# modern-agile-team/8term-coko-front architecture

> Architecture diagram of the GitHub repository modern-agile-team/8term-coko-front, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/modern-agile-team/8term-coko-front
- Repository: https://github.com/modern-agile-team/8term-coko-front

## Overview

##### Main Components
- Frontend Application Shell: This includes the entry point (main.tsx), the router configuration (src/route/Router.tsx), and the global styles (src/style).
- Feature Modules: The project is organized into clear “features” directories (auth, error, intro, learn, profile, progress, quest, quiz, ranking, store, and user). Each feature typically contains submodules like APIs, queries/services, UI components, hooks, and types.
- Shared/Common Components: The common layout and UI components under src/common, such as Header, MenuBar, Modal, Loader, and others that are reused across pages.
- API & State Management: Components responsible for network communication (using Axios defined in src/axios) and data fetching/caching (via @tanstack/react-query). Additionally, state management is handled with Zustand, with store-related code found in src/store.
- Routing & Page Layouts: The pages directory contains distinct pages (login, intro, quest, quiz, ranking, store, etc.) that are tied together via the router.
- Build & Configuration: The configuration files (Vite config, Dockerfile, GitHub actions, ESLint, Prettier, tsconfig files) that give insight into the build pipeline and development environment.

##### Relationships and Interactions
- Flow from the Application Shell to Page Components:
- The App (src/App.tsx) integrates the Router (src/route/Router.tsx), which then loads various pages (inside src/pages) based on user navigation.
- Within Each Page, Demonstrate the Composition:
- Data Fetching and State Management:
- From the UI components, show calls to the API layer (using the Axios instance and specific API functions placed in the features’ apis.ts files).
- Shared Utilities and Common Components:
- Components from various features to common UI elements and utility functions (under src/common and src/utils).

##### Architectural Patterns and Design Principles
- Modular Feature-Based Structure:
- The clear separation of functionality into “features” folders follows a domain-driven design which makes it easy to spot where functionality lives and how it is organized.
- Separation of Concerns:
- Distinct directories for API calls, UI components, hooks, and even style-related files under each feature demonstrate clear layering.
- Client-Side Routing:
- The use of React Router (as seen in src/route) shows that the application is structured around different views/pages that interact via navigation logic.
- State Management:
- The combination of React Query (for server state) and Zustand (for local/global state) emphasizes a deliberate split between asynchronous data retrieval and app-level state management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Shell
    subgraph "Application Shell"
        A1["Entry Point: src/main.tsx"]:::appShell
        A2["Bootstrap: src/App.tsx"]:::appShell
        R["Router: src/route/Router.tsx"]:::appShell
        GS["Global Styles: src/style"]:::appShell
    end

    A1 --> A2
    A2 --> R
    GS -.-> A2

    %% Pages
    subgraph "Pages"
        P["Page Components: src/pages"]:::pages
    end

    R --> P

    %% Feature Modules
    subgraph "Feature Modules"
        F1["Auth Feature: src/features/auth"]:::feature
        F2["Error Feature: src/features/error"]:::feature
        F3["Intro Feature: src/features/intro"]:::feature
        F4["Learn Feature: src/features/learn"]:::feature
        F5["Profile Feature: src/features/profile"]:::feature
        F6["Progress Feature: src/features/progress"]:::feature
        F7["Quest Feature: src/features/quest"]:::feature
        F8["Quiz Feature: src/features/quiz"]:::feature
        F9["Ranking Feature: src/features/ranking"]:::feature
        F10["Store Feature: src/features/store"]:::feature
        F11["User Feature: src/features/user"]:::feature
    end

    %% Connect Pages to each Feature Module
    P --> F1
    P --> F2
    P --> F3
    P --> F4
    P --> F5
    P --> F6
    P --> F7
    P --> F8
    P --> F9
    P --> F10
    P --> F11

    %% API & State Management and Common Components
    subgraph "API & State Management"
        API["API Layer: src/axios"]:::api
        SM["State Mgmt: src/store"]:::state
        RQ["React Query (used in features)"]:::state
    end

    subgraph "Shared / Common Components"
        C["Common Components: src/common"]:::common
    end

    %% External Backend
    subgraph "External & Backend"
        BE["Backend API (External)"]:::external
    end

    %% Build & Configuration
    subgraph "Build & Configuration"
        VITE["Vite Config: vite.config.ts"]:::build
        DOCKER["Dockerfile"]:::build
        GITHUB["CI/CD: .github"]:::build
    end

    %% Connections from Feature Modules to API & State Management and Common Components (Representative)
    F1 -->|"calls"| API
    F1 -->|"updates_state"| SM
    F1 -->|"fetches_data"| RQ
    F1 -->|"uses_common_UI"| C
    F8 -->|"uses_common_UI"| C

    %% Connection from API Layer to External Backend
    API -->|"communicates_to"| BE

    %% Build & Config influences Application Shell
    VITE -->|"builds"| A1
    DOCKER -->|"containerizes"| A2
    GITHUB -->|"CI/CD"| A1

    %% Click Events
    click A1 "https://github.com/modern-agile-team/8term-coko-front/blob/develop/src/main.tsx"
    click A2 "https://github.com/modern-agile-team/8term-coko-front/blob/develop/src/App.tsx"
    click R "https://github.com/modern-agile-team/8term-coko-front/blob/develop/src/route/Router.tsx"
    click GS "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/style"
    click P "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/pages"
    click F1 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/auth"
    click F2 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/error"
    click F3 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/intro"
    click F4 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/learn"
    click F5 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/profile"
    click F6 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/progress"
    click F7 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/quest"
    click F8 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/quiz"
    click F9 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/ranking"
    click F10 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/store"
    click F11 "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/features/user"
    click C "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/common"
    click API "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/axios"
    click SM "https://github.com/modern-agile-team/8term-coko-front/tree/develop/src/store"
    click VITE "https://github.com/modern-agile-team/8term-coko-front/blob/develop/vite.config.ts"
    click DOCKER "https://github.com/modern-agile-team/8term-coko-front/tree/develop/Dockerfile"
    click GITHUB "https://github.com/modern-agile-team/8term-coko-front/blob/develop/.github"

    %% Class Definitions for Colors
    classDef appShell fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef pages fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef feature fill:#fad7a0,stroke:#333,stroke-width:2px;
    classDef common fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef api fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef state fill:#d2b4de,stroke:#333,stroke-width:2px;
    classDef external fill:#c39bd3,stroke:#333,stroke-width:2px;
    classDef build fill:#a9cce3,stroke:#333,stroke-width:2px;
```
