mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
ENROLLMENT_DAILY_CAP was 50, so any traffic spike past 50 new users in a day was turned away with a rate_limited card. Raise the default to 500 and add ENROLLMENT_HOURLY_CAP=60. The hourly guard is the one that actually protects the shared PAT: a new user costs ~37 REST calls (p90 ~104) against a 5000/hr budget, and a spike arrives inside an hour rather than spread over a day. Counted off users.enrolled_at, so no schema change. Also stop an unbounded enqueue loop. `name` is drawn inside the composite and never persisted standalone, and `achievements` renders nothing until the user authors one, so their SVG is permanently absent and every request re-enqueued a build that could never produce it. Only self-heal when no build has actually landed, keyed off widget_data for the current hash. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BwMoSbmK77Ph7XaV5YnAdS
Generator Service
Serves precomputed SVGs to the public internet. Holds user settings and
the widgets cache. Runs a build worker + cron in the background. Also
serves the React SPA (frontend sources live under frontend/).
Run locally (3 processes)
cd generator
pip install -r requirements.txt
# API
FETCHER_URL=http://localhost:5001 FETCHER_INTERNAL_TOKEN=dev python -m src.api
# Build worker
FETCHER_URL=http://localhost:5001 FETCHER_INTERNAL_TOKEN=dev python -m src.worker
# Poll cron
FETCHER_URL=http://localhost:5001 FETCHER_INTERNAL_TOKEN=dev python -m src.cron
Frontend (dev)
cd generator/frontend && npm install && npm run dev
# Vite dev server proxies /api to the Flask app.
Test
cd generator && pytest
Docker
Multi-stage (builds the frontend with node, serves everything from Python):
docker build -t ghstats-generator .
docker run --rm -e FETCHER_URL=http://fetcher:5001 -e FETCHER_INTERNAL_TOKEN=dev \
-p 5002:5002 -v $(pwd)/data:/app/data ghstats-generator
# Worker: override CMD to ["python","-m","src.worker"]
# Cron: override CMD to ["python","-m","src.cron"]
Endpoints
All API endpoints are under /api/. The root and /assets/* serve the SPA.
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /api/health | none | health |
| GET | /api/ | none | composite SVG; auto-enrolls unknown users |
| GET | /api//.svg | none | individual widget SVG |
| POST | /api/enroll | none | explicit enroll (body: {username}) |
| GET | /api//settings | stub | current settings |
| PATCH | /api//settings | stub | update settings (enqueues rebuild) |
| POST | /api//refresh | stub | one-shot re-fetch + rebuild |
Responses carry X-Widget-Status: ready | building | rate_limited | not_found.
Env
See src/config.py.