# huy121003/fe-happyhunt-admin architecture

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

- Interactive diagram: https://gitdiagram.com/huy121003/fe-happyhunt-admin
- Repository: https://github.com/huy121003/fe-happyhunt-admin

## Overview

##### Project type and purpose
- This is a single‐page web application (SPA) built with React, TypeScript and Vite.
- It serves as an admin dashboard with dozens of feature modules (admins, users, posts, payments, statistics, etc.), each following a “feature → UI → service → data” pattern.
- It’s packaged as a Docker image, served by Nginx in production, and makes API calls to a remote back‐end.

##### File structure
- Top‐level infra: Dockerfile, docker-compose.yml, nginx.conf, .env, Vercel config.
- Bundler/config: vite.config.js, tsconfig*, tailwind.config.js, ESLint + Prettier.
- Public assets: public/, index.html.
- Source code under src/:
- main.tsx + App.tsx (entry + root component)
- routers/router.tsx (React Router definitions)
- redux/ (Redux Toolkit store & auth slice)
- libs/ (Axios, theming, query client setups)
- hooks/ + helpers/ (reusable logic & utilities)
- components/ (shared UI library & layout components)
- features/ (domain modules: each has components, hooks, data interfaces, service layer)
- pages/ (page components, split by public vs. private and by feature)

##### Key insights from README
- Uses Vite + HMR for dev experience
- ESLint recommended setup for type‐aware linting
- Two plugin options for React Fast Refresh (Babel or SWC)

##### Final advice
- Be exhaustive in labeling every major module (routers, pages, features, libs, hooks, state).
- Both the infra/build pipeline and the internal component/service layering.
- Keep it detailed—each feature cluster can be further exploded if needed—but start with the high-level boundaries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infra Layer
    subgraph "Infrastructure" 
        direction TB
        subgraph "Development"
            direction TB
            VITE["Vite Dev Server"]:::runtime
            VITE -->|"Serves SPA"| Browser
        end
        subgraph "Production"
            direction TB
            DOCKER["Docker Image"]:::infra
            NGINX["Nginx (Static Assets)"]:::server
            DOCKER -->|Contains| NGINX
            NGINX -->|Serves SPA| Browser
            click DOCKER "https://github.com/huy121003/fe-happyhunt-admin/tree/main/Dockerfile"
            click NGINX "https://github.com/huy121003/fe-happyhunt-admin/blob/main/nginx.conf"
        end
        CDN["CDN/Cache (Optional)"]:::infra
        CDN --> NGINX
    end

    %% Client Browser
    Browser["User Browser"]:::client

    %% Backend API
    API["External REST API"]:::api

    Browser -->|HTTP Requests| API

    %% Application Code
    subgraph "SPA Application" 
        direction TB
        subgraph "Entry & Router"
            direction TB
            MAIN["main.tsx"]:::entry
            APP["App.tsx"]:::entry
            ROUTER["router.tsx"]:::router
            MAIN --> APP
            APP --> ROUTER
            click MAIN "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/main.tsx"
            click APP "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/App.tsx"
            click ROUTER "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/routers/router.tsx"
        end

        subgraph "State Management"
            direction TB
            STORE["store.ts"]:::store
            AUTHS["SAuthSlice.ts"]:::slice
            HOOK["reduxHook.ts"]:::hook
            STORE --> AUTHS
            STORE --> HOOK
            click STORE "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/redux/store.ts"
            click AUTHS "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/redux/slice/SAuthSlice.ts"
            click HOOK "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/redux/reduxHook.ts"
        end

        subgraph "Service & Data Layer"
            direction TB
            AXIOS["axios.ts"]:::service
            QUERY["query.ts"]:::service
            THEME["theme.ts"]:::service
            AXIOS -->|"HTTP Client"| API
            QUERY -->|"Cache Client"| API
            click AXIOS "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/libs/axios.ts"
            click QUERY "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/libs/query.ts"
            click THEME "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/libs/theme.ts"
        end

        subgraph "Utilities"
            direction TB
            HELPERS["BuildMenuTree.ts"]:::util
            HOOKS["Hooks"]:::util
            click HELPERS "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/helpers/BuildMenuTree.ts"
            click HOOKS "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/hooks/**/*"
        end

        subgraph "UI Components"
            direction TB
            SHARED["Shared Components"]:::ui
            LAYOUTS["Layout Components"]:::ui
            click SHARED "https://github.com/huy121003/fe-happyhunt-admin/blob/main/src/components/index.ts"
            click LAYOUTS "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/components/layouts/**/*"
        end

        subgraph "Features"
            direction TB
            subgraph "Admins Module"
                A_UI["Admins UI"]:::feature
                A_SERVICE["Admins Service"]:::feature
            end
            subgraph "Users Module"
                U_UI["Users UI"]:::feature
                U_SERVICE["Users Service"]:::feature
            end
            subgraph "Posts Module"
                P_UI["Posts UI"]:::feature
                P_SERVICE["Posts Service"]:::feature
            end
            subgraph "Payments Module"
                PM_UI["Payments UI"]:::feature
                PM_SERVICE["Payments Service"]:::feature
            end
            subgraph "Statistics Modules"
                S_UI["Stats UI"]:::feature
                S_SERVICE["Stats Service"]:::feature
            end
            click A_UI "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/admins/components"
            click A_SERVICE "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/admins/service"
            click U_UI "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/users/components"
            click U_SERVICE "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/users/service"
            click P_UI "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/posts/components"
            click P_SERVICE "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/posts/service"
            click PM_UI "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/payments/components"
            click PM_SERVICE "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/payments/service"
            click S_UI "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/payment-statistics/**"
            click S_SERVICE "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/features/payment-statistics/**"
        end

        subgraph "Pages"
            direction TB
            PUBLIC["Public Pages"]:::page
            PRIVATE["Private Pages"]:::page
            click PUBLIC "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/pages/public/**/*"
            click PRIVATE "https://github.com/huy121003/fe-happyhunt-admin/tree/main/src/pages/private/**/*"
        end

        %% Data flow
        ROUTER --> PUBLIC
        ROUTER --> PRIVATE
        PUBLIC --> SHARED
        PRIVATE --> SHARED
        PRIVATE --> LAYOUTS
        SHARED --> STORE
        LAYOUTS --> STORE
        SHARED --> AXIOS
        SHARED --> QUERY
        PUBLIC -->|UI Render| HELPERs
        PRIVATE -->|UI Render| HELPERs
        SHARED -->|"UI Calls"| AXIOS
        SHARED -->|"UI Calls"| QUERY
        AXIOS --> STORE
        QUERY --> STORE
        STORE --> SHARED
    end

    %% Build & Config
    subgraph "Configs & Build"
        direction TB
        BUNDLER["vite.config.js"]:::config
        TS["tsconfig*.json"]:::config
        STYLE["tailwind.config.js"]:::config
        LINT["eslint.config.js"]:::config
        ENV[".env/.env.example"]:::config
        VERCEL["vercel.json"]:::config
        DOCKERFILE["docker-compose.yml"]:::config
        click BUNDLER "https://github.com/huy121003/fe-happyhunt-admin/blob/main/vite.config.js"
        click TS "https://github.com/huy121003/fe-happyhunt-admin/blob/main/tsconfig.json"
        click STYLE "https://github.com/huy121003/fe-happyhunt-admin/blob/main/tailwind.config.js"
        click LINT "https://github.com/huy121003/fe-happyhunt-admin/blob/main/eslint.config.js"
        click ENV "https://github.com/huy121003/fe-happyhunt-admin/blob/main/.env"
        click VERCEL "https://github.com/huy121003/fe-happyhunt-admin/blob/main/vercel.json"
        click DOCKERFILE "https://github.com/huy121003/fe-happyhunt-admin/blob/main/docker-compose.yml"
    end

    %% Public Assets
    PUBLICASSETS["public/ + index.html"]:::asset
    click PUBLICASSETS "https://github.com/huy121003/fe-happyhunt-admin/tree/main/public/"
    PUBLICASSETS --> VITE
    PUBLICASSETS --> NGINX

    %% Legend
    classDef runtime fill:#f9f,stroke:#333,stroke-width:1px
    classDef infra fill:#fcc,stroke:#333,stroke-width:1px
    classDef server fill:#fc9,stroke:#333,stroke-width:1px
    classDef client fill:#9cf,stroke:#333,stroke-width:1px
    classDef api fill:#cfc,stroke:#333,stroke-width:1px
    classDef entry fill:#cff,stroke:#333,stroke-width:1px
    classDef router fill:#c9f,stroke:#333,stroke-width:1px
    classDef store fill:#ff9,stroke:#333,stroke-width:1px
    classDef slice fill:#ffb,stroke:#333,stroke-width:1px
    classDef hook fill:#fbf,stroke:#333,stroke-width:1px
    classDef service fill:#9f9,stroke:#333,stroke-width:1px
    classDef util fill:#ccf,stroke:#333,stroke-width:1px
    classDef ui fill:#fdd,stroke:#333,stroke-width:1px
    classDef feature fill:#dfd,stroke:#333,stroke-width:1px
    classDef page fill:#ddf,stroke:#333,stroke-width:1px
    classDef config fill:#eee,stroke:#333,stroke-width:1px
    classDef asset fill:#eef,stroke:#333,stroke-width:1px
```
