# anysda/vpn2 architecture

> Architecture diagram of the GitHub repository anysda/vpn2, 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/anysda/vpn2
- Repository: https://github.com/anysda/vpn2

## Overview

anysda-vpn2 is a self-hosted VPN service with a Nuxt administration panel, a Telegram bot, and entry/exit-node routing. The main user workflow is: an administrator creates a client and device, provisions a WireGuard, OpenVPN, or IKEv2 configuration, and the client connects through the Russian entry node; traffic is routed directly or through an exit. The graph also includes DNS filtering, monitoring, manual routes, and bot self-service. Several links reflect README-level architecture; unsampled implementations are represented only where the tree supports a path.

Main entry points: [`app/server/utils/client-ops.ts`](https://github.com/anysda/vpn2/blob/main/app/server/utils/client-ops.ts) (Client API), [`infra/lib/gen-router-config.py`](https://github.com/anysda/vpn2/blob/main/infra/lib/gen-router-config.py) (Entry-node VPN), [`app/server/utils/auth.ts`](https://github.com/anysda/vpn2/blob/main/app/server/utils/auth.ts) (Panel authentication), [`app/server/database/client.ts`](https://github.com/anysda/vpn2/blob/main/app/server/database/client.ts) (Panel database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_panel["Web panel"]
  node_panelui["Admin panel<br/>[clients.vue]"]
  node_auth["Panel authentication<br/>[auth.ts]"]
  node_database[("Panel database<br/>[client.ts]")]
  node_schema["Data model<br/>[schema.ts]"]
  node_sso["SSO integration<br/>[sso.ts]"]
end

subgraph group_clients["Client access"]
  node_clientsapi["Client API<br/>[client-ops.ts]"]
  node_wireguard["WireGuard provisioning<br/>[wireguard.ts]"]
  node_openvpn["OpenVPN provisioning<br/>[openvpn.ts]"]
  node_ikev2["IKEv2 provisioning<br/>[ikev2.ts]"]
  node_botapi["Bot API<br/>[bot-api.ts]"]
end

subgraph group_routing["VPN routing"]
  node_entry{{"Entry-node VPN"}}
  node_failover["Exit failover"]
  node_exits{{"Exit nodes"}}
  node_manualroutes["Manual routes<br/>[routes-sync.ts]"]
end

subgraph group_operations["Operations"]
  node_bot["Telegram bot<br/>[bot.py]"]
  node_dns["DNS filtering<br/>[dns-settings.ts]"]
  node_adguard["AdGuard Home"]
  node_monitoring["Node monitoring<br/>[vm-client.ts]"]
  node_events["Panel events<br/>[events.ts]"]
end

node_admin(("Administrator"))
node_vpnuser(("VPN client"))
node_telegramuser(("Telegram user"))

node_admin -->|"manages clients"| node_panelui
node_panelui -->|"authenticates requests"| node_auth
node_clientsapi -.->|"requires authentication"| node_auth
node_clientsapi -->|"reads and writes"| node_database
node_database -->|"uses schema"| node_schema
node_clientsapi -->|"syncs configuration"| node_wireguard
node_clientsapi -->|"syncs configuration"| node_openvpn
node_clientsapi -->|"provisions access"| node_ikev2
node_admin -->|"manages clients"| node_bot
node_telegramuser -->|"requests self-service"| node_bot
node_bot -.->|"calls panel API"| node_botapi
node_botapi -->|"reads client data"| node_database
node_vpnuser -->|"connects by VPN"| node_entry
node_entry -->|"routes foreign traffic"| node_exits
node_entry -->|"uses exit selection"| node_failover
node_admin -->|"configures routes"| node_manualroutes
node_manualroutes -->|"writes route file"| node_entry
node_entry -.->|"uses DNS settings"| node_dns
node_dns -->|"queries and configures"| node_adguard
node_admin -->|"views node status"| node_monitoring
node_clientsapi -->|"records client events"| node_events
node_auth -->|"uses SSO support"| node_sso

click node_panelui "https://github.com/anysda/vpn2/blob/main/app/app/pages/clients.vue"
click node_auth "https://github.com/anysda/vpn2/blob/main/app/server/utils/auth.ts"
click node_database "https://github.com/anysda/vpn2/blob/main/app/server/database/client.ts"
click node_schema "https://github.com/anysda/vpn2/blob/main/app/server/database/schema.ts"
click node_clientsapi "https://github.com/anysda/vpn2/blob/main/app/server/utils/client-ops.ts"
click node_wireguard "https://github.com/anysda/vpn2/blob/main/app/server/utils/wireguard.ts"
click node_openvpn "https://github.com/anysda/vpn2/blob/main/app/server/utils/openvpn.ts"
click node_ikev2 "https://github.com/anysda/vpn2/blob/main/app/server/utils/ikev2.ts"
click node_bot "https://github.com/anysda/vpn2/blob/main/telegram/bot.py"
click node_botapi "https://github.com/anysda/vpn2/blob/main/app/server/utils/bot-api.ts"
click node_entry "https://github.com/anysda/vpn2/blob/main/infra/lib/gen-router-config.py"
click node_failover "https://github.com/anysda/vpn2/blob/main/infra/lib/failover-watchdog.py"
click node_manualroutes "https://github.com/anysda/vpn2/blob/main/app/server/utils/routes-sync.ts"
click node_dns "https://github.com/anysda/vpn2/blob/main/app/server/utils/dns-settings.ts"
click node_monitoring "https://github.com/anysda/vpn2/blob/main/app/server/utils/vm-client.ts"
click node_events "https://github.com/anysda/vpn2/blob/main/app/server/utils/events.ts"
click node_sso "https://github.com/anysda/vpn2/blob/main/app/server/utils/sso.ts"

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_panelui,node_auth,node_database,node_schema,node_sso,node_vpnuser,node_telegramuser toneBlue
class node_clientsapi,node_wireguard,node_openvpn,node_ikev2,node_botapi toneAmber
class node_entry,node_failover,node_exits,node_manualroutes toneMint
class node_bot,node_dns,node_adguard,node_monitoring,node_events toneRose
class node_admin toneIndigo
```

## Components

### Web panel

- [Admin panel](https://github.com/anysda/vpn2/blob/main/app/app/pages/clients.vue): `app/app/pages/clients.vue`
- [Panel authentication](https://github.com/anysda/vpn2/blob/main/app/server/utils/auth.ts): `app/server/utils/auth.ts`
- [Panel database](https://github.com/anysda/vpn2/blob/main/app/server/database/client.ts): `app/server/database/client.ts`
- [Data model](https://github.com/anysda/vpn2/blob/main/app/server/database/schema.ts): `app/server/database/schema.ts`
- [SSO integration](https://github.com/anysda/vpn2/blob/main/app/server/utils/sso.ts): `app/server/utils/sso.ts`

### Client access

- [Client API](https://github.com/anysda/vpn2/blob/main/app/server/utils/client-ops.ts): `app/server/utils/client-ops.ts`
- [WireGuard provisioning](https://github.com/anysda/vpn2/blob/main/app/server/utils/wireguard.ts): `app/server/utils/wireguard.ts`
- [OpenVPN provisioning](https://github.com/anysda/vpn2/blob/main/app/server/utils/openvpn.ts): `app/server/utils/openvpn.ts`
- [IKEv2 provisioning](https://github.com/anysda/vpn2/blob/main/app/server/utils/ikev2.ts): `app/server/utils/ikev2.ts`
- [Bot API](https://github.com/anysda/vpn2/blob/main/app/server/utils/bot-api.ts): `app/server/utils/bot-api.ts`

### VPN routing

- [Entry-node VPN](https://github.com/anysda/vpn2/blob/main/infra/lib/gen-router-config.py): `infra/lib/gen-router-config.py`
- [Exit failover](https://github.com/anysda/vpn2/blob/main/infra/lib/failover-watchdog.py): `infra/lib/failover-watchdog.py`
- **Exit nodes**
- [Manual routes](https://github.com/anysda/vpn2/blob/main/app/server/utils/routes-sync.ts): `app/server/utils/routes-sync.ts`

### Operations

- [Telegram bot](https://github.com/anysda/vpn2/blob/main/telegram/bot.py): `telegram/bot.py`
- [DNS filtering](https://github.com/anysda/vpn2/blob/main/app/server/utils/dns-settings.ts): `app/server/utils/dns-settings.ts`
- **AdGuard Home**
- [Node monitoring](https://github.com/anysda/vpn2/blob/main/app/server/utils/vm-client.ts): `app/server/utils/vm-client.ts`
- [Panel events](https://github.com/anysda/vpn2/blob/main/app/server/utils/events.ts): `app/server/utils/events.ts`

### Other components

- **Administrator**
- **VPN client**
- **Telegram user**

## Connections

- Administrator → Admin panel: manages clients (evidence: `README.md`)
- Admin panel → Panel authentication: authenticates requests
- Client API → Panel authentication: requires authentication
- Client API → Panel database: reads and writes (evidence: `app/server/utils/client-ops.ts`)
- Panel database → Data model: uses schema (evidence: `app/server/database/client.ts`)
- Client API → WireGuard provisioning: syncs configuration (evidence: `app/server/utils/client-ops.ts`)
- Client API → OpenVPN provisioning: syncs configuration (evidence: `app/server/utils/client-ops.ts`)
- Client API → IKEv2 provisioning: provisions access (evidence: `app/server/utils/client-ops.ts`)
- Administrator → Telegram bot: manages clients (evidence: `README.md`)
- Telegram user → Telegram bot: requests self-service (evidence: `README.md`)
- Telegram bot → Bot API: calls panel API
- Bot API → Panel database: reads client data (evidence: `app/server/utils/bot-api.ts`)
- VPN client → Entry-node VPN: connects by VPN (evidence: `README.md`)
- Entry-node VPN → Exit nodes: routes foreign traffic (evidence: `README.md`)
- Entry-node VPN → Exit failover: uses exit selection (evidence: `README.md`)
- Administrator → Manual routes: configures routes (evidence: `README.md`)
- Manual routes → Entry-node VPN: writes route file (evidence: `app/server/utils/routes-sync.ts`)
- Entry-node VPN → DNS filtering: uses DNS settings
- DNS filtering → AdGuard Home: queries and configures
- Administrator → Node monitoring: views node status (evidence: `README.md`)
- Client API → Panel events: records client events (evidence: `app/server/utils/client-ops.ts`)
- Panel authentication → SSO integration: uses SSO support (evidence: `app/server/utils/auth.ts`)
