# lingeorge88/admin_dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/lingeorge88/admin_dashboard
- Repository: https://github.com/lingeorge88/admin_dashboard

## Overview

##### Project type and purpose
- This is a full-stack analytics/dashboard application.
- The “client” folder holds a React single-page application (SPA) that renders charts, grids, and navigation.
- The “server” folder contains an Express.js REST API using Mongoose models to persist users, products, transactions, and statistics in MongoDB.

##### File structure
- Top-level:
- client/ – React UI (public/, src/, package.json)
- server/ – Node/Express API (controllers/, models/, routes/, data/, index.js)
- Client src/ organizes code by reusable components (charts, grid helpers) and scenes (dashboard, breakdown, customers, etc.), plus a Redux-style state folder (api.js, geoData.js).
- Server follows an MVC-like pattern: routes → controllers → models.
- Configuration files: client/jsconfig.json, both package.json’s, .gitignore’s.

##### Main components
a. Client (React Browser SPA)
- UI Components (StatBox, OverviewChart, Sidebar…)
- Scenes (Dashboard, Breakdown, Transactions…)
- State Management (Redux store / RTK Query in src/state/api.js)
b. Server (Express API)
- Routes (client, general, management, sales)
- Controllers (client.js, sales.js, management.js, general.js)
- Data layer (server/data/index.js – sample or seed data)
- Models (User, Product, Transaction, AffiliateStat, OverallStat, ProductStat)
c. Database
- MongoDB cluster (external service)
d. External services (if any)
- Auth provider, analytics platform (not shown – optional placeholders)

##### Relationships and interactions
- Browser → HTTP(S) requests → Express Routes
- Routes invoke Controllers → Mongoose Models → MongoDB
- Responses (JSON) return to Client → RTK Query cache/store → UI components re-render
- Static asset serving: client/public builds served by a CDN or directly by the server in production build

##### Architectural patterns and design principles
- Client: Component-based UI, container/presentational separation, centralized state with RTK Query, code-splitting by scenes.
- Server: RESTful API, MVC separation, single responsibility in controllers, schema definitions in models.
- Clear separation of concerns: UI vs. application logic vs. data persistence.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        direction TB
        Browser["Browser: React SPA"]:::frontend
        EntryPointFE["App Entry Point\n(client/src/index.js)"]:::frontend
        Components["UI Components\n(client/src/components/)"]:::frontend
        Scenes["Scenes\n(client/src/scenes/)"]:::frontend
        StateAPI["State: RTK Query\n(client/src/state/api.js)"]:::frontend
        GeoData["Geo State Data\n(client/src/state/geoData.js)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        ExpressServer["Express API\n(server/index.js)"]:::backend

        subgraph "Routes"
            direction TB
            ClientRoutes["Route: /client"]:::backend
            GeneralRoutes["Route: /general"]:::backend
            ManagementRoutes["Route: /management"]:::backend
            SalesRoutes["Route: /sales"]:::backend
        end

        subgraph "Controllers"
            direction TB
            ClientCtrl["Controller: client.js"]:::backend
            GeneralCtrl["Controller: general.js"]:::backend
            ManagementCtrl["Controller: management.js"]:::backend
            SalesCtrl["Controller: sales.js"]:::backend
        end

        DataLayer["Data Layer\n(server/data/index.js)"]:::backend

        subgraph "Models"
            direction TB
            ModelUser["Model: User"]:::backend
            ModelProduct["Model: Product"]:::backend
            ModelTransaction["Model: Transaction"]:::backend
            ModelAffiliateStat["Model: AffiliateStat"]:::backend
            ModelProductStat["Model: ProductStat"]:::backend
            ModelOverallStat["Model: OverallStat"]:::backend
        end
    end

    %% Database Layer
    subgraph "Database"
        direction TB
        MongoDB["MongoDB Cluster"]:::database
    end

    %% Connections Frontend to Backend
    Browser -->|"loads SPA"| EntryPointFE
    EntryPointFE --> Scenes
    EntryPointFE --> Components
    Components -->|"dispatch RTK Query"| StateAPI
    Scenes -->|"render UI"| Components
    StateAPI -->|"HTTP GET/POST"| ExpressServer

    %% Backend Routing
    ExpressServer --> ClientRoutes
    ExpressServer --> GeneralRoutes
    ExpressServer --> ManagementRoutes
    ExpressServer --> SalesRoutes

    %% Routing to Controllers
    ClientRoutes --> ClientCtrl
    GeneralRoutes --> GeneralCtrl
    ManagementRoutes --> ManagementCtrl
    SalesRoutes --> SalesCtrl

    %% Controllers to Models / Data
    ClientCtrl --> ModelUser
    ClientCtrl --> ModelProduct
    ClientCtrl --> ModelTransaction
    GeneralCtrl --> ModelOverallStat
    SalesCtrl --> ModelProductStat
    SalesCtrl --> ModelAffiliateStat
    ManagementCtrl --> ModelTransaction
    ClientCtrl --> DataLayer

    %% Models to Database
    ModelUser -->|"CRUD ops"| MongoDB
    ModelProduct --> MongoDB
    ModelTransaction --> MongoDB
    ModelAffiliateStat --> MongoDB
    ModelProductStat --> MongoDB
    ModelOverallStat --> MongoDB
    DataLayer --> MongoDB

    %% Response Flow
    MongoDB -->|data| ModelOverallStat
    MongoDB -->|data| ModelProductStat
    MongoDB -->|data| ModelAffiliateStat
    MongoDB -->|data| ModelTransaction
    MongoDB -->|data| ModelProduct
    MongoDB -->|data| ModelUser
    ModelOverallStat --> GeneralCtrl
    ModelProductStat --> SalesCtrl
    ModelAffiliateStat --> SalesCtrl
    ModelTransaction --> ManagementCtrl
    ModelProduct --> ClientCtrl
    ModelUser --> ClientCtrl
    ClientCtrl -->|response| ExpressServer
    GeneralCtrl -->|response| ExpressServer
    SalesCtrl -->|response| ExpressServer
    ManagementCtrl -->|response| ExpressServer
    ExpressServer -->|JSON response| StateAPI
    StateAPI -->|update store| Components
    Components -->|re-render| Browser

    %% Click Events
    click Browser "https://github.com/lingeorge88/admin_dashboard/tree/main/client/"
    click EntryPointFE "https://github.com/lingeorge88/admin_dashboard/blob/main/client/src/index.js"
    click Components "https://github.com/lingeorge88/admin_dashboard/tree/main/client/src/components/"
    click Scenes "https://github.com/lingeorge88/admin_dashboard/tree/main/client/src/scenes/"
    click StateAPI "https://github.com/lingeorge88/admin_dashboard/blob/main/client/src/state/api.js"
    click GeoData "https://github.com/lingeorge88/admin_dashboard/blob/main/client/src/state/geoData.js"
    click ExpressServer "https://github.com/lingeorge88/admin_dashboard/blob/main/server/index.js"
    click ClientRoutes "https://github.com/lingeorge88/admin_dashboard/blob/main/server/routes/client.js"
    click GeneralRoutes "https://github.com/lingeorge88/admin_dashboard/blob/main/server/routes/general.js"
    click ManagementRoutes "https://github.com/lingeorge88/admin_dashboard/blob/main/server/routes/management.js"
    click SalesRoutes "https://github.com/lingeorge88/admin_dashboard/blob/main/server/routes/sales.js"
    click ClientCtrl "https://github.com/lingeorge88/admin_dashboard/blob/main/server/controllers/client.js"
    click GeneralCtrl "https://github.com/lingeorge88/admin_dashboard/blob/main/server/controllers/general.js"
    click ManagementCtrl "https://github.com/lingeorge88/admin_dashboard/blob/main/server/controllers/management.js"
    click SalesCtrl "https://github.com/lingeorge88/admin_dashboard/blob/main/server/controllers/sales.js"
    click DataLayer "https://github.com/lingeorge88/admin_dashboard/blob/main/server/data/index.js"
    click ModelUser "https://github.com/lingeorge88/admin_dashboard/blob/main/server/models/User.js"
    click ModelProduct "https://github.com/lingeorge88/admin_dashboard/blob/main/server/models/Product.js"
    click ModelTransaction "https://github.com/lingeorge88/admin_dashboard/blob/main/server/models/Transaction.js"
    click ModelAffiliateStat "https://github.com/lingeorge88/admin_dashboard/blob/main/server/models/AffiliateStat.js"
    click ModelProductStat "https://github.com/lingeorge88/admin_dashboard/blob/main/server/models/ProductStat.js"
    click ModelOverallStat "https://github.com/lingeorge88/admin_dashboard/blob/main/server/models/OverallStat.js"

    %% Styles
    classDef frontend fill:#E8F0FE,stroke:#0366d6,color:#0366d6
    classDef backend fill:#E6F4EA,stroke:#22863a,color:#22863a
    classDef database fill:#FCEBD8,stroke:#d73a49,color:#d73a49
```
