How tensho1026/gitrpg works
Project type and purpose
• Git-RPG is a full-stack Next.js application that gamifies GitHub commit activity.
• Frontend and backend live in the same Next.js “app” directory, using Server Actions for data mutations and queries.
• External services: GitHub GraphQL API for commit data, Supabase for persistence, NextAuth for authentication.
File structure
• Top‐level “src/app” holds Next.js routes and React UI components for pages (home, avatar, item, grass, battle, auth).
• “src/actions” contains business‐logic modules (server actions) grouped by domain: github, user, item.
• “src/lib” holds utility code (session store, leveling, common helpers).
• “src/supabase/supabase.config.ts” configures the Supabase client.
• “src/types” defines TypeScript types.
• Presence of NextAuth config, API routes under “src/app/api/auth/[...nextauth]” indicates a built‐in auth layer.
Main components
• Browser (React/Next.js client)
• Next.js server (Server Actions + API routes)
• Authentication service (NextAuth + session store)
• Supabase database
• GitHub GraphQL API
• CDN/public assets
Relationships and interactions
• The Browser sends page requests to Next.js.
• Next.js renders pages (SSR/SSG) and invokes Server Actions or API routes for data.
• Server Actions call:
• GitHub GraphQL API to fetch commit counts and history
• Supabase to read/write user profiles, coins, XP, avatars, items
• NextAuth manages OAuth handshakes with GitHub, stores sessions in Supabase (or in-memory store).
• The Browser fetches JSON via built-in fetch wrappers or React hooks (useHomeData, useAvatarData, etc.).
Architectural patterns and design principles
• Layered architecture: Presentation (React pages) → Application logic (Server Actions) → Data access (Supabase, GitHub API).
• Domain separation in “src/actions” by feature (user, item, github) follows a Clean Architecture approach.
• File-system-based routing in Next.js organizes UI and API side by side.
• Hooks in “src/app/*/hooks” encapsulate data fetching logic for components.
Detail but keep clarity
• Key components: individual pages (home, avatar, item, grass, battle), shared UI libs, feature‐specific actions, Supabase, GitHub API, NextAuth.
• How data flows end-to-end: from user action in UI through business logic to persistence and back.
• Architectural principles: separation of concerns, domain grouping, external integrations.