How siddharth-m-s/commitquest works
Purpose and Runtime
CommitQuest is a Next.js 14 App Router application that converts GitHub contribution history into shareable RPG character profiles. It runs as a TypeScript server-rendered web app with Tailwind UI, deployable to Vercel/Netlify-compatible infrastructure. Primary external dependencies are GitHub GraphQL/OAuth and optional Upstash Redis.
Core entry points:
• Public landing/search: src/app/page.tsx
• Public character profile: src/app/[username]/page.tsx
• Authenticated account view: src/app/account/page.tsx
• Root application shell: src/app/layout.tsx
Profile and Stats Orchestration
src/lib/stats-service.ts is the central application service: it obtains a user’s GitHub-derived stats, applies caching, and produces the domain data consumed by pages and APIs. Public lookups use the server public token; signed-in users can use their GitHub OAuth token, enabling private-repository contribution access.
Stats are exposed independently for reuse:
• src/app/api/stats/[username]/route.ts
• src/app/api/me/route.ts
• src/lib/types.ts
The public route/page boundary allows profiles to render without an account, while account/auth flows selectively add private data access.
GitHub Data Acquisition
GitHub integration is isolated under src/lib/github/:
• src/lib/github/client.ts
• src/lib/github/queries.ts
• src/lib/github/fetcher.ts
The fetcher executes GraphQL contribution queries one year at a time because GitHub limits contribution collections to yearly ranges. It parallelizes yearly requests to assemble all-time history, then returns raw activity, repository, language, and profile data to the stats service. This is the principal external-service and rate-limit boundary.
RPG Domain Engine
The transformation from GitHub metrics to a persistent character model is separated from transport/UI:
• src/lib/rpg/engine.ts
• src/lib/rpg/xp.ts
• src/lib/rpg/levels.ts
The engine combines contributions and repository signals into XP, level/title, language-derived class/skills, and achievements. Supporting domain modules keep the mechanics independently evolvable:
• src/lib/rpg/skills.ts
• src/lib/rpg/achievements.ts
Pages and image generation should consume this computed character output rather than reimplement scoring rules.
Cache and Persistence Boundary
There is no primary database for core profiles. Cache behavior is encapsulated in:
• src/lib/cache.ts
• src/lib/stats-service.ts
Upstash Redis provides a shared six-hour stats cache when configured. Without Upstash, the service falls back to in-memory caching for local/zero-service operation. Cached data sits between expensive GitHub GraphQL aggregation and all profile/API consumers; it is performance infrastructure, not durable user state.
Authentication, Preferences, and Monetization
NextAuth provides GitHub OAuth and session/token handling:
• src/lib/auth.ts
• src/app/api/auth/[...nextauth]/route.ts
• src/types/next-auth.d.ts
User-specific settings are handled behind the preferences API and library:
• src/app/api/prefs/route.ts
• src/lib/prefs.ts
Subscription/pricing concerns are isolated rather than embedded in profile computation:
• src/lib/subscriptions.ts
• src/app/pricing/page.tsx
Presentation, Sharing, and Discovery
The profile UI composes reusable RPG visual components:
• src/components/CharacterCard.tsx
• src/components/SkillBar.tsx
• src/components/AchievementBadge.tsx
Share surfaces reuse profile data through dedicated image/badge endpoints:
• src/app/api/og/[username]/route.tsx
• src/app/api/badge/[username]/route.ts
Discovery and comparison are separate page flows built around username/profile stats:
• src/app/leaderboard/page.tsx
• src/app/compare/[a]/[b]/page.tsx
• src/lib/leaderboard.ts
Main entry points: stats-service.ts Stats service · auth.ts Auth & sessions · page.tsx Landing & profile pages · fetcher.ts GitHub history fetcher
Components 22
App routes & UI
- Root application shell
src/app/layout.tsx - Landing & profile pages · Search and shareable username profiles.
src/app/page.tsx - Account view
src/app/account/page.tsx - Leaderboard & comparison
src/app/leaderboard/page.tsx - Character UI components
src/components/CharacterCard.tsx - Stats API
src/app/api/stats/[username]/route.ts - Current-user API
src/app/api/me/route.ts - Share image & badge APIs
src/app/api/og/[username]/route.tsx - OAuth route
src/app/api/auth/[...nextauth]/route.ts - Preferences API
src/app/api/prefs/route.ts - Pricing page
src/app/pricing/page.tsx
Application services
- Stats service · Applies cache and selects public or OAuth GitHub access.
src/lib/stats-service.ts - RPG engine · Computes XP, level, class, skills, and achievements.
src/lib/rpg/engine.ts - Stats cache · Six-hour shared Redis cache with in-memory fallback.
src/lib/cache.ts - Leaderboard service
src/lib/leaderboard.ts - Auth & sessions
src/lib/auth.ts - Preferences service
src/lib/prefs.ts - Subscriptions service
src/lib/subscriptions.ts
External boundaries
- GitHub history fetcher · Parallelizes one-year contribution queries into all-time activity.
src/lib/github/fetcher.ts - GitHub GraphQL queries
src/lib/github/queries.ts - GitHub GraphQL & OAuth · Source of contribution, repository, profile, and OAuth token data.
- Upstash Redis
Connections 21
- Root application shell → Landing & profile pages
- Landing & profile pages → Character UI components: renders
- Landing & profile pages → Stats service: loads profile
- Account view → Stats service: loads private stats
- Account view → Auth & sessions: reads session
- Leaderboard & comparison → Leaderboard service: uses
- Leaderboard service → Stats service: uses profiles
- Stats API → Stats service: exposes
- Current-user API → Stats service: exposes
- Current-user API → Auth & sessions: requires session
- Share image & badge APIs → Stats service: reuses character data
- Stats service → Stats cache: reads and writes
- Stats cache → Upstash Redis: when configured
- Stats service → GitHub history fetcher: cache miss
- GitHub history fetcher → GitHub GraphQL queries: executes
- GitHub history fetcher → GitHub GraphQL & OAuth: GraphQL requests
- Stats service → RPG engine: turns activity into character
- OAuth route → Auth & sessions: serves
- Auth & sessions → GitHub GraphQL & OAuth: GitHub OAuth
- Preferences API → Preferences service: manages
- Pricing page → Subscriptions service: uses