# 53ai/53aihub architecture

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

- Interactive diagram: https://gitdiagram.com/53ai/53aihub
- Repository: https://github.com/53ai/53aihub

## Overview

##### Project Type and Purpose
- This is a full-stack, open-source AI portal (“53AI Hub”) comprising:
- A Go-based monolithic API server (the `api/` directory)
- A Vue-powered web administration console (`web/console/`)
- An Electron/Vite-based desktop/web front-end application (`web/front/`)
- Docker orchestration for local/cloud deployment (`docker/` folders)
- Its purpose is to provide an operational AI portal: managing AI agents, prompts, tools, users, permissions, SSO, and integrations with LLM platforms and cloud services.

##### File-Structure Analysis
- Top-level “api/” directory contains subfolders:
- `common/`, `config/`, `controller/`, `middleware/`, `model/`, `router/`, `service/`, `tasks/`, and Docker/Makefiles.
- Controllers route HTTP requests → Services implement business logic → Models map to database → Common utilities handle cache, storage, email, JWT, logging, etc.
- `service/hub_adaptor/` holds adapters for third-party AI platforms (OpenAI, Dify, Coze, etc.).
- `tasks/` contains background/cron jobs.
- Two front-end apps under “web/”:
- `web/console/`: an admin portal built with Vue 3, Vite, TypeScript, Vuex/Pinia, Vue Router, and UEditor/Vditor for rich text.
- `web/front/`: an Electron-backed desktop client (also usable as SPA) with similar structure to console but scoped for end-user chat & agent interaction.
- Shared Docker Compose files under `api/docker/` and project-level `docker/` orchestrate multi-container stacks (API, DB, Redis, storage).

##### Key README Insights
- Emphasizes one-click deployment via Docker Compose
- Lists integrations: Coze, Dify, FastGPT, RAGFlow, 53AI Studio
- Mentions enterprise features: SSO (WeCom, DingTalk, Feishu), multi-style theming, permissions, user management
- Guides to use `.env` for custom config

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Web Admin Console"
        AdminUI["Vue Admin Console"]:::frontend
        subgraph "Admin Console Details"
            Src["Source Code"]:::frontend
            Public["Public Assets"]:::frontend
            AR["Admin Router"]:::frontend
            AS["State Management"]:::frontend
            AC["Components Library"]:::frontend
        end
    end

    subgraph "Electron/Web Front UI"
        FrontUI["Electron/Web Front UI"]:::frontend
        subgraph "Front UI Details"
            FRenderer["Renderer Source"]:::frontend
            FEConfig["Electron Config"]:::frontend
            FAPIMod["API Modules"]:::frontend
            FComp["UI Components"]:::frontend
            FR["Front Router"]:::frontend
            FS["Front Stores"]:::frontend
            FViews["Front Views"]:::frontend
        end
    end

    %% Backend Services
    subgraph "Backend Services"
        APIServer["Go API Server"]:::backend
        subgraph "Monolith Components"
            Cont["Controllers"]:::backend
            Serv["Services"]:::backend
            Mod["Models"]:::backend
            Mid["Middleware"]:::backend
            Comm["Common Utilities"]:::backend
            Rout["Router Definitions"]:::backend
            Task["Background Tasks"]:::backend
        end
    end

    %% Infrastructure & Data Stores
    subgraph "Infrastructure & Data Stores"
        DB["Relational DB"]:::datastore
        Redis["Redis Cache"]:::datastore
        ObjStore["Object Storage"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        LLM["LLM Providers"]:::external
        SSO["SSO Identity Providers"]:::external
        Email["Email Service"]:::external
        Cloud["Cloud Services"]:::external
    end

    %% Orchestration
    subgraph "Orchestration"
        Docker["Docker Compose"]:::infra
    end

    %% Connections
    AdminUI -->|"REST API"| APIServer
    FrontUI -->|"REST API"| APIServer
    APIServer -->|"uses"| Cont
    APIServer -->|"uses"| Serv
    APIServer -->|"uses"| Mod
    APIServer -->|"uses"| Mid
    APIServer -->|"uses"| Comm
    APIServer -->|"uses"| Rout
    Task -->|"invokes"| APIServer
    APIServer -->|"SQL Queries"| DB
    APIServer -->|"Cache GET/SET"| Redis
    APIServer -->|"File Upload/Download"| ObjStore
    APIServer -->|"Adapter Calls (HTTP)"| LLM
    APIServer -->|"OAuth/OpenID"| SSO
    APIServer -->|"SMTP/API"| Email
    APIServer -->|"Cloud SDK"| Cloud
    Docker --> APIServer
    Docker --> DB
    Docker --> Redis
    Docker --> ObjStore
    Docker --> AdminUI
    Docker --> FrontUI

    %% Click Events
    click APIServer "https://github.com/53ai/53aihub/tree/main/api/"
    click Cont "https://github.com/53ai/53aihub/tree/main/api/controller/"
    click Serv "https://github.com/53ai/53aihub/tree/main/api/service/"
    click Mod "https://github.com/53ai/53aihub/tree/main/api/model/"
    click Mid "https://github.com/53ai/53aihub/tree/main/api/middleware/"
    click Comm "https://github.com/53ai/53aihub/tree/main/api/common/"
    click Rout "https://github.com/53ai/53aihub/tree/main/api/router/"
    click Task "https://github.com/53ai/53aihub/tree/main/api/tasks/"
    click Docker "https://github.com/53ai/53aihub/blob/main/docker/docker-compose.yml"
    click AdminUI "https://github.com/53ai/53aihub/tree/main/web/console/"
    click Src "https://github.com/53ai/53aihub/tree/main/web/console/src/"
    click Public "https://github.com/53ai/53aihub/tree/main/web/console/public/"
    click AR "https://github.com/53ai/53aihub/tree/main/web/console/src/router/"
    click AS "https://github.com/53ai/53aihub/tree/main/web/console/src/stores/"
    click AC "https://github.com/53ai/53aihub/tree/main/web/console/src/components/"
    click FrontUI "https://github.com/53ai/53aihub/tree/main/web/front/"
    click FRenderer "https://github.com/53ai/53aihub/tree/main/web/front/src/renderer/main/"
    click FEConfig "https://github.com/53ai/53aihub/blob/main/web/front/electron.vite.config.ts"
    click FAPIMod "https://github.com/53ai/53aihub/tree/main/web/front/src/renderer/main/api/modules/"
    click FComp "https://github.com/53ai/53aihub/tree/main/web/front/src/renderer/main/components/"
    click FR "https://github.com/53ai/53aihub/tree/main/web/front/src/renderer/main/router/"
    click FS "https://github.com/53ai/53aihub/tree/main/web/front/src/renderer/main/stores/"
    click FViews "https://github.com/53ai/53aihub/tree/main/web/front/src/renderer/main/views/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef infra fill:#DDA0DD,stroke:#333,stroke-width:1px
```
