Context
Every visitor's GitHub API calls currently ride on the single server-side GITHUB_TOKEN
(lib/github.ts, lib/squad/contributors.ts,
lib/squad/valuation.ts) — one shared 5,000-points/hour budget for the whole
site (see docs/caching-and-rate-limits.md for the real cost accounting). Caching
absorbs most of this today, but a viral spike of cold (never-cached) lookups could exhaust the shared budget for
everyone.
The ask: let a visitor optionally sign in with their own GitHub account (OAuth) so their lookups draw on
their own rate limit instead of the shared one. This should be additive — the site must keep working exactly as
it does today for anyone who doesn't sign in.
Files involved
- New: an OAuth flow — a GitHub OAuth App (not a PAT), a callback route under
app/api/, and short-lived session
storage (a signed cookie is enough; no database exists in this project and this shouldn't be the reason to add
one).
lib/github.ts — githubGraphQL() currently reads process.env.GITHUB_TOKEN unconditionally; needs a path to
accept a per-request token instead.
lib/squad/contributors.ts, lib/squad/valuation.ts — same, for the REST calls.
components/Navbar.tsx / components/NavbarClient.tsx — where a "Sign in with GitHub" affordance would live.
Acceptance criteria
Notes
This is explicitly optional/best-effort — don't block on handling every OAuth edge case (revoked tokens mid-session
etc.) perfectly for a first version; document known limitations instead.
Context
Every visitor's GitHub API calls currently ride on the single server-side
GITHUB_TOKEN(
lib/github.ts,lib/squad/contributors.ts,lib/squad/valuation.ts) — one shared 5,000-points/hour budget for the wholesite (see
docs/caching-and-rate-limits.mdfor the real cost accounting). Cachingabsorbs most of this today, but a viral spike of cold (never-cached) lookups could exhaust the shared budget for
everyone.
The ask: let a visitor optionally sign in with their own GitHub account (OAuth) so their lookups draw on
their own rate limit instead of the shared one. This should be additive — the site must keep working exactly as
it does today for anyone who doesn't sign in.
Files involved
app/api/, and short-lived sessionstorage (a signed cookie is enough; no database exists in this project and this shouldn't be the reason to add
one).
lib/github.ts—githubGraphQL()currently readsprocess.env.GITHUB_TOKENunconditionally; needs a path toaccept a per-request token instead.
lib/squad/contributors.ts,lib/squad/valuation.ts— same, for the REST calls.components/Navbar.tsx/components/NavbarClient.tsx— where a "Sign in with GitHub" affordance would live.Acceptance criteria
x-ratelimit-remainingbehavior or via logging.docs/caching-and-rate-limits.mdupdated to describe the new per-user path alongside the existing shared one.Notes
This is explicitly optional/best-effort — don't block on handling every OAuth edge case (revoked tokens mid-session
etc.) perfectly for a first version; document known limitations instead.