# paratrip/client architecture

> Architecture diagram of the GitHub repository paratrip/client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paratrip/client
- Repository: https://github.com/paratrip/client

## Overview

##### Project type and purpose
- This is a frontend-only single-page application (SPA) built with React, TypeScript, and Vite.
- It provides a travel/discovery platform with pages for home (locations, popular items, detail views), community (posts, popularity, write), tour courses (list, detail, navigation), authentication flows (login, sign-up, account recovery), and a user “My Page.”
- It uses CSS modules for styling, React Query for data-fetching, a small global store for local state, and integrates third-party services (e.g., Kakao login).

##### File structure
- Top level:
– public, src, dist, configuration (tsconfig, vite.config.ts, .eslintrc.js, netlify.toml).
– package.json defines dependencies and scripts.
- src/ directory modularized by concern:
– components/: reusable UI pieces (atoms, molecules, organism) and feature-specific groups (auth, home, community, tour-course).
– pages/: route-level views matching URL paths.
– routes/: routing configuration (path definitions + Router setup).
– services/: React Query hooks and adapters to fetch from backend/external APIs.
– store/: small Zustand/Recoil-like stores for session tokens, modal flags, community board state, etc.
– hooks/: custom React hooks for data fetching, mutation, validation, modal control, Kakao loader, etc.
– utils/: helpers, constants, endpoint definitions, validation, reducers.
- dist/: automated build output ready for Netlify deployment.

##### README
- States this is a minimal React + TypeScript + Vite template with ESLint and HMR configured.

1. Developer & Vite CLI
2. Vite Dev Server / Build Process
3. Browser / Client Runtime
4. React Application
– Router Layer (routes/routes.tsx + path configs)
– Page Components (src/pages/)
– Feature Components (src/components/)
– UI Library (src/components/ui/)
– Styling (CSS Modules)
– State Management (src/store/)
– Data Fetch Layer (src/services/react-query + src/hooks/useFetch, useMutate)
– Utilities & Helpers (src/utils/)
5. External Services
– REST/GraphQL backend API (endpoints in src/utils/endpoint)
– Third-party Auth (Kakao)
6. Hosting / CDN (Netlify serving dist/)

- Development flow:
Developer → Vite CLI → Vite Dev Server → Browser (HMR)
- Build/deploy flow:
Developer → Vite CLI (build) → dist/ → Netlify → CDN → Browser
- Runtime data flow:
Browser → React App → Router → Page → Component → Hook/Service → External API → Service returns data → React Query updates cache → Store updates (if any) → Component re-render → Browser
- State flow:
Component ↔ Store (read/write)
Component → Utils/Reducers → Local state updates
- Auth flow:
Component → Kakao SDK → OAuth redirect → Token → Store → ProtectedRoute wrapper grants access

c. Architectural patterns & principles:
- Component-based (atomic + composite pattern)
- Container (pages) vs Presentational components (ui/*)
- Hooks for side effects and data fetching (custom hooks)
- Centralized data caching and synchronization via React Query
- Small global stores for ephemeral UI state and session tokens
- CSS Modules for scoped styling
- Code-splitting by route (implicit via Vite and dynamic imports if used)

d. Key technologies & frameworks:
- React 18 + TypeScript
- Vite (dev server, build)
- React Router or custom routing (routes/routes.tsx)
- React Query for async data
- Zustand (or similar) for store
- CSS Modules
- Netlify for hosting
- ESLint / Prettier for code quality
- Kakao JS SDK for OAuth login

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Tooling & Deployment
    subgraph "Tooling & Deployment" 
        Developer["Developer"]:::tool
        ViteCLI["Vite CLI"]:::tool
        ViteDev["Vite Dev Server"]:::tool
        Dist["dist/ (Build Output)"]:::tool
        Netlify["Netlify"]:::tool
        CDN["CDN"]:::tool
    end

    Developer -->|dev & build| ViteCLI
    ViteCLI -->|dev server| ViteDev
    ViteDev -->|HMR| Browser
    ViteCLI -->|build| Dist
    Dist -->|deploy| Netlify
    Netlify --> CDN
    CDN --> Browser

    %% Client App
    subgraph "Client App (React + TS)" 
        ReactApp["React Application"]:::client

        subgraph "Entry & Styles"
            Main["main.tsx"]:::client
            App["App.tsx & App.css"]:::client
            IndexCSS["index.css"]:::client
        end

        subgraph "Routing Layer"
            Router["Router Layer"]:::client
            PathDefs["Path Definitions"]:::client
        end

        subgraph "Presentation & UI"
            Pages["Pages (Route Views)"]:::ui
            Components["Feature Components"]:::ui
            UILib["UI Library"]:::ui
        end

        subgraph "Styling"
            Styling["CSS Modules"]:::ui
        end

        subgraph "State Management"
            ModalStore["ModalStore"]:::store
            BoardStore["communityBoard"]:::store
            FindStore["find"]:::store
            TokenStore["login-token"]:::store
            SignupStore["sign-up"]:::store
        end

        subgraph "Data & Fetch Layer"
            Services["React Query Hooks & Adapters"]:::data
        end

        subgraph "Custom Hooks"
            useFetch["useFetch"]:::data
            useGet["useGet"]:::data
            useMutate["useMutate"]:::data
            useInvalidate["useInvalidateQueries"]:::data
            useKakaoLoader["useKaKaoLoader"]:::data
            useKakao["useKakao"]:::data
            KakaoPage["Kakao Login Page"]:::data
        end

        subgraph "Utilities & Helpers"
            Endpoints["Endpoints"]:::util
            Constants["Constants"]:::util
            Helpers["Helper Functions"]:::util
            AuthReducer["auth-reducer"]:::util
            TermsReducer["terms-reducer"]:::util
            Validation["Validation"]:::util
        end
    end

    Browser --> ReactApp
    ReactApp --> Main
    ReactApp --> App
    ReactApp --> IndexCSS
    ReactApp --> Router
    Router --> PathDefs
    Router --> Pages
    Pages --> Components
    Components --> UILib
    Components --> Styling
    Components <--> ModalStore
    Components <--> BoardStore
    Components <--> FindStore
    Components <--> TokenStore
    Components <--> SignupStore
    Components --> useFetch
    Components --> useGet
    Components --> useMutate
    Components --> useInvalidate
    useFetch --> Services
    useGet --> Services
    useMutate --> Services
    useInvalidate --> Services
    useKakaoLoader --> KakaoSDK
    useKakao --> KakaoSDK
    KakaoPage --> useKakaoLoader
    KakaoPage --> useKakao
    Components --> KakaoPage
    Components --> Endpoints
    Components --> Constants
    Components --> Helpers
    Components --> AuthReducer
    Components --> TermsReducer
    Components --> Validation
    Services --> ExternalAPI
    ExternalAPI --> Services
    Services --> ReactApp

    %% External Dependencies
    subgraph "External Dependencies"
        ExternalAPI["Backend REST/GraphQL API"]:::ext
        KakaoSDK["Kakao JS SDK (OAuth)"]:::ext
    end

    %% Click Events
    click Router "https://github.com/paratrip/client/blob/main/src/routes/routes.tsx"
    click PathDefs "https://github.com/paratrip/client/blob/main/src/routes/path/index.ts"
    click Pages "https://github.com/paratrip/client/tree/main/src/pages/"
    click Components "https://github.com/paratrip/client/tree/main/src/components/"
    click UILib "https://github.com/paratrip/client/tree/main/src/components/ui/"
    click ModalStore "https://github.com/paratrip/client/blob/main/src/store/ModalStore.ts"
    click BoardStore "https://github.com/paratrip/client/blob/main/src/store/communityBoard.ts"
    click FindStore "https://github.com/paratrip/client/blob/main/src/store/find.ts"
    click TokenStore "https://github.com/paratrip/client/blob/main/src/store/login-token.ts"
    click SignupStore "https://github.com/paratrip/client/blob/main/src/store/sign-up.ts"
    click Services "https://github.com/paratrip/client/blob/main/src/services/react-query/index.tsx"
    click useFetch "https://github.com/paratrip/client/blob/main/src/hooks/useFetch.tsx"
    click useGet "https://github.com/paratrip/client/blob/main/src/hooks/useGet.tsx"
    click useMutate "https://github.com/paratrip/client/blob/main/src/hooks/useMutate.tsx"
    click useInvalidate "https://github.com/paratrip/client/blob/main/src/hooks/useInvalidateQueries.tsx"
    click useKakaoLoader "https://github.com/paratrip/client/blob/main/src/hooks/useKaKaoLoader.tsx"
    click useKakao "https://github.com/paratrip/client/blob/main/src/hooks/useKakao.ts"
    click KakaoPage "https://github.com/paratrip/client/blob/main/src/pages/kakao-login/kakao-login.tsx"
    click Endpoints "https://github.com/paratrip/client/blob/main/src/utils/endpoint/endpoint.ts"
    click Constants "https://github.com/paratrip/client/tree/main/src/utils/constants/"
    click Helpers "https://github.com/paratrip/client/tree/main/src/utils/helpers/"
    click AuthReducer "https://github.com/paratrip/client/blob/main/src/utils/reducer/auth-reducer.tsx"
    click TermsReducer "https://github.com/paratrip/client/blob/main/src/utils/reducer/terms-reducer.tsx"
    click Validation "https://github.com/paratrip/client/blob/main/src/utils/validation.ts"
    click Main "https://github.com/paratrip/client/blob/main/src/main.tsx"

    %% Styles
    classDef tool fill:#FFEB3B,stroke:#333,stroke-width:1px;
    classDef client fill:#BBDEFB,stroke:#333,stroke-width:1px;
    classDef ui fill:#C8E6C9,stroke:#333,stroke-width:1px;
    classDef data fill:#DCEDC8,stroke:#333,stroke-width:1px;
    classDef store fill:#F8BBD0,stroke:#333,stroke-width:1px;
    classDef util fill:#FFE0B2,stroke:#333,stroke-width:1px;
    classDef ext fill:#FFCDD2,stroke:#333,stroke-width:1px;
```
