How amfoss/home works
Project Type and Purpose
• This is a full-stack React application built with Next.js (App Router).
• It provides authentication (login/logout), a member dashboard with attendance tracking, coding-problem leaderboards, and profile pages.
• It uses Apollo Client for GraphQL queries/mutations and Tailwind CSS for styling.
Main Components
a. Client (Browser)
• Renders React pages/components.
• Initiates navigation and GraphQL queries/mutations via Apollo Client.
b. Next.js Server
• Handles server-side rendering (SSR) and routing (src/app).
• Serves static assets (public/) and CSS.
• Hosts API routes or GraphQL proxy if implemented in Next.js.
c. Apollo Client Layer (src/lib/apollo-client.ts + ProviderApollo)
• Wraps the app to provide GraphQL data fetching capabilities.
d. UI Components (src/components/)
• Calendar, Card, LeaderboardTable, Sidebar, etc.
• AttendanceDetails nested under attendance-track.
e. Context Providers (src/context/)
• SelectedButtonContext: manages UI state.
• ProviderApollo: injects Apollo Client into React tree.
f. Services / Data Layer (src/services/)
• attendance-service.ts: GraphQL/REST calls for attendance.
• streak-service.ts: calls to compute streaks.
g. External Systems
• Authentication backend (could be an OAuth/OpenID or custom API).
• GraphQL API Server (hosted separately or as Next.js API routes).
• Vercel (or Netlify) for deployment.
Relationships and Data Flow
1. Browser → Next.js Server
• User navigates to /login, /dashboard, etc.
• Next.js SSR returns HTML.
2. React Components → Apollo Client
• On page load or user action, components call Apollo Client.
3. Apollo Client → GraphQL API
• Queries/mutations travel over HTTP to the remote GraphQL endpoint.
4. GraphQL API → Database / Auth Service
• The backend resolves data, applies business logic, and returns responses.
5. Next.js Static Assets
• CSS from tailwind.config.ts, static images under public/, served directly.
Architectural Patterns and Principles
• Separation of concerns: UI components, context, data-services, and Apollo setup are modular.
• App Router (file-based routing) for page organization and dynamic routes ([memberId]).
• Context for cross-cutting state; Services for data access.
• Client-side caching and SSR for performance.
• Clear labels for each module and directory (e.g., “UI Components (src/components)”).
• Annotations for dynamic routing, context providers, and styling engine (Tailwind).