How yapp-github/25th-web-team-2-fe works
Project Type and Purpose
• This is a full-stack Next.js (v14) web application, written in TypeScript, which connects two user groups: researchers (who post experiments) and participants (who sign up).
• It uses Next.js App Router under /src/app for page rendering and server‐side API routes (e.g., /app/api/auth/[...nextauth]/route.ts).
File Structure
• Top-level directories:
• /src/app – Next.js pages and serverless API routes
• /src/apis – client‐side wrappers for calling your own API endpoints
• /src/components, /src/hooks, /src/providers, /src/lib – shared UI and utility modules
• /src/middleware – request middleware for auth, feature-flags, etc.
• /mocks – MSW setup for local development and testing
• Configuration files: next.config.mjs, .eslintrc.json, tsconfig.json, GitHub Actions workflows.
Main System Components
a. Frontend Client (Browser)
• Renders React UI via Next.js (Server-Side Rendering & Client-Side Navigation)
• Uses TanStack Query for data fetching, React Hook Form & Zod for forms/validation
• Interacts with /app/api/* routes and external auth providers
b. Next.js Server (Node.js)
• Serves pages and static assets (from /public)
• Implements API routes under /app/api/auth for NextAuth, plus any other custom endpoints
• Applies middleware (/middleware.ts) for authentication/session checks
c. Authentication Layer
• NextAuth integration for email, Google, Naver logins
• Session management (JWT or DB adapter)
d. Data Storage
• Although not shown in code, assume a persistent database (e.g., PostgreSQL) used by NextAuth and your API routes to store users, posts, experiments
e. External Services
• Email service to send recruitment emails
• OAuth providers (Google, Naver) for authentication
• Analytics (Mixpanel)
f. Mock Service Worker (MSW)
• Intercepts network calls in development/testing to simulate API responses (/mocks/*)
Component Interactions & Data Flow
• User’s Browser → Next.js Server: requests pages/routes via HTTP(S)
• Next.js Server → Database/External APIs:
• On page load or form submit, server‐side functions query DB or call 3rd-party services
• NextAuth handlers call OAuth endpoints or DB to validate sessions
• Browser → Client API Wrappers (/src/apis/*) → Next.js API routes for data mutations and queries
• TanStack Query caches these responses client-side for a fast, reactive UI
Architectural Patterns & Principles
• App Router: file-based routing for pages and API endpoints
• Separation of concerns:
• UI components under /components vs. page-specific components under /src/app
• Logic hooks under /src/hooks vs. data-access wrappers in /src/apis
• MSW for isolating front-end dev/testing from real backend
• Data fetching pattern: React Query → hooks → API wrappers → server routes
• App Router (/src/app)
• API Routes (/app/api)
• Middleware (/middleware.ts)
• Database (e.g., User, Post tables)
• OAuth Providers (Google, Naver)
• Email Service
• Analytics (Mixpanel)
5) MSW under the client as a dev/testing stub.