This FastAPI service renders cumulative CNB Star/Fork histories as SVG or PNG charts.
All data is pulled from the official CNB API:
https://api.cnb.cool/{repo}/-/{resource}?filter_type=all
where {resource} is either stars or forks.
| Variable | Purpose |
|---|---|
CNB_API_TOKEN | Bearer token for the CNB API |
CNB_API_BASE_URL (optional) | Override the API host (defaults to https://api.cnb.cool) |
REDIS_URL (optional) | Enables Redis-backed caching; falls back to in-memory cache |
CACHE_TTL_SECONDS (optional) | Cache time-to-live in seconds (default 86400) |
You can place these in a .env file— the app loads it automatically via python-dotenv.
pip install -r requirements.txt
python main.py # reload enabled by default
Set UVICORN_RELOAD=0 to disable hot reload.
Endpoints:
/stars/{repo} → star history chart; pass multiple repos (up to 6) separated by commas to render a comparison (e.g. /stars/cnb/feedback,cnb/cool/git-clone-yyds)./forks/{repo} → fork history chart/issues/{repo} → issue history chart/healthz → health checkEach supports query options:
image_format=svg|pngtheme=light|dark (default light)accumulation=cumulative|net (default cumulative); net plots the monthly growth instead of the running totalstate=open, state=closed, state=open,closed (default all), state=both (renders open & closed lines together), and authors=user1,user2docker build -t commitcool .
docker run --env-file .env -p 8000:8000 commitcool
Then call http://localhost:8000/stars/cnb/feedback.