# richard0403/fluxpanel architecture

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

- Interactive diagram: https://gitdiagram.com/richard0403/fluxpanel
- Repository: https://github.com/richard0403/fluxpanel

## Overview

##### Project Type and Purpose
- This is a full‑stack, front‑end/back‑end separated web application called “FluxPanel,” a rapid development framework built with FastAPI (Python) on the back end and Vue 3 on the front end.
- It delivers a management console with built‑in user/role/menu/department/post/dict/parameter/notice/logs/monitoring/code‑generation/AI Q&A features and supports Docker deployment.

##### Top‑Level Components
- Docker Compose Orchestrator
- Nginx Reverse Proxy / Static File Server
- Frontend (Vue 3 + Element Plus)
- Backend API Server (FastAPI + Uvicorn/Gunicorn/Granian)
- Relational Database (MySQL)
- In‑Memory Store / Cache (Redis)
- Scheduler / Task Queue (Python APScheduler via Redis)
- MCP AI WebSocket Server (AI Q&A)
- Code Generation Module

##### Key Architectural Patterns
- Front‑end / Back‑end separation via an HTTP API layer
- MVC‑style organization in both layers:
- Frontend: Views, Components, Services (api/*.js)
- Backend: Controllers (FastAPI routers), Services, DAOs, Entities (DO/VO)
- Modular back end: module_admin, module_app, module_gen, module_task, module_website
- Shared middleware stack (CORS, GZIP, error handling)
- Docker‑based micro‑services style: separate containers for nginx, mysql, python app, redis

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Users(["Users & Browsers"]):::client

    %% Proxy
    Nginx["Nginx\n(Ports: 80/443)"]:::proxy

    %% Frontend
    Frontend["Vue3 Frontend\n(Vite, Element Plus)"]:::frontend

    %% Backend
    subgraph "Backend API Server" 
        direction TB
        BackendCore["FastAPI App\n(Uvicorn/Gunicorn)"]:::backend
        subgraph "Controllers & Routers"
            RouterManager["router_manager.py"]:::backend
        end
        subgraph "Config & Middleware"
            Config["config/"]:::backend
            Middleware["middlewares/"]:::backend
        end
        subgraph "Modules"
            subgraph "CodeGen (module_gen)"
                CodeGenCtrl["gen_controller.py"]:::backend
                CodeGenSvc["gen_table_service.py"]:::backend
                CodeGenDAO["gen_table_dao.py"]:::backend
            end
            subgraph "Admin Module"
                AdminCtrl["module_admin/controllers"]:::backend
            end
            subgraph "App Module"
                AppCtrl["app_login_controller.py"]:::backend
            end
            subgraph "Website Module"
                WebCtrl["home_controller.py"]:::backend
            end
        end
        subgraph "Async Services"
            Scheduler["Scheduler (APScheduler)"]:::async
            MCP["MCP AI WebSocket"]:::async
        end
    end

    %% Data Stores
    MySQL["MySQL\n(≥5.7)"]:::db
    Redis["Redis Cache"]:::cache

    %% Docker Compose
    DockerCompose["Docker Compose Orchestrator"]:::infra

    %% Flows
    Users -->|HTTP/HTTPS| Nginx
    Nginx -->|Static Files| Frontend
    Nginx -->|/server/*| BackendCore
    Frontend -->|REST/HTTP| BackendCore
    BackendCore -->|SQL| MySQL
    BackendCore -->|Redis| Redis
    BackendCore -->|Invoke| Scheduler
    BackendCore -->|WebSocket| MCP
    CodeGenCtrl -->|Generate| CodeGenCtrl

    %% Docker network links
    DockerCompose --> Nginx
    DockerCompose --> Frontend
    DockerCompose --> BackendCore
    DockerCompose --> MySQL
    DockerCompose --> Redis

    %% Click Events
    click DockerCompose "https://github.com/richard0403/fluxpanel/blob/main/docker/docker-compose.yml"
    click Nginx "https://github.com/richard0403/fluxpanel/blob/main/docker/config/nginx/nginx.conf"
    click Nginx "https://github.com/richard0403/fluxpanel/blob/main/docker/config/nginx/conf.d/http-server.conf"
    click Nginx "https://github.com/richard0403/fluxpanel/blob/main/docker/config/nginx/conf.d/stream-app.conf"
    click Frontend "https://github.com/richard0403/fluxpanel/blob/main/flux-frontend/package.json"
    click Frontend "https://github.com/richard0403/fluxpanel/blob/main/flux-frontend/vite.config.js"
    click Frontend "https://github.com/richard0403/fluxpanel/tree/main/flux-frontend/src/"
    click BackendCore "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/app.py"
    click BackendCore "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/server.py"
    click RouterManager "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/router/router_manager.py"
    click Config "https://github.com/richard0403/fluxpanel/tree/main/flux-backend/config/"
    click Middleware "https://github.com/richard0403/fluxpanel/tree/main/flux-backend/middlewares/"
    click Scheduler "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/config/get_scheduler.py"
    click MCP "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/mcp_server/ai_websocket.py"
    click CodeGenCtrl "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/module_gen/controller/gen_controller.py"
    click CodeGenSvc "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/module_gen/service/gen_table_service.py"
    click CodeGenDAO "https://github.com/richard0403/fluxpanel/blob/main/flux-backend/module_gen/dao/gen_table_dao.py"

    %% Styles
    classDef client fill:#E3F2FD,stroke:#90CAF9;
    classDef proxy fill:#FFECB3,stroke:#FFC107;
    classDef frontend fill:#BBDEFB,stroke:#2196F3;
    classDef backend fill:#C8E6C9,stroke:#4CAF50;
    classDef db fill:#FFE0B2,stroke:#FF5722;
    classDef cache fill:#FFF9C4,stroke:#FBC02D;
    classDef async fill:#D1C4E9,stroke:#7E57C2;
    classDef infra fill:#CFD8DC,stroke:#607D8B;
```
