How kirniy/coinmania works
Project type and purpose
• This is a full-stack React/TypeScript web application built on Next.js (App Router).
• It serves both a browser-rendered UI (pages under src/app and components) and a backend API (Route Handlers under src/app/api).
• It uses Supabase as its database/auth service, Redux for client state, and custom contexts/hooks for UI logic.
File structure
• Top-level config: next.config.mjs, tsconfig.json, tailwind.config.ts, postcss.config.mjs
• Public assets in public/ (images, static files)
• App entry in src/app/: layout.tsx, page.tsx, nested routes (bonus, game, profile, stub)
• API routes in src/app/api/* (auth, user, tasks, slot, util, etc.), each with its own route.ts
• UI components in src/components/ (common widgets, modal, popup, screens subfolders)
• Styling: global SCSS (globals.scss), CSS Modules next to components
• State: Redux slices in src/store/, contexts in src/app/context/
• Data layer: supabase client in src/db/supabase.ts
• Helpers and utils under src/helpers/ and src/utils/
• Type definitions in src/types/ and global.d.ts
README
• Confirms Next.js App Router setup, next/font usage, Vercel deployment.
• No custom microservices or external APIs beyond Supabase.
Main components & interactions
A. Browser (Client)
• Renders pages via Next.js (SSR/SSG or client-side)
• Loads React components, CSS, JS bundles
• Interacts with Next.js API endpoints and the Redux store/context
B. Next.js Application (Server & Build)
1. App Router (UI Layer)
– src/app/layout.tsx, nested page.tsx files
– global providers (Redux <Provider>, custom contexts)
– dynamic/static rendering, ISR paths if any
2. API Layer (Backend)
– src/app/api/**/*/route.ts
– Organized by domain (auth, user, tasks, slot, util, etc.)
– Handles HTTP requests, validates, applies business logic
3. Data Access
– supabase client in src/db/supabase.ts
– Queries/Mutations to Supabase (Postgres)
4. Build & Dev Tooling
– next.config.mjs for routing, env vars, custom webpack
– tailwind.config.ts + postcss.config.mjs for styling
– Typescript config
C. External Services
• Supabase (Database + Auth)
• Vercel (Hosting & CDN)
Relationships & data flow
• Clients request pages → Next.js App Router serves pre-rendered or dynamically rendered pages with data fetched from Supabase.
• Client-side hydration kicks in → React takes over, uses Redux store or contexts to manage in-app state.
• Components invoke API Layer endpoints (fetch/axios) → Next.js Route Handlers process requests, read/write Supabase, return JSON.
• API responses update Redux store or local state, UI updates.
Architectural patterns & design principles
• Monolithic full-stack framework leveraging Next.js App Router (file-system routing).
• Domain-partitioned API routes (grouped by feature).
• Separation of concerns:
• UI components under src/components and screens
• State management in Redux slices & React contexts
• Data logic centralized in supabase client
• Type safety end-to-end with TypeScript
Essential architectural elements
• Do not overcomplicate with every small helper or util—group them under “Helpers/Utils” if needed.
• Split between frontend (App Router + Components) and backend (API routes).
• Middleware of Redux/context providers as part of the UI Layer.
• That Supabase is both DB and Auth provider.
• If desired, annotate that assets and static files are served from public/ via Vercel CDN.