# jaikewhh166/3x-ui architecture

> Architecture diagram of the GitHub repository jaikewhh166/3x-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jaikewhh166/3x-ui
- Repository: https://github.com/jaikewhh166/3x-ui

## Overview

3X-UI is a web control panel for configuring and monitoring Xray proxy servers, managing clients and subscriptions, and operating multi-node deployments. The main workflow runs from the panel UI through HTTP controllers and services to persistent state and Xray or remote-node runtimes; subscription requests also produce client-ready configuration formats. The README documents further capabilities including routing, outbound management, Telegram, Fail2ban, and API documentation. Some UI and backend links are documented only at product level; unsampled implementation details are not asserted.

Main entry points: [`frontend/src/api`](https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/api) (API client), [`internal/sub/controller.go`](https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/controller.go) (Subscription routes), [`internal/database/db.go`](https://github.com/jaikewhh166/3x-ui/blob/main/internal/database/db.go) (Persistent storage), [`internal/web/service/client_bulk.go`](https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/service/client_bulk.go) (Client operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_panel["Panel interface"]
  node_panel_ui["Management UI"]
  node_routing_ui["Routing editor"]
  node_client_ui["Client management"]
  node_api_client["API client"]
end

subgraph group_api["Web API"]
  node_app_entry["Application entry<br/>[main.go]"]
  node_web_server["Web server<br/>[server.go]"]
  node_client_api["Client endpoints<br/>[client.go]"]
  node_subscription_api["Subscription routes<br/>[controller.go]"]
end

subgraph group_domain["Management services"]
  node_client_service["Client operations<br/>[client_bulk.go]"]
  node_server_service["Panel operations<br/>[server.go]"]
  node_database[("Persistent storage<br/>[db.go]")]
  node_telegram["Telegram bot"]
end

subgraph group_runtime["Proxy runtimes"]
  node_xray["Xray core"]
  node_runtime_dispatch["Node runtime dispatch<br/>[manager.go]"]
  node_mtproto["MTProto sidecar<br/>[manager.go]"]
end

subgraph group_delivery["Subscriptions"]
  node_subscription_service["Subscription generation<br/>[service.go]"]
  node_json_subs["JSON subscriptions<br/>[json_service.go]"]
  node_clash_subs["Clash subscriptions<br/>[clash_service.go]"]
end

node_operator(("Panel operator"))
node_remote_nodes["Remote nodes"]
node_subscription_user(("Subscription client"))

node_operator -->|"uses"| node_panel_ui
node_panel_ui -.->|"requests data"| node_api_client
node_routing_ui -.->|"saves configuration"| node_api_client
node_client_ui -.->|"manages clients"| node_api_client
node_app_entry -->|"starts server"| node_web_server
node_api_client -.->|"calls API"| node_web_server
node_api_client -.->|"calls API"| node_client_api
node_web_server -->|"serves operations"| node_server_service
node_client_api -.->|"delegates"| node_client_service
node_client_service -->|"reads and writes"| node_database
node_client_service -->|"updates clients"| node_xray
node_server_service -->|"uses storage"| node_database
node_server_service -->|"manages core"| node_xray
node_runtime_dispatch -->|"loads nodes"| node_database
node_runtime_dispatch -.->|"dispatches remotely"| node_remote_nodes
node_subscription_api -->|"builds subscriptions"| node_subscription_service
node_subscription_service -->|"reads client state"| node_database
node_subscription_api -->|"serves JSON"| node_json_subs
node_subscription_api -->|"serves Clash"| node_clash_subs
node_subscription_user -->|"requests config"| node_subscription_api
node_app_entry -->|"initializes service"| node_mtproto

click node_panel_ui "https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/pages"
click node_routing_ui "https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/pages/xray/routing"
click node_client_ui "https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/pages/clients"
click node_api_client "https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/api"
click node_app_entry "https://github.com/jaikewhh166/3x-ui/blob/main/main.go"
click node_web_server "https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/controller/server.go"
click node_client_api "https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/controller/client.go"
click node_subscription_api "https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/controller.go"
click node_client_service "https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/service/client_bulk.go"
click node_server_service "https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/service/server.go"
click node_database "https://github.com/jaikewhh166/3x-ui/blob/main/internal/database/db.go"
click node_subscription_service "https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/service.go"
click node_json_subs "https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/json_service.go"
click node_clash_subs "https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/clash_service.go"
click node_xray "https://github.com/jaikewhh166/3x-ui/tree/main/internal/xray"
click node_runtime_dispatch "https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/runtime/manager.go"
click node_mtproto "https://github.com/jaikewhh166/3x-ui/blob/main/internal/mtproto/manager.go"
click node_telegram "https://github.com/jaikewhh166/3x-ui/tree/main/internal/web/service/tgbot"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_panel_ui,node_routing_ui,node_client_ui,node_api_client,node_subscription_user toneBlue
class node_app_entry,node_web_server,node_client_api,node_subscription_api toneAmber
class node_client_service,node_server_service,node_database,node_telegram toneMint
class node_xray,node_runtime_dispatch,node_mtproto toneRose
class node_subscription_service,node_json_subs,node_clash_subs,node_operator,node_remote_nodes toneIndigo
```

## Components

### Panel interface

- [Management UI](https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/pages): `frontend/src/pages`
- [Routing editor](https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/pages/xray/routing): `frontend/src/pages/xray/routing`
- [Client management](https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/pages/clients): `frontend/src/pages/clients`
- [API client](https://github.com/jaikewhh166/3x-ui/tree/main/frontend/src/api): `frontend/src/api`

### Web API

- [Application entry](https://github.com/jaikewhh166/3x-ui/blob/main/main.go): `main.go`
- [Web server](https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/controller/server.go): `internal/web/controller/server.go`
- [Client endpoints](https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/controller/client.go): `internal/web/controller/client.go`
- [Subscription routes](https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/controller.go): `internal/sub/controller.go`

### Management services

- [Client operations](https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/service/client_bulk.go): `internal/web/service/client_bulk.go`
- [Panel operations](https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/service/server.go): `internal/web/service/server.go`
- [Persistent storage](https://github.com/jaikewhh166/3x-ui/blob/main/internal/database/db.go): `internal/database/db.go`
- [Telegram bot](https://github.com/jaikewhh166/3x-ui/tree/main/internal/web/service/tgbot): `internal/web/service/tgbot`

### Proxy runtimes

- [Xray core](https://github.com/jaikewhh166/3x-ui/tree/main/internal/xray): `internal/xray`
- [Node runtime dispatch](https://github.com/jaikewhh166/3x-ui/blob/main/internal/web/runtime/manager.go): `internal/web/runtime/manager.go`
- [MTProto sidecar](https://github.com/jaikewhh166/3x-ui/blob/main/internal/mtproto/manager.go): `internal/mtproto/manager.go`

### Subscriptions

- [Subscription generation](https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/service.go): `internal/sub/service.go`
- [JSON subscriptions](https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/json_service.go): `internal/sub/json_service.go`
- [Clash subscriptions](https://github.com/jaikewhh166/3x-ui/blob/main/internal/sub/clash_service.go): `internal/sub/clash_service.go`

### Other components

- **Panel operator**
- **Remote nodes**
- **Subscription client**

## Connections

- Panel operator → Management UI: uses (evidence: `README.md`)
- Management UI → API client: requests data
- Routing editor → API client: saves configuration
- Client management → API client: manages clients
- Application entry → Web server: starts server (evidence: `main.go`)
- API client → Web server: calls API
- API client → Client endpoints: calls API
- Web server → Panel operations: serves operations (evidence: `internal/web/controller/server.go`)
- Client endpoints → Client operations: delegates
- Client operations → Persistent storage: reads and writes (evidence: `internal/web/service/client_bulk.go`)
- Client operations → Xray core: updates clients (evidence: `internal/web/service/client_bulk.go`)
- Panel operations → Persistent storage: uses storage (evidence: `internal/web/service/server.go`)
- Panel operations → Xray core: manages core (evidence: `internal/web/service/server.go`)
- Node runtime dispatch → Persistent storage: loads nodes (evidence: `internal/web/runtime/manager.go`)
- Node runtime dispatch → Remote nodes: dispatches remotely
- Subscription routes → Subscription generation: builds subscriptions (evidence: `internal/sub/controller.go`)
- Subscription generation → Persistent storage: reads client state (evidence: `internal/sub/service.go`)
- Subscription routes → JSON subscriptions: serves JSON (evidence: `internal/sub/controller.go`)
- Subscription routes → Clash subscriptions: serves Clash (evidence: `internal/sub/controller.go`)
- Subscription client → Subscription routes: requests config (evidence: `README.md`)
- Application entry → MTProto sidecar: initializes service (evidence: `main.go`)
