# zhuhengtan/gorgeous-admin architecture

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

- Interactive diagram: https://gitdiagram.com/zhuhengtan/gorgeous-admin
- Repository: https://github.com/zhuhengtan/gorgeous-admin

## Overview

##### Main System Components

a) Frontend Architecture (Primary Focus):
- Present this as the main layer with these sub-components:
- Core Application Layer (src/app.tsx)
- Authentication System (src/components/auth-fragment)
- Routing System (src/routes)
- Layout Components (src/components/layout)
- Service Layer (src/service)
- Internationalization System (src/lang)

b) Backend Integration:
- Connection to gorgeous-admin-server (external)
- API Communication Layer (src/service/api.ts)

##### Authentication Flow
- Login Page → Auth Service → Backend
- Auth Context Provider → Protected Routes

##### Data Flow
- Components → Service Layer → API Layer → Backend
- API Responses → State Management → Components

##### Specific Component Details

**[Frontend Layer]**
- Authentication System
- Login Module
- Role Management
- User Management
- Core Features
- Page Management
- CRUD Generator
- Admin Dashboard
- Shared Infrastructure
- i18n System
- Layout Components
- Common Utils
- Service Layer
- API Client
- Request Handlers

##### Important Technical Aspects

Technical implementations:
- Vite as build tool (vite.config.mts)
- TypeScript integration (tsconfig.json)
- Environment configurations (vite-env/)
- Nginx deployment setup (nginx/)

##### Architectural Patterns to Emphasize

Patterns:
- Component-based architecture
- Route-based code splitting
- Service layer abstraction
- Authentication context provider pattern

##### External Services Layer

This structure will help other developers understand both the overall architecture and the specific implementation details of this admin dashboard system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        App["Core Application"]:::core
        AuthSystem["Authentication System"]:::auth
        Routes["Routing System"]:::core
        Layout["Layout Components"]:::ui
        Services["Service Layer"]:::service
        I18n["Internationalization"]:::infra
        
        subgraph AuthComponents
            Login["Login Module"]:::auth
            RoleMgmt["Role Management"]:::auth
            UserMgmt["User Management"]:::auth
            AuthContext["Auth Context"]:::auth
        end
        
        subgraph CoreFeatures
            PageMgmt["Page Management"]:::feature
            CRUDGen["CRUD Generator"]:::feature
            Dashboard["Admin Dashboard"]:::feature
        end
        
        subgraph SharedInfra
            LayoutComp["Layout Components"]:::ui
            Utils["Common Utils"]:::infra
        end
        
        subgraph ServiceLayer
            APIClient["API Client"]:::service
            ReqHandlers["Request Handlers"]:::service
        end
    end
    
    Backend["gorgeous-admin-server"]:::external
    
    %% Relationships
    App --> AuthSystem
    App --> Routes
    App --> Layout
    App --> I18n
    
    AuthSystem --> AuthComponents
    AuthContext --> Routes
    
    Routes --> CoreFeatures
    Routes --> SharedInfra
    
    Services --> APIClient
    APIClient --> Backend
    
    Login --> Services
    RoleMgmt --> Services
    UserMgmt --> Services
    PageMgmt --> Services
    CRUDGen --> Services
    Dashboard --> Services
    
    %% Click Events
    click App "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/app.tsx"
    click AuthSystem "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/components/auth-fragment/index.tsx"
    click Routes "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/routes/index.tsx"
    click Layout "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/components/layout/index.tsx"
    click Services "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/service/index.ts"
    click I18n "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/lang/i18n.tsx"
    click Login "https://github.com/zhuhengtan/gorgeous-admin/tree/main/src/pages/login"
    click RoleMgmt "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/pages/auth/role/index.tsx"
    click PageMgmt "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/pages/auth/page/index.tsx"
    click CRUDGen "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/pages/auth/generate-server-crud/index.tsx"
    click APIClient "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/service/api.ts"
    click AuthContext "https://github.com/zhuhengtan/gorgeous-admin/blob/main/src/context/AdminAuthContext.ts"
    click LayoutComp "https://github.com/zhuhengtan/gorgeous-admin/tree/main/src/components/layout"
    
    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef auth fill:#F44336,stroke:#C62828,color:white
    classDef ui fill:#4CAF50,stroke:#2E7D32,color:white
    classDef service fill:#FF9800,stroke:#EF6C00,color:white
    classDef infra fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef feature fill:#00BCD4,stroke:#00838F,color:white
    classDef external fill:#757575,stroke:#424242,color:white
    
    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Auth Components"]:::auth
        L3["UI Components"]:::ui
        L4["Services"]:::service
        L5["Infrastructure"]:::infra
        L6["Features"]:::feature
        L7["External Systems"]:::external
    end
```
