Turn your GitHub activity into a cinematic, Shields-style Rank badge โ with granular sub-ranks (IโIV), a colorful XP indicator, Jedi/Sith themes, streaks, fun Trials (achievements), and shareable head-to-head Duels.
- Auto-computed rank (0โ100) from GitHub activity (GraphQL preferred; REST fallback)
- Granular sub-ranks inside each tier: I โ II โ III โ IV
- XP indicator: dots or bar, color-ramped by progress
- Themes:
jedi(space-blue) orsith(crimson/black) - Streaks (consecutive days with โฅ1 contribution), computed from your contribution calendar, with an events-based fallback
- Trials: fun achievement badges based on your recent activity
- Rank Duels: shareable SVG posters for A vs B
- Zero front-end required: every endpoint returns SVG (or JSON if you want raw data)
Drop this in your GitHub profile README, swapping in your username:
[](https://yoda-level-github-badge.vercel.app/api/user-rank?username=YOUR_USERNAME)Sith theme + XP bar:
[](https://yoda-level-github-badge.vercel.app/api/user-rank?username=YOUR_USERNAME)Rank Duel โ you vs a friend:
[](https://yoda-level-github-badge.vercel.app/api/duel?user1=YOUR_USERNAME&user2=THEIR_USERNAME&theme=jedi)Trials (achievements strip):
Manual points badge (no GitHub calls):
Replace the domain with your own deployment if you forked and redeployed this project.
- Method:
GET - Returns:
SVGwhenbadge=1, otherwiseJSON
Core params
| Param | Type | Default | Description |
|---|---|---|---|
username |
string | โ | GitHub username (required) |
badge |
0|1 | 0 |
1 โ return SVG badge; 0 โ JSON |
label |
string | Rank |
Left-side label |
logo |
enum | saber |
galaxy | saber | github |
theme |
enum | jedi |
jedi | sith |
granular |
0|1 | 0 |
Show sub-rank IโIV inside the tier |
xp |
enum | dots |
dots | bar | none |
showPoints |
0|1 | 0 |
Append score (e.g., 82.5 pts) |
showNext |
0|1 | 0 |
Append delta to next tier (e.g., +2.0 to Grand Master) |
streak |
0|1 | 0 |
Show streak on the badge text |
streakMode |
enum | classic |
classic (consecutive days โฅ1) | momentum (2-day rolling window) |
streakSource |
enum | calendar |
calendar | events | hybrid (merges both, taking the max) |
streakWindow |
number | 120 |
Days of history for streak calc (30โ365) |
JSON example
/api/user-rank?username=CosminBMemetea
{
"username": "CosminBMemetea",
"points": 73.4,
"rank": "B",
"persona": "Rebel Pilot",
"color": "#8b5cf6",
"method": "graphql",
"streak": { "mode": "classic", "days": 5 },
"granular": { "band": "II", "nextTier": "Rebel Commander", "pointsToNext": 1.6, "pctWithinTier": 41.2 },
"tiers": [
{ "grade": "S++", "name": "Master Yoda", "min": 98 },
...
]
}SVG example
/api/user-rank?username=torvalds&badge=1&granular=1&xp=bar&theme=sith&streak=1&logo=saber
- Method:
GET - Returns:
SVG
Params
| Param | Type | Default | Description |
|---|---|---|---|
label |
string | Rank |
Left-side text |
persona |
string | Master Yoda |
Right persona (ignored if points is provided) |
grade |
string | S++ |
Right grade (ignored if points is provided) |
points |
number | โ | If provided, maps pointsโtier and fills persona/grade/color |
granular |
0|1 | 0 |
Show IโIV inside tier |
xp |
enum | dots |
dots | bar | none |
showPoints |
0|1 | 0 |
Append numeric points |
showNext |
0|1 | 0 |
Add distance to next tier |
logo |
enum | saber |
galaxy | saber | github |
theme |
enum | jedi |
jedi | sith |
Example
/api/badge?points=82.5&label=Rank&granular=1&xp=bar&showPoints=1&showNext=1&logo=galaxy
- Method:
GET - Returns:
SVGwhenbadgeisn't0, otherwiseJSON
Params
| Param | Type | Default | Description |
|---|---|---|---|
user1 |
string | โ | First GitHub username (required; u1 also works) |
user2 |
string | โ | Second GitHub username (required; u2 also works) |
theme |
enum | jedi |
jedi | sith |
icon1 |
enum | saber |
github | saber | galaxy | none โ left icon |
icon2 |
enum | galaxy |
github | saber | galaxy | none โ right icon |
badge |
0|1 | 1 |
0 โ return JSON instead of SVG |
Example
/api/duel?user1=CosminBMemetea&user2=torvalds&theme=jedi
- Method:
GET - Returns:
SVG(icon strip or card grid), orJSONwithjson=1
Params
| Param | Type | Default | Description |
|---|---|---|---|
username |
string | โ | GitHub username (required) |
theme |
enum | jedi |
jedi | sith |
detailed |
0|1 | 0 |
1 โ multi-row card grid with descriptions; 0 โ compact icon strip |
labels |
0|1 | 0 |
Show short labels under icons in compact mode |
cols |
number | 3 |
Columns for the detailed card grid (1โ4) |
title |
string | Yoda Trials |
Heading text |
streakWindow |
number | 180 |
Days of history used for the streak-based trial (30โ400) |
json |
0|1 | 0 |
1 โ return raw JSON instead of SVG |
Trials unlock based on recent activity: commits in the last 7/30 days, merged PRs, PR reviews, commit streaks, distinct issues opened, total stars, and reaching S-tier.
Example
/api/trials?username=CosminBMemetea&theme=jedi&detailed=1
- S++: Master Yoda (98โ100)
- S+: Grand Master (โฅ96) โข S: Jedi Master (โฅ94) โข S-: Jedi Council (โฅ92) โข S--: Sith Lord (โฅ90)
- A+: Obi-Wan Kenobi (โฅ85) โข A: Jedi Knight (โฅ80)
- B+: Rebel Commander (โฅ75) โข B: Rebel Pilot (โฅ70)
- C+: Padawan (โฅ65) โข C: Youngling (โฅ60) โข C-: Academy Cadet (โฅ55)
- D+: Frontier Scout (โฅ50) โข D: Cantina Regular (โฅ45) โข D-: Scrapyard Tech (โฅ40)
- F+: Moisture Farmer (โฅ30) โข F: Force Beginner (โฅ0)
Sub-ranks inside each tier: I (entry) โ IV (top).
| Name | Required | Purpose |
|---|---|---|
GITHUB_TOKEN |
Recommended | Enables GitHub GraphQL (richer metrics + 5,000 req/hr). Public-data scope is enough. Without it, the app falls back to REST with lower rate limits. |
Vercel: Project โ Settings โ Environment Variables โ add GITHUB_TOKEN, redeploy.
Local: create .env.local:
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxx
# install
npm i
# local dev
npm run dev
# build check
npm run build- Push to GitHub.
- Import the repo into Vercel.
- Set
GITHUB_TOKEN(optional but recommended). - Vercel auto-builds when you push.
- Edge Runtime routes (
app/api/**/route.ts) for fast cold starts. - SVG is XML-safe (attributes/text escaped; decimals use
0.xnot.x). - Caching: responses set
s-maxagefor CDN caching; add&t=<nonce>to bust caches if needed. - XP colors ramp with progress: red โ amber โ lime โ green (Sith palette adjusts hues).
- Legend override: obvious legends (e.g.,
torvalds) are clamped to 100 to ensure โYoda (S++)โ.
- Broken SVG / XML error: You're hitting a cached response. Re-deploy and add
&t=1to the URL. - Streak looks wrong: Hit
/api/streak-debug?username=YOUR_USERNAMEโ it returns the raw per-day counts and computed streak so you can see exactly what's being counted. Without your ownGITHUB_TOKEN, only public contributions are visible. - Module not found (
@/lib/...):- Ensure
tsconfig.jsonhas:{ "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./*"] } } } - Or use relative imports like
../../../lib/rank.
- Ensure
- Rate limited /
"method":"rest": SetGITHUB_TOKENin env and redeploy.
MIT โ use anywhere, contributions welcome.
Built with Next.js App Router + Edge Functions. Star Wars-inspired styling for fun; not affiliated with Lucasfilm/Disney. GitHub data via REST/GraphQL APIs.