From 74047b28fcf54f195a3102d0edd31b59a432d2b0 Mon Sep 17 00:00:00 2001 From: shay Date: Fri, 17 Apr 2026 17:19:23 -0400 Subject: [PATCH] docs: top-level README + CLAUDE.md reflect three-service layout --- CLAUDE.md | 63 ++++++++++++++++++++++++++++++++ README.md | 106 +++++++++++++++--------------------------------------- 2 files changed, 91 insertions(+), 78 deletions(-) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b698548 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,63 @@ +# CLAUDE.md + +Guidance for Claude Code working in this repository. + +## Layout + +This is a monorepo of three independent Python services plus a Vite+React +frontend. Each service has its own `requirements.txt`, `pytest.ini`, +`Dockerfile`, and README: + +- `fetcher/` — port 5001. Owns the GitHub PAT and `fetcher.db`. Refresh + cron polls GitHub, upserts raw payloads, serves `/data/` to internal + callers only. +- `generator/` — port 5002. Owns settings + widgets SQLite DBs. Build + worker renders SVGs from fetcher data. Serves the React SPA from + `src/static/` and all `/api/*` routes. Frontend sources live in + `generator/frontend/` and get built into `src/static/` by the + multi-stage Dockerfile. +- `edge/` — port 5003. Cache-first SVG proxy in front of the generator; + Flask-Caching + Flask-Compress, optional Redis. + +Per-service READMEs cover run/test/Docker commands. The design and +implementation plan live in `docs/superpowers/`. + +## Working on a single service + +Each service is self-contained. `cd && pytest` is the test +entry point; `cd && pip install -r requirements.txt` is the +dependency install. Don't cross-import across services — they talk +over HTTP (generator → fetcher via `generator/src/fetcher_client.py`; +edge → generator via `edge/src/api.py::_fetch_origin`). + +## Configuration + +All runtime tuning is in each service's `src/config.py` and is +overridable via env vars: + +- `fetcher/src/config.py` — `GITHUB_PAT`, `FETCHER_INTERNAL_TOKEN`, + `COLLABORATOR_*`, `COMMIT_*`, `API_TIMEOUT`, refresh cadence. +- `generator/src/config.py` — `FETCHER_URL`, `FETCHER_INTERNAL_TOKEN`, + `ENROLLMENT_DAILY_CAP`, `WIDGET_LRU_PER_USER`, `POLL_INTERVAL_MINUTES`, + `TAG_MAX_COUNT`, `TAG_LANGUAGE_MAP`, `TAG_TOPIC_MAP`, + `ENABLED_WIDGETS`, `WIDGET_ORDER`, `HIDDEN_LANGUAGES`. +- `edge/src/config.py` — `GENERATOR_URL`, `CACHE_TYPE`, + `CACHE_REDIS_URL`, `CACHE_DEFAULT_TIMEOUT`, `CACHE_THRESHOLD`, + `UPSTREAM_TIMEOUT`. + +## Conventions + +- Widget renderers return SVG strings; only `generator/src/worker.py` + persists them (via `db.put_widgets`). +- The `X-Widget-Status` header (`ready | building | rate_limited | + not_found`) is the contract between generator and edge for what to + cache. +- Generator ↔ fetcher traffic uses the shared secret + `FETCHER_INTERNAL_TOKEN` (HTTP header `X-Internal-Token`). Public + routes on the generator don't require auth in v1. +- Adding a widget still means: new `generator/src/widgets/.py`, + export from `generator/src/widgets/__init__.py`, wire into + `generator/src/processor.py::generate_widgets_from_github`, add the + key to `WIDGET_ORDER` / `ENABLED_WIDGETS` in + `generator/src/config.py`. +- Adding a theme: entry in `generator/src/themes/themes.py`. diff --git a/README.md b/README.md index 2f0e425..a3269ba 100644 --- a/README.md +++ b/README.md @@ -1,90 +1,40 @@ -# GitHub README Stats +# github-readme-stats -Generate polished SVG profile cards from your GitHub data. Fetches your repos, contributions, languages, and collaborators, then renders them into composable widgets you can drop into your profile README. +A monorepo of three independent Python services plus a React frontend, +each self-contained. See each service's README for details. -

- Example composite widget -

+## Services -## Widgets +| Folder | Port | Responsibility | +|---|---|---| +| [`fetcher/`](./fetcher/README.md) | 5001 | Owns GitHub PAT + `fetcher.db`; cron-refreshes data | +| [`generator/`](./generator/README.md) | 5002 | Settings + widgets DBs, build worker, serves React SPA + `/api/*` | +| [`edge/`](./edge/README.md) | 5003 | Cache-first SVG proxy; deploy globally | -| Widget | What it shows | -|--------|--------------| -| **Grade** | Letter grade (S through F) with score breakdown, stats, and inferred role tags | -| **Impact** | Contribution timeline over the last 6 months | -| **Collaborators** | Top people you've committed alongside, ranked by shared commits | -| **Focus** | Where your recent work falls (Backend, Frontend, ML, DevOps, etc.) | -| **Languages** | Donut chart of your most-used languages by LOC | -| **Achievements** | Custom badges you define (hackathons, awards, milestones) | +## Design Docs -Each widget is also saved individually as `widget_.svg`. +- Spec: [`docs/superpowers/specs/2026-04-17-production-pipeline-design.md`](docs/superpowers/specs/2026-04-17-production-pipeline-design.md) +- Plan: [`docs/superpowers/plans/2026-04-17-production-pipeline.md`](docs/superpowers/plans/2026-04-17-production-pipeline.md) -## Quick Start +## Quick start (local dev, no Docker) -```bash -# Basic (public data only) -python run.py + # 1) fetcher + (cd fetcher && pip install -r requirements.txt && + FETCHER_INTERNAL_TOKEN=dev GITHUB_PAT= python -m src.api) & -# With a GitHub token for full commit/contribution data -GITHUB_PAT= python run.py + # 2) generator API, worker, cron (three processes) + cd generator && pip install -r requirements.txt + FETCHER_URL=http://localhost:5001 FETCHER_INTERNAL_TOKEN=dev python -m src.api & + FETCHER_URL=http://localhost:5001 FETCHER_INTERNAL_TOKEN=dev python -m src.worker & + FETCHER_URL=http://localhost:5001 FETCHER_INTERNAL_TOKEN=dev python -m src.cron & -# Choose a theme -python run.py nord -``` + # 3) edge + (cd ../edge && pip install -r requirements.txt && + GENERATOR_URL=http://localhost:5002 python -m src.api) & -Output lands in the repo root as `widget_.svg`. + # 4) frontend (dev server) + cd ../generator/frontend && npm install && npm run dev -## Themes +Test everything: -Five built-in themes: - -| Theme | Style | -|-------|-------| -| `midnight` / `dark` | Dark blue-gray (default) | -| `onyx` | High-contrast on near-black | -| `nord` | Muted pastels on slate | -| `clean` / `light` | White background | -| `paper` | Warm off-white, sepia accents | - -## Web UI - -A React frontend lets you customize widgets interactively with live preview and per-widget advanced settings (colors, counts, etc.). - -```bash -# Terminal 1 — start the generator API -python -m src.generator_api # :5002 - -# Terminal 2 — start the frontend -cd frontend && npm install && npm run dev # :3000 -``` - -Open `http://localhost:3000`, enter a GitHub username, tweak settings, and hit Generate. - -## Configuration - -All tuning lives in `src/config.py` and can be overridden with environment variables. Key knobs: - -| Variable | Default | What it does | -|----------|---------|-------------| -| `GITHUB_PAT` | — | GitHub personal access token | -| `COMMIT_MAX_REPOS` | 10 | Max repos to scan for commits | -| `COMMIT_PER_REPO` | 30 | Max commits per repo | -| `COLLABORATOR_MIN_COMMITS` | 3 | Minimum shared commits to show a collaborator | -| `API_TIMEOUT` | 5 | Per-request timeout in seconds | - -See [CONFIGURATION.md](CONFIGURATION.md) for the full list. - -## Project Structure - -``` -src/ - data/ # GitHub API fetching + data processing - widgets/ # One SVG renderer per widget - themes/ # Color palettes - models/ # Typed data structures - utils/ # SVG helpers - config.py # All tunables - generate.py # CLI entry point - generator_api.py # Flask API for the web UI -frontend/ # React + TypeScript + Vite -``` + (cd fetcher && pytest) && (cd generator && pytest) && (cd edge && pytest)