# 2602hoang/admin-nextjs architecture

> Architecture diagram of the GitHub repository 2602hoang/admin-nextjs, 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/admin-nextjs
- Repository: https://github.com/2602hoang/admin-nextjs

## Overview

##### High-Level Architecture Overview

a) Client Layer (Frontend):
- Admin Layout (for authenticated admin routes)
- Auth Layout (for login/signup)
- Shared Components
- Context Providers
- Query Client (React Query)

b) Server Layer (Backend):
- API Routes
- Authentication/Authorization Middleware

c) Data Layer:
- MySQL Database (hosted on Aiven)
- External Services (Google Apps Script API)

##### Detailed Component Breakdown

Frontend Components (organize in connected blocks):
- Admin Dashboard Layout
- Navigation Components
- Header Components
- Content Area with sub-sections:
> Home/Analytics
> Products
> Orders
> Sales Reports
> Messages
> User Management
> Settings
- Authentication Layout
- Login
- Signup

##### Data Flow Visualization

- Client-Server Communication:
- API Requests (Axios)
- Authentication Flow
- Data Fetching (React Query)
- State Management Flow:
- Context Providers
- Component-level State
- API State Management

##### Technical Stack Visualization

- UI Layer:
- Ant Design
- Tailwind CSS
- SASS
- Application Layer:
- TypeScript
- Next.js
- React Query
- Backend Layer:
- Node.js
- Express
- Database Layer:
- MySQL

##### Integration Points

External integrations:
- Vercel Deployment
- Aiven Database
- Google Apps Script API
- Authentication Services

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Frontend["Next.js Frontend"]
        AdminLayout["Admin Layout"]:::adminLayout
        AuthLayout["Auth Layout"]:::authLayout
        QueryClient["Query Client Provider"]:::queryClient
        AppProviders["Application Providers"]:::appProviders
        
        subgraph Layouts
            AdminLayout --> NavBar["Navigation"]:::navbar
            AdminLayout --> Header["Header"]:::header
            AdminLayout --> ContentArea["Content Area"]
            
            subgraph Content
                Home["Home/Analytics"]:::home
                Products["Products"]:::products
                Orders["Orders"]:::orders
                Sales["Sales Reports"]:::sales
                Messages["Messages"]:::messages
                Settings["Settings"]:::settings
            end
            
            ContentArea --> Content
        end
        
        subgraph Auth
            Login["Login"]:::auth
            Signup["Signup"]:::auth
            AuthLayout --> Login
            AuthLayout --> Signup
        end
        
        subgraph Providers
            AuthContext["Auth Context"]:::context
            ReportContext["Report Data Context"]:::context
            StateManagement["State Management"]:::state
        end
        
        subgraph UI
            AntDesign["Ant Design"]:::ui
            TailwindCSS["Tailwind CSS"]
            Charts["Data Visualization"]:::charts
        end
    end
    
    subgraph Server
        Backend["Node.js + Express"]
        AuthMiddleware["Authorization Middleware"]:::middleware
        APIRoutes["API Routes"]
        ErrorHandler["Error Handling"]:::error
        AxiosProvider["API Integration"]:::axios
    end
    
    subgraph Data
        MySQL[(MySQL Database)]
        GoogleAPI["Google Apps Script API"]
    end
    
    %% Connections
    Frontend --> Backend
    Backend --> MySQL
    Backend --> GoogleAPI
    AuthMiddleware --> APIRoutes
    ErrorHandler --> APIRoutes
    
    %% Styling
    classDef frontend fill:#a8d1ff
    classDef backend fill:#90EE90
    classDef database fill:#FFD700
    classDef external fill:#DDA0DD
    classDef context fill:#FFB6C1
    classDef ui fill:#98FB98
    classDef state fill:#87CEEB
    classDef error fill:#FF6B6B
    
    %% Click Events
    click AdminLayout "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/app/(adminLayout)/layout.tsx"
    click AuthLayout "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/app/(authLayout)/layout.tsx"
    click Login "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(authLayout)/login"
    click Signup "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(authLayout)/signup"
    click AuthContext "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/contexts/AuthContext.tsx"
    click ReportContext "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/contexts/ReportDataContext.tsx"
    click QueryClient "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/providers/QueryClientProvider.tsx"
    click AuthMiddleware "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/middleware/IsAdmin.tsx"
    click NavBar "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/components/navbar/NavBar.tsx"
    click Header "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/components/header/Header.tsx"
    click Home "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(adminLayout)/useLogicHome"
    click Products "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(adminLayout)/product"
    click Orders "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(adminLayout)/order"
    click Sales "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(adminLayout)/salereport"
    click Messages "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(adminLayout)/message"
    click Settings "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/app/(adminLayout)/setting"
    click Charts "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/components/charts/ComponentCharts.tsx"
    click AxiosProvider "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/providers/AxiosProvider.tsx"
    click AntDesign "https://github.com/2602hoang/admin-nextjs/tree/deploy_app/src/style/antd"
    click StateManagement "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/components/state/StateCallApi.tsx"
    click ErrorHandler "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/errors/HttpError.ts"
    click AppProviders "https://github.com/2602hoang/admin-nextjs/blob/deploy_app/src/providers/AppProviders.tsx"
```
