# 2602hoang/client architecture

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

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

## Overview

##### Main Components

a) Client-Side (Frontend):
- User Interface (Components)
- Public Components (Header, Footer)
- User Components (Home, Product, Cart, Order)
- Admin Components (Dashboard, Management Panels)
- State Management (Context API - AuthContextProvider)
- Routing System (Protected Routes)

b) Server-Side (Backend):
- API Endpoints
- Authentication Services
- Business Logic Layer
- Data Access Layer

c) Database:
- Users
- Products
- Orders
- Cart

d) External Services:
- EmailJS Service
- Google Apps Script API
- PDF.js Service

##### Connection and Data Flow

- Frontend-Backend communication via REST API
- Backend-Database interactions
- Integration with external services

##### Specific Implementation Details

a) Frontend Architecture:
**React Frontend**
- Components Layer
- Layout Components
- User Components
- Admin Components
- Shared Components
- Routing Layer
- Protected Routes
- Public Routes
- Context Layer
- Auth Context
- Utils/Config Layer

b) Backend Architecture (to be referenced):
**Node.js/Express Backend**
- API Routes
- Controllers
- Services
- Models
- Database Interface

##### Important Elements to Highlight

- Authentication flow
- Protected route mechanism
- Order processing pipeline
- Admin dashboard data flow
- Statistics and reporting system

##### Deployment Architecture

A section showing:
- Vercel hosting for Frontend
- Vercel hosting for Backend
- Aiven MySQL database
- External service connections

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[User Interface]
        RC[React Components]
        SM[State Management]
        RS[Routing System]
        
        subgraph Components
            LC[Layout Components]:::layout
            PC[Public Components]:::public
            UC[User Components]:::user
            AC[Admin Components]:::admin
        end
        
        subgraph Auth
            ACP[Auth Context Provider]:::auth
            PR[Protected Routes]:::auth
        end
        
        UI --> RC
        RC --> Components
        RC --> Auth
    end
    
    subgraph Backend
        API[API Endpoints]:::backend
        AS[Authentication Services]:::backend
        BL[Business Logic]:::backend
        DAL[Data Access Layer]:::backend
    end
    
    subgraph Database
        DB[(MySQL Database)]:::database
        Users[(Users Table)]:::database
        Products[(Products Table)]:::database
        Orders[(Orders Table)]:::database
        Cart[(Cart Table)]:::database
        
        DB --> Users
        DB --> Products
        DB --> Orders
        DB --> Cart
    end
    
    subgraph "External Services"
        EJS[EmailJS Service]:::external
        GAS[Google Apps Script]:::external
        PDF[PDF.js Service]:::external
    end
    
    Frontend --> API
    API --> BL
    BL --> DAL
    DAL --> DB
    BL --> EJS
    BL --> GAS
    BL --> PDF
    
    %% Component Mappings
    click LC "https://github.com/2602hoang/client/blob/master/src/page/layout/Layout.js"
    click PC "https://github.com/2602hoang/client/blob/master/src/component/Header.js"
    click UC "https://github.com/2602hoang/client/tree/master/src/page/user"
    click AC "https://github.com/2602hoang/client/tree/master/src/page/admin"
    click ACP "https://github.com/2602hoang/client/blob/master/src/contexts/AuthContextProvider.js"
    click PR "https://github.com/2602hoang/client/blob/master/src/routing/ProtectedRoute.js"
    
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white
    classDef layout fill:#34495e,stroke:#2c3e50,color:white
    classDef public fill:#1abc9c,stroke:#16a085,color:white
    classDef user fill:#e67e22,stroke:#d35400,color:white
    classDef admin fill:#95a5a6,stroke:#7f8c8d,color:white
```
