diff --git a/README.md b/README.md index 76fea48..90acd50 100644 --- a/README.md +++ b/README.md @@ -12,28 +12,19 @@ and earns you tags like `Backend`, `ML`, or `Founder #42`. ![my stats](https://gh-stats.com/YOUR_USERNAME) ``` -![hero widget](https://gh-stats.com/ShayManor) +composite widget, midnight theme
-Table of contents (click to show) +Table of contents (click to expand) - [Quick start](#quick-start) -- [The composite widget](#the-composite-widget) -- [Individual widgets](#individual-widgets) - - [Grade](#grade) - - [Impact timeline](#impact-timeline) - - [Streaks](#streaks) - - [Top collaborators](#top-collaborators) - - [Recent focus](#recent-focus) - - [Languages](#languages) - - [Achievements](#achievements) - [Themes](#themes) -- [Customization via query parameters](#customization-via-query-parameters) +- [Individual widgets](#individual-widgets) +- [Query parameter reference](#query-parameter-reference) +- [Auto-awarded tags](#auto-awarded-tags) - [Refreshing your data](#refreshing-your-data) -- [Status states](#status-states) -- [Self-hosting](#self-hosting) -- [Running tests](#running-tests) - [FAQ](#faq) +- [Gallery](#gallery)
@@ -41,174 +32,55 @@ and earns you tags like `Backend`, `ML`, or `Founder #42`. ## Quick start -1. Open in a browser. -2. **Sign in with GitHub** — this enrolls your username and makes you the - owner of the widget. The editor (Workshop) is only accessible to the - signed-in owner. -3. Pick a theme, reorder widgets, add custom tags and achievements. -4. Click **Generate** — the SVG is built on the server and cached. -5. Copy the one-liner into your profile README: +1. Open . +2. Sign in with GitHub. Signing in is how you prove ownership of the + username, and it unlocks the editor. +3. Pick a theme, reorder widgets, add any custom tags or achievements. +4. Click **Generate**. +5. Paste this one line into your profile README: ```md ![my stats](https://gh-stats.com/YOUR_USERNAME) ``` -That's it. A 15-minute refresh cron picks up new GitHub activity, so the -image stays current on its own. +The image URL is stable. Once it's in your README you can change +themes, tags, or widget order in the editor at any time without +touching the markdown. > [!NOTE] -> The image URL is stable. Once it's in your README, you can change -> themes, tags, or widget order in the Workshop without ever touching -> the markdown again. - ---- - -## The composite widget - -The default URL returns a single composed card with every enabled widget -stacked in your chosen order. - -Endpoint: `https://gh-stats.com/` - -```md -![stats](https://gh-stats.com/anuraghazra) -``` - -![composite example](https://gh-stats.com/anuraghazra) - -> [!WARNING] -> Only public GitHub activity is counted. Private commits, private -> repos, and organization-restricted contributions are not visible to -> the fetcher. This applies even on self-hosted deployments — the PAT -> only sees what GitHub's public GraphQL/REST endpoints expose. - ---- - -## Individual widgets - -Don't want the full stack? Every widget is independently addressable at -`https://gh-stats.com//.svg`: - -```md -![grade](https://gh-stats.com/YOUR_USERNAME/grade.svg) -![impact](https://gh-stats.com/YOUR_USERNAME/impact.svg) -![streaks](https://gh-stats.com/YOUR_USERNAME/streaks.svg) -![collaborators](https://gh-stats.com/YOUR_USERNAME/collaborators.svg) -![focus](https://gh-stats.com/YOUR_USERNAME/focus.svg) -![languages](https://gh-stats.com/YOUR_USERNAME/languages.svg) -![achievements](https://gh-stats.com/YOUR_USERNAME/achievements.svg) -``` - -Put two side-by-side with an HTML table (GitHub strips inline CSS, so a -table is the only reliable way): - -```html - - - -
-``` - -### Grade - -Overall score (0–100), letter grade (S / A / B / C / D / F), and your -top role tags. The grade is a weighted blend of commit volume, review -activity, recent authorship, and language breadth — see -`generator/src/scoring.py` for the exact formula. - -```md -![grade](https://gh-stats.com/YOUR_USERNAME/grade.svg?grade.max_tags=6) -``` - -### Impact timeline - -A smooth contribution curve over the last 6 months, drawn against a -faint grid. Nice on its own, or sitting above a languages card. - -```md -![impact](https://gh-stats.com/YOUR_USERNAME/impact.svg?impact.line_color=%23a78bfa) -``` - -### Streaks - -Current and longest contribution streak, with a small spark chart. - -```md -![streaks](https://gh-stats.com/YOUR_USERNAME/streaks.svg?streaks.color=%233fb950) -``` - -### Top collaborators - -Avatars, shared-repo count, and commit bars for the people you work -with most. We filter out huge OSS projects (configurable via -`COLLABORATOR_MAX_REPO_SIZE`) so your drive-by PR to `react` doesn't -put the React team on your card. - -```md -![collab](https://gh-stats.com/YOUR_USERNAME/collaborators.svg?collaborators.max_count=5) -``` - -### Recent focus - -What you've actually been working on lately, grouped by topic/language -cluster. - -```md -![focus](https://gh-stats.com/YOUR_USERNAME/focus.svg?focus.max_categories=5) -``` - -### Languages - -Your language mix, weighted by bytes in **repos you authored** (forks -where you haven't contributed meaningfully are ignored). Hide noise -like `HTML` or `Makefile` with the `hide` parameter. - -```md -![langs](https://gh-stats.com/YOUR_USERNAME/languages.svg?hide=HTML,CSS,Makefile) -``` - -### Achievements - -Up to 10 hand-entered lines — hackathons, talks, awards, certifications. -Each line has an icon (`trophy`, `medal`, `star`, `hackathon`), a -title, a subtitle, and an optional date. - -```md -![ach](https://gh-stats.com/YOUR_USERNAME/achievements.svg) -``` +> Only public GitHub activity is counted. Private repos, private +> commit counts, and contributions to org-restricted repos are never +> visible to the fetcher. --- ## Themes -Pass `?theme=` or pick one in the Workshop. Five built-ins: +Pass `?theme=` on the URL, or pick one in the editor. -| Theme | Tone | +| Theme | Preview | |---|---| -| `midnight` *(default)* | dark, soft blue accents | -| `onyx` | deep black, neon violet | -| `nord` | muted pastel on slate | -| `clean` | white, understated | -| `paper` | warm off-white | +| `midnight` (default) | | +| `onyx` | | +| `nord` | | +| `clean` | | +| `paper` | | ```md -![onyx](https://gh-stats.com/YOUR_USERNAME?theme=onyx) -![nord](https://gh-stats.com/YOUR_USERNAME?theme=nord) -![clean](https://gh-stats.com/YOUR_USERNAME?theme=clean) -![paper](https://gh-stats.com/YOUR_USERNAME?theme=paper) +![stats](https://gh-stats.com/YOUR_USERNAME?theme=onyx) ``` -### Dark / light auto-switching +### Auto-switching for dark and light mode -Use GitHub's built-in theme context suffixes to serve a different image -to viewers on dark vs. light GitHub: +Add GitHub's theme suffix to serve a different image to dark vs. light +viewers: ```md ![dark](https://gh-stats.com/YOUR_USERNAME?theme=onyx#gh-dark-mode-only) ![light](https://gh-stats.com/YOUR_USERNAME?theme=clean#gh-light-mode-only) ``` -Or with `` for precise `prefers-color-scheme` control: +Or use `` for precise `prefers-color-scheme` control: ```html @@ -222,215 +94,272 @@ Or with `` for precise `prefers-color-scheme` control: --- -## Customization via query parameters +## Individual widgets -Every widget URL accepts query parameters. They let you override the -owner's saved settings on a per-embed basis **without re-enrolling or -signing in** — useful when someone else wants to embed your widget -with different options. Nothing is persisted; the owner's widget is -unaffected. +Every widget is independently addressable at +`https://gh-stats.com//.svg`. Embed one, two, or all +of them. + +### Grade + +Overall score (0 to 100), letter grade, and your top role tags. + +grade widget + +```md +![grade](https://gh-stats.com/YOUR_USERNAME/grade.svg) +``` + +### Impact + +Your contribution volume over the last 6 months, drawn as a smooth area +chart. + +impact widget + +```md +![impact](https://gh-stats.com/YOUR_USERNAME/impact.svg) +``` + +### Streaks + +Current and longest contribution streaks. + +streaks widget + +```md +![streaks](https://gh-stats.com/YOUR_USERNAME/streaks.svg) +``` + +### Top collaborators + +The people you actually work with, filtered down to repos of a +reasonable size so a drive-by PR to `react` does not put the React team +on your card. + +collaborators widget + +```md +![collaborators](https://gh-stats.com/YOUR_USERNAME/collaborators.svg) +``` + +### Recent focus + +What you have actually been working on lately, grouped by topic. + +focus widget + +```md +![focus](https://gh-stats.com/YOUR_USERNAME/focus.svg) +``` + +### Languages + +Your language mix, weighted by bytes in repos you authored. Forks with +no meaningful contribution are ignored. + +languages widget + +```md +![languages](https://gh-stats.com/YOUR_USERNAME/languages.svg) +``` + +### Achievements + +Hand-entered lines for hackathons, talks, awards, and certifications. + +achievements widget + +```md +![achievements](https://gh-stats.com/YOUR_USERNAME/achievements.svg) +``` + +### Side by side + +GitHub strips inline CSS, so an HTML table is the simplest way to put +two widgets next to each other. + +```html + + + +
+``` + +--- + +## Query parameter reference + +Every URL accepts query parameters. They override the owner's saved +settings on a per-embed basis, so viewers can tweak the look without +changing anything the owner has stored. + +Values with special characters must be URL-encoded: `#a78bfa` becomes +`%23a78bfa`, a space becomes `%20`. ### Common parameters -| Parameter | Description | Type | Example | -|---|---|---|---| -| `theme` | Built-in theme name. | enum | `?theme=onyx` | -| `widgets` | Which widgets to render (composite only). | csv | `?widgets=grade,languages` | -| `order` | Render order (composite only). | csv | `?order=grade,streaks,impact` | -| `hide` | Languages to exclude from the languages widget. | csv | `?hide=HTML,CSS,Makefile` | -| `tags` | Extra custom role tags to merge into the grade widget. | csv | `?tags=ML,Systems` | -| `ach` | Achievements list as url-safe base64(json). | string | see below | - -> [!NOTE] -> Values with special characters must be URL-encoded. `#a78bfa` becomes -> `%23a78bfa`; `Jupyter Notebook` becomes `Jupyter%20Notebook`. +| Parameter | What it does | Example | +|---|---|---| +| `theme` | Built-in theme name. | `?theme=onyx` | +| `widgets` | Which widgets to show on the composite card. | `?widgets=grade,streaks,languages` | +| `order` | Render order on the composite card. | `?order=grade,streaks,languages` | +| `hide` | Languages to exclude from the languages widget. | `?hide=HTML,CSS,Makefile` | +| `tags` | Extra custom role tags on the grade widget. | `?tags=ML,Systems` | ### Per-widget parameters Use dot notation: `.=`. -| Parameter | Description | Type | Default | +| Parameter | What it does | Type | Default | |---|---|---|---| -| `grade.max_tags` | Max role tags shown on the grade card (1–20). | int | all tags | -| `impact.line_color` | Accent color for the contribution curve. | hex color | theme accent | -| `streaks.color` | Accent color for the streak bars. | hex color | theme green | -| `collaborators.max_count` | Max collaborators shown (1–10). | int | `5` | +| `grade.max_tags` | Max role tags shown (1 to 20). | int | all tags | +| `impact.line_color` | Accent color for the area curve. | hex color | theme accent | +| `streaks.color` | Accent color for the current-streak text. | hex color | theme accent | +| `collaborators.max_count` | Max collaborators shown (1 to 10). | int | 5 | | `collaborators.bar_color` | Accent color for the commit bars. | hex color | theme accent | -| `focus.max_categories` | Max focus clusters shown (1–10). | int | `6` | -| `languages.max_languages` | Max languages shown (1–10). | int | `5` | -| `achievements.max_items` | Max achievement rows shown (1–10). | int | `5` | +| `focus.max_categories` | Max focus clusters shown (1 to 10). | int | 6 | +| `languages.max_languages` | Max languages shown (1 to 10). | int | 5 | +| `achievements.max_items` | Max achievement rows shown (1 to 10). | int | 5 | -Example combining several overrides: +--- -```md -![stats](https://gh-stats.com/YOUR_USERNAME?theme=onyx&widgets=grade,streaks,languages&order=grade,streaks,languages&hide=HTML,CSS&grade.max_tags=4&streaks.color=%23a78bfa) -``` +## Auto-awarded tags -### Auto-awarded tags +Some tags on the grade card are earned from real activity. No query +parameter will add them if you have not earned them: -Some tags on the grade card are earned from real activity — no query -parameter will add them if you haven't earned them: - -- `Founder #N` — one of the first N users to enroll. Your number is - fixed at enrollment and never changes. +- `Founder #N` is your enrollment number, fixed when you first sign in. - Role tags like `Backend`, `Frontend`, `ML`, `Mobile`, `DevOps`, - `Cloud`, `Systems`, `Database`, `Security` — derived from your - language mix and repo topics. The mapping lives in - `generator/src/config.py` (`TAG_LANGUAGE_MAP`, `TAG_TOPIC_MAP`). + `Cloud`, `Systems`, `Database`, `Security` are derived from your + language mix and repo topics. --- ## Refreshing your data -The refresh cron re-pulls GitHub data every **15 minutes**, so new -commits typically appear in your widget within that window. GitHub's -image CDN may add another minute or two of staleness on top. +The refresh cron re-pulls GitHub data every 15 minutes, so new commits +usually appear in your widget within that window. GitHub's image CDN +may add another minute or two on top. -If you need an immediate update (e.g. right after merging something -big), click **Refresh now** in the Workshop. This is a **one-shot per -account** — use it when it matters. - ---- - -## Status states - -The SVG endpoint advertises its state via the `X-Widget-Status` -response header, and the edge cache uses it to decide whether to cache: - -| Status | Meaning | What the viewer sees | -|---|---|---| -| `ready` | Built and cached | the real widget | -| `building` | Enrolled, first render in progress | a placeholder card | -| `rate_limited` | Daily enrollment cap hit | a placeholder card | -| `not_found` | GitHub username doesn't exist | a 404-style card | - -GitHub caches images aggressively; a just-enrolled widget may show the -placeholder for a minute or two before the real image propagates. This -is normal — no action needed on your side. - ---- - -## Self-hosting - -If you want your own instance, it runs as three Python services plus a -Vite+React SPA served by the generator. You'll need a GitHub Personal -Access Token (classic, `read:user` + `repo:public_repo` is enough) and, -for OAuth-based enrollment, a GitHub OAuth App. - -```bash -# 1) fetcher — owns the PAT, talks to GitHub (port 5001) -cd fetcher && pip install -r requirements.txt -FETCHER_INTERNAL_TOKEN=dev GITHUB_PAT= python -m src.api & - -# 2) generator — API + worker + refresh cron (port 5002) -cd ../generator && pip install -r requirements.txt -export FETCHER_URL=http://localhost:5001 -export FETCHER_INTERNAL_TOKEN=dev -export GH_OAUTH_CLIENT_ID= -export GH_OAUTH_CLIENT_SECRET= -python -m src.api & -python -m src.worker & -python -m src.cron & - -# 3) edge — cache-first SVG proxy (put this behind your domain) (port 5003) -cd ../edge && pip install -r requirements.txt -GENERATOR_URL=http://localhost:5002 python -m src.api & - -# 4) frontend (dev only — production builds are baked into the generator image) -cd ../generator/frontend && npm install && npm run dev -``` - -Each service is independent: a Dockerfile, `requirements.txt`, and -`pytest.ini` sit in its directory. The generator image bundles the -pre-built frontend, so a production deploy is `edge → generator → -fetcher` with one domain pointed at edge. - -### Capacity knobs - -Sensible defaults out of the box; all overridable via env: - -| Env | Default | What it bounds | -|---|---|---| -| `GENERATE_CONCURRENCY` | `2` | Simultaneous SVG renders | -| `PREFETCH_MAX_WORKERS` | `2` | Background prefetch threads | -| `PENDING_JOB_QUEUE_CAP` | `200` | Build-queue depth before new enrolls 429 | -| `ENROLLMENT_DAILY_CAP` | `50` | New users per day | -| `RATE_LIMIT_READ_MAX` | `3000` per 60s | Per-IP README embeds | -| `RATE_LIMIT_MUTATE_MAX` | `120` per 60s | Per-IP settings edits / generates | -| `RATE_LIMIT_ENROLL_MAX` | `60` per 300s | Per-IP new enrollments | -| `EDGE_RATE_LIMIT_MAX` | `3000` per 60s | Per-IP at the edge | - -### Required env for OAuth - -| Env | Description | -|---|---| -| `GH_OAUTH_CLIENT_ID` | GitHub OAuth App client ID | -| `GH_OAUTH_CLIENT_SECRET` | GitHub OAuth App client secret | -| `GH_OAUTH_REDIRECT_URI` | Callback URL, e.g. `https://gh-stats.com/api/auth/github/callback` | -| `GENERATOR_SECRET_KEY` | Flask session signing key (`python -c 'import secrets;print(secrets.token_hex(32))'`) | -| `ALLOWED_ORIGINS` | Comma-separated origin allow-list for mutate routes | - ---- - -## Running tests - -Each service is self-contained: - -```bash -(cd fetcher && pytest) && (cd generator && pytest) && (cd edge && pytest) -``` +If you need an immediate update (for example right after merging +something big), click **Refresh now** in the editor. It is a one-shot +per account, so save it for when it matters. --- ## FAQ **Can I use a private GitHub account?** -No. The fetcher only reads public activity. Private repos, private -commit counts, and org-restricted contributions are never included — -even on a self-hosted instance, since the public GitHub API doesn't -expose them. +No. The service only reads public activity. Private repos, private +commit counts, and contributions to org-restricted repos are not +visible to GitHub's public API, so they are never part of the widget. **How fresh is the data?** -Every 15 minutes via the refresh cron. You can also click **Refresh -now** in the Workshop once per account for an immediate update. +Every 15 minutes, automatically. You can also click **Refresh now** +once per account for an immediate update. **How do I edit my widget?** -Sign in with GitHub at . Only the GitHub account -that owns the username can edit that widget's settings. There is no -other edit path — the Workshop's mutate routes require both a valid -session cookie and a matching login. - -**Someone else's username is already showing on the site — can I claim it?** -Yes. Enrollment happens implicitly on first GitHub sign-in: the first -time the owner of a username signs in, their settings row is created -(or taken over, if it was auto-enrolled by a previous viewer). No -manual claim step is needed. +Sign in with GitHub at . Only the account whose +login matches the username can edit that widget's settings. **Can I change the widget without re-embedding?** -Yes. The image URL is stable. Edit settings in the Workshop, click -**Generate**, and the next fetch serves the new version. GitHub's -image cache may delay propagation by a few minutes. +Yes. The image URL is stable. Edit in the editor, click **Generate**, +and the next fetch serves the new version. GitHub's image cache may +delay propagation by a few minutes. -**Can I embed someone else's widget with my own theme / filters?** -Yes — use [query parameters](#customization-via-query-parameters). The -owner's stored settings are unaffected; the override render is -computed on demand and cached briefly. +**Can I embed someone else's widget with my own theme or filters?** +Yes, use the [query parameters](#query-parameter-reference). The +owner's saved settings are not affected. -**I'm getting a placeholder card. What's wrong?** -Check the `X-Widget-Status` header on the response (`curl -I -https://gh-stats.com/`). `building` means first render is in -progress — wait a minute. `rate_limited` means the daily enrollment -cap was hit — try tomorrow. `not_found` means GitHub doesn't know -that username. +**I am getting a placeholder card. What is wrong?** +`building` means the first render is still in progress, give it a +minute. `not_found` means GitHub does not know that username. -**Why does my `Languages` card look wrong?** -The languages widget only counts repos you authored, weighted by -bytes. Forks where you haven't made enough commits are excluded (see -`FORK_MIN_COMMITS`). Add `?hide=HTML,CSS,Makefile` if stock-generated -files are dominating the breakdown. +**Why does my languages card look wrong?** +It counts bytes in repos you authored. Forks with little commit +activity are dropped. Add `?hide=HTML,CSS,Makefile` if generated files +dominate the breakdown. -**Does the public instance work for high-traffic profiles?** -It's best-effort. The public instance at `gh-stats.com` runs on a -single mini PC, and the capacity knobs above are tuned for that. If -your profile gets heavy traffic, self-host — the edge cache in front -of the generator scales the read path almost for free. +**Can I reorder widgets?** +Yes, either in the editor (drag and drop) or by passing +`?widgets=...&order=...` on the URL. + +--- + +## Gallery + +### Composite themes + + + + + + + + + + + + + + +
midnight
onyx
nord
clean
paper
custom (onyx, 3 widgets)
+ +### Single-widget examples + + + + + + + + + + + + + + + + + + + + + + + + + + +
Grade
Grade (max_tags=3)
Impact
Impact (purple line)
Streaks
Streaks (green)
Languages
Languages (hide Shell, Dockerfile)
Collaborators
Focus
Achievements
+ +### Mix and match + +Embed two widgets side by side with an HTML table: + +```html + + + +
+``` + +Stack a custom composite with only three widgets: + +```md +![stats](https://gh-stats.com/YOUR_USERNAME?theme=onyx&widgets=grade,streaks,languages&order=grade,streaks,languages) +``` + +Recolor the impact line: + +```md +![impact](https://gh-stats.com/YOUR_USERNAME/impact.svg?impact.line_color=%23a78bfa) +``` + +Hide noisy languages: + +```md +![langs](https://gh-stats.com/YOUR_USERNAME/languages.svg?hide=HTML,CSS,Makefile) +```