# vpn-vendor/vpn-panel architecture

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

- Interactive diagram: https://gitdiagram.com/vpn-vendor/vpn-panel
- Repository: https://github.com/vpn-vendor/vpn-panel

## Overview

VPN Panel is a self-hosted office VPN-gateway control panel, with both browser and console entry points. The main workflow is to complete first-time network setup, configure gateway services, and inspect their status and diagnostics; backup/restore and security administration are substantial supporting capabilities. The web routing and sampled services show several controller-to-service links, while the agent boundary is visible through RPC clients and the agent server. Some capability links are documented in the README rather than verified in sampled implementation.

Main entry points: [`internal/agentrpc/client.go`](https://github.com/vpn-vendor/vpn-panel/blob/main/internal/agentrpc/client.go) (Agent RPC), [`routes/web.go`](https://github.com/vpn-vendor/vpn-panel/blob/main/routes/web.go) (Web routes), [`app/http/controllers/vpn_controller.go`](https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/vpn_controller.go) (VPN profiles and status), [`app/services/diag/service.go`](https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/diag/service.go) (Discovery and checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Panel and access"]
  node_webui["Browser panel<br/>[app.js]"]
  node_routes["Web routes<br/>[web.go]"]
  node_setup["First-run wizard"]
  node_auth["Login and devices"]
  node_console["Console menu"]
end

subgraph group_network["Gateway configuration"]
  node_networkui["Network setup<br/>[service.go]"]
  node_vpnui["VPN profiles and status<br/>[vpn_controller.go]"]
  node_dhcp["DHCP service<br/>[service.go]"]
  node_dns["DNS service<br/>[service.go]"]
  node_qos["Traffic prioritization<br/>[service.go]"]
end

subgraph group_ops["Operations and safety"]
  node_diagui["Device diagnostics"]
  node_diagservice["Discovery and checks<br/>[service.go]"]
  node_security["Security controls"]
  node_backup["Backup and restore"]
  node_support["Support reports<br/>[service.go]"]
  node_db[("Local application store<br/>[device.go]")]
end

subgraph group_agent["System agent"]
  node_agentrpc["Agent RPC<br/>[client.go]"]
  node_agent["Privileged gateway agent<br/>[main.go]"]
  node_vpnengine["VPN configuration generators<br/>[ovpngen.go]"]
  node_diagnose["Network diagnosis engine<br/>[diagnose.go]"]
end

node_admin(("Office administrator"))
node_external["VPN provider configuration"]

node_admin -->|"uses browser"| node_webui
node_admin -->|"uses console"| node_console
node_webui -.->|"requests pages"| node_routes
node_routes -->|"routes requests"| node_setup
node_routes -->|"routes requests"| node_vpnui
node_routes -->|"routes requests"| node_diagui
node_setup -->|"uses"| node_auth
node_setup -->|"reads network state"| node_networkui
node_vpnui -->|"reads network roles"| node_networkui
node_vpnui -->|"imports profile"| node_external
node_networkui -->|"calls agent"| node_agentrpc
node_vpnui -->|"calls agent"| node_agentrpc
node_diagui -->|"requests checks"| node_diagservice
node_diagservice -->|"builds report"| node_diagnose
node_diagservice -->|"requests probes"| node_agentrpc
node_diagservice -->|"records devices"| node_db
node_security -->|"reads network status"| node_networkui
node_security -->|"uses agent"| node_agentrpc
node_backup -.->|"exports settings"| node_external
node_agentrpc -.->|"sends RPC"| node_agent
node_agent -.->|"applies VPN config"| node_vpnengine
node_console -->|"offers backup commands"| node_backup

click node_webui "https://github.com/vpn-vendor/vpn-panel/blob/main/public/js/app.js"
click node_routes "https://github.com/vpn-vendor/vpn-panel/blob/main/routes/web.go"
click node_setup "https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/setup_controller.go"
click node_auth "https://github.com/vpn-vendor/vpn-panel/tree/main/app/services/auth"
click node_console "https://github.com/vpn-vendor/vpn-panel/tree/main/internal/console"
click node_networkui "https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/network/service.go"
click node_vpnui "https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/vpn_controller.go"
click node_dhcp "https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/dhcp/service.go"
click node_dns "https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/dns/service.go"
click node_qos "https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/qos/service.go"
click node_diagui "https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/diagnostics_controller.go"
click node_diagservice "https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/diag/service.go"
click node_security "https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/security_controller.go"
click node_backup "https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/backup_controller.go"
click node_support "https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/support/service.go"
click node_agentrpc "https://github.com/vpn-vendor/vpn-panel/blob/main/internal/agentrpc/client.go"
click node_agent "https://github.com/vpn-vendor/vpn-panel/blob/main/cmd/vpn-agent/main.go"
click node_vpnengine "https://github.com/vpn-vendor/vpn-panel/blob/main/internal/ovpngen/ovpngen.go"
click node_diagnose "https://github.com/vpn-vendor/vpn-panel/blob/main/internal/diagnose/diagnose.go"
click node_db "https://github.com/vpn-vendor/vpn-panel/blob/main/app/models/device.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_webui,node_routes,node_setup,node_auth,node_console toneBlue
class node_networkui,node_vpnui,node_dhcp,node_dns,node_qos toneAmber
class node_diagui,node_diagservice,node_security,node_backup,node_support,node_db toneMint
class node_agentrpc,node_agent,node_vpnengine,node_diagnose toneRose
class node_admin,node_external toneIndigo
```

## Components

### Panel and access

- [Browser panel](https://github.com/vpn-vendor/vpn-panel/blob/main/public/js/app.js): `public/js/app.js`
- [Web routes](https://github.com/vpn-vendor/vpn-panel/blob/main/routes/web.go): `routes/web.go`
- [First-run wizard](https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/setup_controller.go): `app/http/controllers/setup_controller.go`
- [Login and devices](https://github.com/vpn-vendor/vpn-panel/tree/main/app/services/auth): `app/services/auth`
- [Console menu](https://github.com/vpn-vendor/vpn-panel/tree/main/internal/console): `internal/console`

### Gateway configuration

- [Network setup](https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/network/service.go): `app/services/network/service.go`
- [VPN profiles and status](https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/vpn_controller.go): `app/http/controllers/vpn_controller.go`
- [DHCP service](https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/dhcp/service.go): `app/services/dhcp/service.go`
- [DNS service](https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/dns/service.go): `app/services/dns/service.go`
- [Traffic prioritization](https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/qos/service.go): `app/services/qos/service.go`

### Operations and safety

- [Device diagnostics](https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/diagnostics_controller.go): `app/http/controllers/diagnostics_controller.go`
- [Discovery and checks](https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/diag/service.go): `app/services/diag/service.go`
- [Security controls](https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/security_controller.go): `app/http/controllers/security_controller.go`
- [Backup and restore](https://github.com/vpn-vendor/vpn-panel/blob/main/app/http/controllers/backup_controller.go): `app/http/controllers/backup_controller.go`
- [Support reports](https://github.com/vpn-vendor/vpn-panel/blob/main/app/services/support/service.go): `app/services/support/service.go`
- [Local application store](https://github.com/vpn-vendor/vpn-panel/blob/main/app/models/device.go): `app/models/device.go`

### System agent

- [Agent RPC](https://github.com/vpn-vendor/vpn-panel/blob/main/internal/agentrpc/client.go): `internal/agentrpc/client.go`
- [Privileged gateway agent](https://github.com/vpn-vendor/vpn-panel/blob/main/cmd/vpn-agent/main.go): `cmd/vpn-agent/main.go`
- [VPN configuration generators](https://github.com/vpn-vendor/vpn-panel/blob/main/internal/ovpngen/ovpngen.go): `internal/ovpngen/ovpngen.go`
- [Network diagnosis engine](https://github.com/vpn-vendor/vpn-panel/blob/main/internal/diagnose/diagnose.go): `internal/diagnose/diagnose.go`

### Other components

- **Office administrator**
- **VPN provider configuration**

## Connections

- Office administrator → Browser panel: uses browser
- Office administrator → Console menu: uses console
- Browser panel → Web routes: requests pages
- Web routes → First-run wizard: routes requests (evidence: `routes/web.go`)
- Web routes → VPN profiles and status: routes requests (evidence: `routes/web.go`)
- Web routes → Device diagnostics: routes requests (evidence: `routes/web.go`)
- First-run wizard → Login and devices: uses (evidence: `app/http/controllers/setup_controller.go`)
- First-run wizard → Network setup: reads network state (evidence: `app/http/controllers/setup_controller.go`)
- VPN profiles and status → Network setup: reads network roles (evidence: `app/http/controllers/vpn_controller.go`)
- VPN profiles and status → VPN provider configuration: imports profile (evidence: `app/http/controllers/vpn_controller.go`)
- Network setup → Agent RPC: calls agent (evidence: `app/services/network/service.go`)
- VPN profiles and status → Agent RPC: calls agent
- Device diagnostics → Discovery and checks: requests checks (evidence: `app/http/controllers/diagnostics_controller.go`)
- Discovery and checks → Network diagnosis engine: builds report (evidence: `app/services/diag/service.go`)
- Discovery and checks → Agent RPC: requests probes (evidence: `app/services/diag/service.go`)
- Discovery and checks → Local application store: records devices (evidence: `app/services/diag/service.go`)
- Security controls → Network setup: reads network status (evidence: `app/http/controllers/security_controller.go`)
- Security controls → Agent RPC: uses agent (evidence: `app/http/controllers/security_controller.go`)
- Backup and restore → VPN provider configuration: exports settings
- Agent RPC → Privileged gateway agent: sends RPC
- Privileged gateway agent → VPN configuration generators: applies VPN config
- Console menu → Backup and restore: offers backup commands
