How cow-dev/ddingdong-fe works
Project type and purpose
• This is a full‑stack web application built with Next.js v13 (TypeScript).
• Its goal is to provide a unified “club platform” for students (public site) and club administrators (admin portal), consuming backend REST APIs for data.
Core components and layers
a. Client layer
• Web browsers (students & admins) interacting with the Next.js app.
• Next.js handles SSR/SSG, client‑side routing, and hydration.
b. Presentation layer (Next.js frontend)
• pages/…: Defines public routes (/, /club/[id], /apply/[id], /notice, etc.) and admin routes (/admin/**).
• components/: Reusable UI pieces (common, club, apply, feed, fixzone, report, score, modals, etc.).
• styles/, public/: Static assets, global CSS, JSON animations.
c. Application logic
• src/apis/index.ts: Centralized API client (fetch wrappers, presigned‑URL logic).
• src/hooks/api/*: Custom React hooks (e.g., useAllClubs, useNewReport) encapsulating fetch/mutation logic per resource.
• src/hooks/common: Utilities for modals, SSE subscriptions, form handling.
• src/store: Zustand stores for auth, club context, uploads.
• middleware.ts: Edge middleware for auth checks and route protection.
• next.config.js, tsconfig.json, PostCSS/Tailwind configs.
d. External services
• Backend REST API(s): /api/club, /api/apply, /api/feed, /api/document, /api/fixzone, etc.
• Sentry: Client/Server/Edge error monitoring (sentry.*.config.ts).
• Google Analytics: gtag integration (lib/gtag.ts).
• SSE endpoint (utils/subscribeToSSE.tsx) for real‑time updates (optional).
• Object storage (S3 or similar) via presigned URLs for file/image uploads.
e. Data persistence (not in repo)
• Backend databases (likely PostgreSQL/Mongo) behind the REST API.
• File storage for uploaded documents, images.
Relationships and data flow
1. User → Browser
2. Browser → Next.js App (SSR/CSR)
3. Next.js App → src/apis → fetch → Backend REST API
4. Backend → Database / Storage → Backend → Response → Next.js → Browser
5. Sentry and Analytics capture errors & metrics throughout
Architectural patterns & principles
• Component‑based architecture: Separation of concerns by domain (apply, club, feed, etc.).
• Hooks for data fetching: Encapsulate API details and caching strategies.
• Middleware for cross‑cutting concerns (auth guard, redirects).
• State management via lightweight stores (Zustand).
• Static assets & CDN: public/, Next.js static optimization.
• Error monitoring (Sentry) and analytics (gtag) integrated at multiple layers.