# liangliang723/sun-panel architecture

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

- Interactive diagram: https://gitdiagram.com/liangliang723/sun-panel
- Repository: https://github.com/liangliang723/sun-panel

## Overview

##### Main Components
- Frontend Client:
- Vue.js application (present in the “src” directory, “public”, “index.html”, and assets).
- Related modules like components (apps, common, deskModule), API integration (src/api), routing (src/router), and state management (src/store).
- Backend API Server:
- Go service as a core API server, combining multiple modules (e.g., system, panel, openness) which are segmented in the “service/api/api_v1” directories.
- Middleware (e.g., AdminInterceptor, LoginInterceptor, and PublicModeInterceptor), routers (in “service/router”), and business logic (in “service/lib”, “service/global”, “service/initialize”) components.
- Configuration & Initialization:
- Supporting/Infrastructure Elements:
- Docker and compose files, which show the deployment packaging. Also include CI/CD workflows from “.github/workflows.”
- Mention utilities such as caching (both in “service/lib/cache” and “service/initialize/redis”) and rate limiting (“service/global/rateLimit.go” and related files).

##### Relationships and Interactions
- Client-Server Interaction:
- Separate API endpoints catering to different modules, e.g., “system”, “panel”, “openness.”
- Backend Internal Flow:
- Initialization routines and configuration loading as the fundamental startup steps for the backend.
- Data Flow & Caching:
- If applicable, include interactions with caching layers (in-memory or Redis based on “service/lib/cache” and “service/initialize/redis”) and other utility libraries.
- Docker and Deployment:
- Docker containers (Dockerfile and docker-compose.yml) to show the container boundaries, and note the build pipelines from CI workflows.

##### Architectural Patterns and Technologies
- Use the MVC or layered approach in the backend (separating API routing, controller/middleware logic, and business logic).
- Clear separation of concerns between the client (view layer using Vue.js) and server (API and services written in Go).
- Docker deployment strategy and the use of container orchestration with docker-compose.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Client
    subgraph "Frontend Client"
        FE1["Vue.js App"] 
        FE2["Public Files & index.html"]
        FE3["Assets"]
        FE4["Styles"]
        FE5["API Integration"]
        FE6["Routing"]
        FE7["State Management"]
        FE8["UI Components"]
    end

    %% Backend API Server
    subgraph "Backend API Server"
        BE1["API Endpoints (system,panel,openness)"]
        BE2["Middleware (Admin,Login,PublicMode)"]
        BE3["Backend Routers"]
        BE4["Business Logic"]
        BE5["Global Logic"]
        BE6["Rate Limiting"]
        BE7["Cache Utility"]
        BE8["Redis Initialization"]
    end

    %% Configuration & Initialization
    subgraph "Configuration & Initialization"
        CI1["Configuration Files"]
        CI3["Initialization Config"]
        CI4["Service Assets"]
        CI2["Initialization Routines"]
    end

    %% Infrastructure & Deployment
    subgraph "Infrastructure & Deployment"
        INF1["Dockerfile"]
        INF2["docker-compose.yml"]
        INF3["CI/CD Workflows"]
    end

    %% Connections between Frontend and Backend
    FE5 -->|"HTTPRequest"| BE1

    %% Internal Backend Flow
    BE1 -->|"pass"| BE2
    BE2 -->|"route"| BE3
    BE3 -->|"process"| BE4
    BE3 -->|"global"| BE5
    BE3 -->|"limit"| BE6
    BE3 -->|"cache"| BE7
    BE7 -->|"init"| BE8

    %% Configuration feeding Backend
    CI1 --> CI2
    CI3 --> CI2
    CI4 --> CI2
    CI2 -->|"configures"| BE4

    %% Infrastructure wrapping Frontend & Backend
    INF1 --- FE1
    INF1 --- BE1
    INF2 --- FE1
    INF2 --- BE1
    INF3 --> INF1
    INF3 --> INF2

    %% Class styling
    class FE1,FE2,FE3,FE4,FE5,FE6,FE7,FE8 frontend
    class BE1,BE2,BE3,BE4,BE5,BE6,BE7,BE8 backend
    class CI1,CI2,CI3,CI4 config
    class INF1,INF2,INF3 infra

    %% Click Events for Frontend
    click FE1 "https://github.com/liangliang723/sun-panel/tree/master/src"
    click FE2 "https://github.com/liangliang723/sun-panel/tree/master/public"
    click FE3 "https://github.com/liangliang723/sun-panel/tree/master/src/assets"
    click FE4 "https://github.com/liangliang723/sun-panel/tree/master/src/styles"
    click FE5 "https://github.com/liangliang723/sun-panel/tree/master/src/api"
    click FE6 "https://github.com/liangliang723/sun-panel/tree/master/src/router"
    click FE7 "https://github.com/liangliang723/sun-panel/tree/master/src/store"
    click FE8 "https://github.com/liangliang723/sun-panel/tree/master/src/components"

    %% Click Events for Backend
    click BE1 "https://github.com/liangliang723/sun-panel/tree/master/service/api/api_v1"
    click BE2 "https://github.com/liangliang723/sun-panel/tree/master/service/api/api_v1/middleware"
    click BE3 "https://github.com/liangliang723/sun-panel/tree/master/service/router"
    click BE4 "https://github.com/liangliang723/sun-panel/tree/master/service/lib"
    click BE5 "https://github.com/liangliang723/sun-panel/tree/master/service/global"
    click BE6 "https://github.com/liangliang723/sun-panel/blob/master/service/global/rateLimit.go"
    click BE7 "https://github.com/liangliang723/sun-panel/tree/master/service/lib/cache"
    click BE8 "https://github.com/liangliang723/sun-panel/blob/master/service/initialize/redis/redis.go"

    %% Click Events for Configuration & Initialization
    click CI1 "https://github.com/liangliang723/sun-panel/tree/master/config"
    click CI2 "https://github.com/liangliang723/sun-panel/tree/master/service/initialize"
    click CI3 "https://github.com/liangliang723/sun-panel/blob/master/service/initialize/config/config.go"
    click CI4 "https://github.com/liangliang723/sun-panel/tree/master/service/assets"

    %% Click Events for Infrastructure & Deployment
    click INF1 "https://github.com/liangliang723/sun-panel/tree/master/Dockerfile"
    click INF2 "https://github.com/liangliang723/sun-panel/blob/master/docker-compose.yml"
    click INF3 "https://github.com/liangliang723/sun-panel/tree/master/.github/workflows"

%% Style Definitions
classDef frontend fill:#FFEBEE,stroke:#C62828,stroke-width:2px;
classDef backend fill:#E3F2FD,stroke:#1565C0,stroke-width:2px;
classDef config fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px;
classDef infra fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px;
```
