# minhtan0804/foos-store-fe architecture

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

- Interactive diagram: https://gitdiagram.com/minhtan0804/foos-store-fe
- Repository: https://github.com/minhtan0804/foos-store-fe

## Overview

##### Project type and purpose
- This is a single-page application (SPA) built with React, TypeScript, and Vite.
- It serves as the front-end of an e-commerce & content management system, with both public store pages (home, products, cart, payment, blogs, reviews) and an admin console (product, order, user, review, article, addon management).
- It communicates via RESTful APIs (src/apis) to a back-end service and is deployed as a static site behind Nginx in Docker.

##### File structure
- Top level:
- Dockerfile + .nginx/nginx.conf → containerized static server
- .github/workflows/ci-cd.yml → CI/CD pipeline
- .env/.env.example → environment variables for API endpoints, feature flags, etc.
- vite.config.ts, tsconfig.json → build and TypeScript setup
- src/apis: type-safe axios wrappers for each resource (auth, product, order, cart, etc.)
- src/lib/react-query & src/lib/axios: shared HTTP client and query client
- src/pages + src/routes: React Router-driven page modules (public vs protected/admin)
- src/components + src/layout: reusable UI pieces and page layouts
- src/store + react-query: client-side state management and server cache
- config, constants, helper, hooks, i18n, assets, styles: cross-cutting concerns

##### README
- Standard React+TS+Vite template with HMR and ESLint.

##### Elements
- Labels: “Browser”, “React App”, “API Layer”, “E-commerce API Service”, “Database”, “File Storage”, “Payment Gateway”, “CI/CD Pipeline”, “Docker & Nginx”.
- Build → Container → Deployment
- Browser → Nginx → React App → API Layer → Back-end
- API calls → Database/File/Payment Gateway
- Rectangles for applications/components

##### Final advice
- Be very granular: split your front-end into UI, state management, API, build/deploy.
- Both happy-path (data fetch) and auth-flow (login → token storage → protected routes).
- Full lifecycle: code commit → CI → build → deployment → runtime in browser → API interactions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer Environment
    subgraph "Developer Environment" 
        direction TB
        ViteDev["Vite Dev Server"]:::infra
        IDE["Local IDE"]:::external
    end

    click ViteDev "https://github.com/minhtan0804/foos-store-fe/blob/main/vite.config.ts"

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        direction TB
        GitHubActions["GitHub Actions"]:::infra
    end

    click GitHubActions "https://github.com/minhtan0804/foos-store-fe/blob/main/.github/workflows/ci-cd.yml"

    %% Container & Static Server
    subgraph "Container & Static Server"
        direction TB
        Docker["Docker Image"]:::infra
        Nginx["Nginx Server"]:::infra
        EnvVars["Environment Variables"]:::infra
    end

    click Docker "https://github.com/minhtan0804/foos-store-fe/tree/main/Dockerfile"
    click Nginx "https://github.com/minhtan0804/foos-store-fe/blob/main/.nginx/nginx.conf"
    click EnvVars "https://github.com/minhtan0804/foos-store-fe/blob/main/.env"

    %% Browser & App Entry
    subgraph "Browser (User Agent)"
        direction TB
        IndexHTML["index.html"]:::frontend
        MainTSX["main.tsx"]:::frontend
    end

    click IndexHTML "https://github.com/minhtan0804/foos-store-fe/blob/main/index.html"
    click MainTSX "https://github.com/minhtan0804/foos-store-fe/blob/main/src/main.tsx"

    %% Routing Layer
    subgraph "Routing Layer" 
        direction TB
        Router["Router"]:::frontend
        PublicRoutes["Public Routes"]:::frontend
        ProtectedRoutes["Protected/Admin Routes"]:::frontend
    end

    click Router "https://github.com/minhtan0804/foos-store-fe/blob/main/src/routes/router.tsx"
    click PublicRoutes "https://github.com/minhtan0804/foos-store-fe/blob/main/src/routes/public.tsx"
    click ProtectedRoutes "https://github.com/minhtan0804/foos-store-fe/blob/main/src/routes/protected.tsx"

    %% Front-end Application Layers
    subgraph "Front-end Application" 
        direction TB
        subgraph "Presentation Layer"
            direction TB
            Components["Components & Layouts"]:::frontend
            Pages["Pages (Home, Product, Cart, etc.)"]:::frontend
        end
        subgraph "State & Data Layer"
            direction TB
            ReactQuery["React Query Client"]:::frontend
            Store["Client Store"]:::frontend
        end
        subgraph "API Layer"
            direction TB
            AxiosClients["Axios API Clients"]:::frontend
        end
        subgraph "Utilities & Cross-Cutting"
            direction TB
            Utils["Helpers, Config, i18n, Styles, Assets"]:::frontend
        end
    end

    click Components "https://github.com/minhtan0804/foos-store-fe/tree/main/src/components/"
    click ReactQuery "https://github.com/minhtan0804/foos-store-fe/blob/main/src/lib/react-query/index.ts"
    click AxiosClients "https://github.com/minhtan0804/foos-store-fe/blob/main/src/apis/index.ts"
    click Utils "https://github.com/minhtan0804/foos-store-fe/blob/main/src/config/index.ts"

    %% Backend Services
    subgraph "Back-end Services (External)" 
        direction TB
        ApiServer["E-commerce API Service"]:::external
        Database["Database"]:::external
        FileStorage["File Storage"]:::external
        PaymentGateway["Payment Gateway"]:::external
        ThirdParty["Third-party Services"]:::external
    end

    %% Edges
    ViteDev --> GitHubActions
    IDE --> ViteDev

    GitHubActions --> Docker
    Docker --> Nginx
    EnvVars --> Nginx

    Nginx --> IndexHTML
    IndexHTML --> MainTSX
    MainTSX --> Router
    Router --> PublicRoutes
    Router --> ProtectedRoutes

    PublicRoutes --> Pages
    ProtectedRoutes --> Pages

    Pages --> ReactQuery
    ReactQuery --> AxiosClients
    AxiosClients --> ApiServer

    ApiServer --> Database
    ApiServer --> FileStorage
    ApiServer --> PaymentGateway
    ApiServer --> ThirdParty

    classDef frontend fill:#e0ffe0,stroke:#0a0,stroke-width:1px
    classDef infra fill:#e0f0ff,stroke:#00a,stroke-width:1px
    classDef external fill:#ffe0c0,stroke:#a50,stroke-width:1px
```
