# tonulls/vpn-ui architecture

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

- Interactive diagram: https://gitdiagram.com/tonulls/vpn-ui
- Repository: https://github.com/tonulls/vpn-ui

## Overview

vpn-ui is an all-in-one VPN server panel built around an HTTP administration UI, persistent account/inbound configuration, and managed VPN/Xray processes. The main operator workflow is to sign in, configure accounts and inbounds, and have the panel manage services and expose client subscriptions; clients then connect using the configured protocols. The README documents broad daemon, kernel-tunnel, accounting, and Xray capabilities, while the supplied source excerpts only verify selected wiring. Edges for documented-but-unsampled integrations cite the README; other uncertain connections are omitted.

Main entry points: [`web/web.go`](https://github.com/tonulls/vpn-ui/blob/tonulls/web/web.go) (HTTP server), [`web/service`](https://github.com/tonulls/vpn-ui/tree/tonulls/web/service) (VPN protocol services), [`sub/subService.go`](https://github.com/tonulls/vpn-ui/blob/tonulls/sub/subService.go) (Subscription generation), [`web/job`](https://github.com/tonulls/vpn-ui/tree/tonulls/web/job) (Scheduled monitoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_panel["Panel and administration"]
  node_web["HTTP server<br/>[web.go]"]
  node_login["Login and sessions<br/>[index.go]"]
  node_server_api["Server controls<br/>[server.go]"]
  node_other_controllers["Panel controllers"]
  node_database[("Panel database<br/>[db.go]")]
end

subgraph group_accounts["Accounts and subscriptions"]
  node_models["Account and inbound models<br/>[model.go]"]
  node_account_services["Account and inbound services"]
  node_subscription_routes["Subscription routes<br/>[subController.go]"]
  node_subscription_builder["Subscription generation<br/>[subService.go]"]
  node_clash_output["Clash output<br/>[subClashService.go]"]
end

subgraph group_runtime["VPN runtime"]
  node_vpn_services["VPN protocol services"]
  node_backend["VPN daemon management<br/>[backend.go]"]
  node_xray["Xray process and API<br/>[process.go]"]
  node_awg_module["AmneziaWG kernel module<br/>[main.c]"]
end

subgraph group_operations["Operations and security"]
  node_jobs["Scheduled monitoring"]
  node_ssl["Certificate management<br/>[sslmanager.go]"]
end

node_operator(("Administrator"))
node_clients(("VPN clients"))
node_internet(("Internet services"))

node_operator -->|"uses panel"| node_web
node_web -->|"routes requests"| node_login
node_web -->|"registers routes"| node_other_controllers
node_web -->|"schedules jobs"| node_jobs
node_login -.->|"authenticates users"| node_database
node_server_api -->|"registers routes"| node_web
node_server_api -->|"invokes services"| node_account_services
node_other_controllers -->|"uses services"| node_account_services
node_database -->|"persists records"| node_models
node_subscription_routes -->|"builds responses"| node_subscription_builder
node_subscription_builder -->|"reads account data"| node_models
node_subscription_builder -->|"formats Clash"| node_clash_output
node_clients -->|"fetches configuration"| node_subscription_routes
node_operator -->|"manages services"| node_server_api
node_account_services -.->|"configures protocols"| node_vpn_services
node_vpn_services -.->|"manages daemons"| node_backend
node_backend -->|"serves VPN tunnels"| node_clients
node_vpn_services -->|"sets up module"| node_awg_module
node_vpn_services -->|"configures core"| node_xray
node_xray -->|"routes traffic"| node_internet
node_jobs -->|"checks runtime"| node_xray
node_jobs -->|"records client IPs"| node_database
node_operator -.->|"manages certificates"| node_ssl
node_ssl -->|"requests certificates"| node_internet

click node_web "https://github.com/tonulls/vpn-ui/blob/tonulls/web/web.go"
click node_login "https://github.com/tonulls/vpn-ui/blob/tonulls/web/controller/index.go"
click node_server_api "https://github.com/tonulls/vpn-ui/blob/tonulls/web/controller/server.go"
click node_other_controllers "https://github.com/tonulls/vpn-ui/tree/tonulls/web/controller"
click node_database "https://github.com/tonulls/vpn-ui/blob/tonulls/database/db.go"
click node_models "https://github.com/tonulls/vpn-ui/blob/tonulls/database/model/model.go"
click node_account_services "https://github.com/tonulls/vpn-ui/tree/tonulls/web/service"
click node_subscription_routes "https://github.com/tonulls/vpn-ui/blob/tonulls/sub/subController.go"
click node_subscription_builder "https://github.com/tonulls/vpn-ui/blob/tonulls/sub/subService.go"
click node_clash_output "https://github.com/tonulls/vpn-ui/blob/tonulls/sub/subClashService.go"
click node_vpn_services "https://github.com/tonulls/vpn-ui/tree/tonulls/web/service"
click node_backend "https://github.com/tonulls/vpn-ui/blob/tonulls/backend/backend.go"
click node_xray "https://github.com/tonulls/vpn-ui/blob/tonulls/xray/process.go"
click node_awg_module "https://github.com/tonulls/vpn-ui/blob/tonulls/awgsrc/src/main.c"
click node_jobs "https://github.com/tonulls/vpn-ui/tree/tonulls/web/job"
click node_ssl "https://github.com/tonulls/vpn-ui/blob/tonulls/web/service/sslmanager.go"

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_web,node_login,node_server_api,node_other_controllers,node_database,node_clients toneBlue
class node_models,node_account_services,node_subscription_routes,node_subscription_builder,node_clash_output toneAmber
class node_vpn_services,node_backend,node_xray,node_awg_module toneMint
class node_jobs,node_ssl toneRose
class node_operator,node_internet toneIndigo
```

## Components

### Panel and administration

- [HTTP server](https://github.com/tonulls/vpn-ui/blob/tonulls/web/web.go): `web/web.go`
- [Login and sessions](https://github.com/tonulls/vpn-ui/blob/tonulls/web/controller/index.go): `web/controller/index.go`
- [Server controls](https://github.com/tonulls/vpn-ui/blob/tonulls/web/controller/server.go): `web/controller/server.go`
- [Panel controllers](https://github.com/tonulls/vpn-ui/tree/tonulls/web/controller): `web/controller`
- [Panel database](https://github.com/tonulls/vpn-ui/blob/tonulls/database/db.go): `database/db.go`

### Accounts and subscriptions

- [Account and inbound models](https://github.com/tonulls/vpn-ui/blob/tonulls/database/model/model.go): `database/model/model.go`
- [Account and inbound services](https://github.com/tonulls/vpn-ui/tree/tonulls/web/service): `web/service`
- [Subscription routes](https://github.com/tonulls/vpn-ui/blob/tonulls/sub/subController.go): `sub/subController.go`
- [Subscription generation](https://github.com/tonulls/vpn-ui/blob/tonulls/sub/subService.go): `sub/subService.go`
- [Clash output](https://github.com/tonulls/vpn-ui/blob/tonulls/sub/subClashService.go): `sub/subClashService.go`

### VPN runtime

- [VPN protocol services](https://github.com/tonulls/vpn-ui/tree/tonulls/web/service): `web/service`
- [VPN daemon management](https://github.com/tonulls/vpn-ui/blob/tonulls/backend/backend.go): `backend/backend.go`
- [Xray process and API](https://github.com/tonulls/vpn-ui/blob/tonulls/xray/process.go): `xray/process.go`
- [AmneziaWG kernel module](https://github.com/tonulls/vpn-ui/blob/tonulls/awgsrc/src/main.c): `awgsrc/src/main.c`

### Operations and security

- [Scheduled monitoring](https://github.com/tonulls/vpn-ui/tree/tonulls/web/job): `web/job`
- [Certificate management](https://github.com/tonulls/vpn-ui/blob/tonulls/web/service/sslmanager.go): `web/service/sslmanager.go`

### Other components

- **Administrator**
- **VPN clients**
- **Internet services**

## Connections

- Administrator → HTTP server: uses panel (evidence: `README.md`)
- HTTP server → Login and sessions: routes requests (evidence: `web/web.go`)
- HTTP server → Panel controllers: registers routes (evidence: `web/web.go`)
- HTTP server → Scheduled monitoring: schedules jobs (evidence: `web/web.go`)
- Login and sessions → Panel database: authenticates users
- Server controls → HTTP server: registers routes (evidence: `web/controller/server.go`)
- Server controls → Account and inbound services: invokes services (evidence: `web/controller/server.go`)
- Panel controllers → Account and inbound services: uses services (evidence: `web/controller/server.go`)
- Panel database → Account and inbound models: persists records (evidence: `database/db.go`)
- Subscription routes → Subscription generation: builds responses (evidence: `sub/subController.go`)
- Subscription generation → Account and inbound models: reads account data (evidence: `sub/subService.go`)
- Subscription generation → Clash output: formats Clash (evidence: `sub/subClashService.go`)
- VPN clients → Subscription routes: fetches configuration (evidence: `sub/subController.go`)
- Administrator → Server controls: manages services (evidence: `web/controller/server.go`)
- Account and inbound services → VPN protocol services: configures protocols
- VPN protocol services → VPN daemon management: manages daemons
- VPN daemon management → VPN clients: serves VPN tunnels (evidence: `README.md`)
- VPN protocol services → AmneziaWG kernel module: sets up module (evidence: `README.md`)
- VPN protocol services → Xray process and API: configures core (evidence: `README.md`)
- Xray process and API → Internet services: routes traffic (evidence: `README.md`)
- Scheduled monitoring → Xray process and API: checks runtime (evidence: `web/job/check_client_ip_job.go`)
- Scheduled monitoring → Panel database: records client IPs (evidence: `web/job/check_client_ip_job.go`)
- Administrator → Certificate management: manages certificates
- Certificate management → Internet services: requests certificates (evidence: `web/service/sslmanager.go`)
