How devpalsplus/frontend works
Project Type and Purpose
• This is the frontend of a full-stack web application called *DevPals*.
• Built with React, TypeScript, Vite, Styled-Components, React Query, and Zustand, it serves as a Single-Page Application (SPA) that consumes a RESTful NestJS backend.
• Its purpose is to help junior developers discover, apply to, and manage side-project postings, while interacting with senior mentors and other community members.
File-Structure Analysis
• Top-level config & tooling: vite.config.ts, tsconfig.json, .github/workflows (CI/CD), Storybook config.
• public/: static assets and the mock Service Worker.
• src/:
• pages/: top-level routes (Home, Login, Apply, CreateProject, MyPage, etc.)
• components/: reusable UI blocks organized by feature (common, home, comment, m ypage, projectForm, etc.)
• api/: wrappers around HTTP calls (e.g., auth.api.ts, projectLists.api.ts)
• hooks/: custom hooks, divided into domain hooks (ProjectHooks, CommentHooks) and generic hooks (useAuth, useModal)
• store/: Zustand stores (e.g., authStore.ts)
• context/: React Context providers (ModalContext, ErrorBoundaryContext, SearchFilteringContext)
• routes/: routing config (AppRoutes.tsx)
• models/: TypeScript type definitions for API payloads and domain models
• constants/, util/, assets/, style/
• Mocks & tests: src/mock/ for MSW, setupTests.ts, vitest.d.ts, __tests__ under util.
Key Architecture & Interactions
a. UI Layer
• Pages: mounted by the router.
• Components: presentational and container components under components/.
b. Routing
• AppRoutes.tsx configures public and protected routes using React Router and ProtectRoute.
c. State Management
• Zustand (authStore) for global auth state.
• React Query for server state (queries and mutations via custom hooks).
d. Data-Fetching Layer
• api/ modules build HTTP requests to VITE_APP_API_BASE_URL.
• React Query Hooks wrap these APIs (useGetProjectData, usePostComment, etc.) and manage caching.
e. Context Providers
• ModalContext for global modal dialogs.
• ErrorBoundaryContext for error handling.
• SearchFilteringContext for filter state on the home page.
f. Styling
• Styled-Components used per component and per page.
g. Utilities & Models
• Helpers in util/ (date formatting, crypto utils).
• Domain types in models/.
h. External Services
• Backend API on AWS (NestJS + Prisma + MySQL).
• Image CDN (S3).
• CI/CD: GitHub Actions, deploying static to S3 via AWS CLI.
Architectural Patterns & Principles
• Component-Based UI: modularization by feature and reusability (common/ vs feature/).
• Separation of Concerns: distinct layers for UI, routing, state, data fetching, contexts.
• Single Source of Truth: central stores for auth & server data (Zustand + React Query).
• Provider Pattern: contexts wrapping the app for cross-cutting concerns (modal, error, filtering).
• API Abstraction: each domain API in its own module under api/.