# avatardd/zapret-gui architecture

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

- Interactive diagram: https://gitdiagram.com/avatardd/zapret-gui
- Repository: https://github.com/avatardd/zapret-gui

## Overview

Zapret Web-GUI is a router-focused web application for DPI circumvention, VPN/proxy tunnels, and destination-based routing. The user configures a method through the SPA; the Python backend exposes management APIs and coordinates engines and routing. Major documented branches include DPI bypass, multiple tunnel/proxy options, WARP/MASQUE, and unified routing with failover. The graph also shows configuration and logs as shared internal layers. Some API-to-page wiring and unsampled subsystem internals are not shown, so those links are omitted rather than inferred.

Main entry points: [`api/engine_wrapper.py`](https://github.com/avatardd/zapret-gui/blob/main/api/engine_wrapper.py) (Engine API), [`api/routing.py`](https://github.com/avatardd/zapret-gui/blob/main/api/routing.py) (Routing API), [`core/unified/manager.py`](https://github.com/avatardd/zapret-gui/blob/main/core/unified/manager.py) (Unified routing), [`app.py`](https://github.com/avatardd/zapret-gui/blob/main/app.py) (HTTP backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface and API"]
  node_spa["Web SPA<br/>[app.js]"]
  node_routing_ui["Routing UI<br/>[routing_unified.js]"]
  node_zapret_ui["DPI controls<br/>[zapret_manager.js]"]
  node_backend["HTTP backend<br/>[app.py]"]
  node_routing_api["Routing API<br/>[routing.py]"]
  node_engine_api["Engine API<br/>[engine_wrapper.py]"]
end

subgraph group_bypass["DPI bypass"]
  node_dpi_engine["DPI bypass engine<br/>[bypass_engine.py]"]
  node_nfqws["nfqws2 manager<br/>[nfqws_manager.py]"]
  node_geneva["Geneva manager<br/>[geneva_manager.py]"]
end

subgraph group_tunnels["Tunnels and proxies"]
  node_awg["AmneziaWG manager<br/>[awg_manager.py]"]
  node_singbox["sing-box manager<br/>[singbox_manager.py]"]
  node_mihomo["mihomo manager<br/>[mihomo_manager.py]"]
  node_usque["WARP/MASQUE manager<br/>[usque_manager.py]"]
  node_opera["Opera Proxy"]
  node_tgproxy["Telegram Tunnel<br/>[tgproxy_manager.py]"]
end

subgraph group_routing["Unified routing"]
  node_unified["Unified routing<br/>[manager.py]"]
  node_route_manager["Routing manager<br/>[manager.py]"]
  node_route_store[("Rule storage<br/>[storage.py]")]
end

subgraph group_shared["Shared services"]
  node_config[("Settings store<br/>[config_manager.py]")]
  node_logs[("Log buffer<br/>[log_buffer.py]")]
end

node_user(("Router administrator"))

node_user -->|"configures"| node_spa
node_spa -->|"uses backend"| node_backend
node_routing_ui -.-> node_routing_api
node_zapret_ui -.-> node_backend
node_backend -->|"manages engines"| node_engine_api
node_backend -->|"routes requests"| node_routing_api
node_engine_api -->|"imports manager"| node_awg
node_engine_api -->|"imports manager"| node_singbox
node_engine_api -->|"imports manager"| node_mihomo
node_dpi_engine -->|"starts or checks"| node_nfqws
node_dpi_engine -->|"checks engine"| node_geneva
node_routing_api -->|"references manager"| node_awg
node_routing_api -->|"references manager"| node_singbox
node_routing_api -->|"references manager"| node_mihomo
node_routing_api -->|"references manager"| node_usque
node_unified -->|"dispatches to"| node_awg
node_unified -->|"dispatches to"| node_singbox
node_unified -->|"dispatches to"| node_mihomo
node_unified -->|"dispatches to"| node_usque
node_unified -->|"uses routing"| node_route_manager
node_route_manager -->|"loads rules"| node_route_store
node_route_store -->|"reads and saves"| node_config
node_engine_api -.-> node_nfqws
node_engine_api -.-> node_geneva
node_user -.-> node_opera
node_user -.-> node_tgproxy

click node_spa "https://github.com/avatardd/zapret-gui/blob/main/web/js/app.js"
click node_routing_ui "https://github.com/avatardd/zapret-gui/blob/main/web/js/pages/routing_unified.js"
click node_zapret_ui "https://github.com/avatardd/zapret-gui/blob/main/web/js/pages/zapret_manager.js"
click node_backend "https://github.com/avatardd/zapret-gui/blob/main/app.py"
click node_routing_api "https://github.com/avatardd/zapret-gui/blob/main/api/routing.py"
click node_engine_api "https://github.com/avatardd/zapret-gui/blob/main/api/engine_wrapper.py"
click node_dpi_engine "https://github.com/avatardd/zapret-gui/blob/main/core/bypass_engine.py"
click node_nfqws "https://github.com/avatardd/zapret-gui/blob/main/core/nfqws_manager.py"
click node_geneva "https://github.com/avatardd/zapret-gui/blob/main/core/geneva_manager.py"
click node_awg "https://github.com/avatardd/zapret-gui/blob/main/core/awg_manager.py"
click node_singbox "https://github.com/avatardd/zapret-gui/blob/main/core/singbox_manager.py"
click node_mihomo "https://github.com/avatardd/zapret-gui/blob/main/core/mihomo_manager.py"
click node_usque "https://github.com/avatardd/zapret-gui/blob/main/core/usque_manager.py"
click node_opera "https://github.com/avatardd/zapret-gui/blob/main/core/opera_proxy_manager.py"
click node_tgproxy "https://github.com/avatardd/zapret-gui/blob/main/core/tgproxy_manager.py"
click node_unified "https://github.com/avatardd/zapret-gui/blob/main/core/unified/manager.py"
click node_route_manager "https://github.com/avatardd/zapret-gui/blob/main/core/routing/manager.py"
click node_route_store "https://github.com/avatardd/zapret-gui/blob/main/core/routing/storage.py"
click node_config "https://github.com/avatardd/zapret-gui/blob/main/core/config_manager.py"
click node_logs "https://github.com/avatardd/zapret-gui/blob/main/core/log_buffer.py"

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_spa,node_routing_ui,node_zapret_ui,node_backend,node_routing_api,node_engine_api toneBlue
class node_dpi_engine,node_nfqws,node_geneva toneAmber
class node_awg,node_singbox,node_mihomo,node_usque,node_opera,node_tgproxy,node_user toneMint
class node_unified,node_route_manager,node_route_store toneRose
class node_config,node_logs toneIndigo
```

## Components

### Web interface and API

- [Web SPA](https://github.com/avatardd/zapret-gui/blob/main/web/js/app.js): `web/js/app.js`
- [Routing UI](https://github.com/avatardd/zapret-gui/blob/main/web/js/pages/routing_unified.js): `web/js/pages/routing_unified.js`
- [DPI controls](https://github.com/avatardd/zapret-gui/blob/main/web/js/pages/zapret_manager.js): `web/js/pages/zapret_manager.js`
- [HTTP backend](https://github.com/avatardd/zapret-gui/blob/main/app.py): `app.py`
- [Routing API](https://github.com/avatardd/zapret-gui/blob/main/api/routing.py): `api/routing.py`
- [Engine API](https://github.com/avatardd/zapret-gui/blob/main/api/engine_wrapper.py): `api/engine_wrapper.py`

### DPI bypass

- [DPI bypass engine](https://github.com/avatardd/zapret-gui/blob/main/core/bypass_engine.py): `core/bypass_engine.py`
- [nfqws2 manager](https://github.com/avatardd/zapret-gui/blob/main/core/nfqws_manager.py): `core/nfqws_manager.py`
- [Geneva manager](https://github.com/avatardd/zapret-gui/blob/main/core/geneva_manager.py): `core/geneva_manager.py`

### Tunnels and proxies

- [AmneziaWG manager](https://github.com/avatardd/zapret-gui/blob/main/core/awg_manager.py): `core/awg_manager.py`
- [sing-box manager](https://github.com/avatardd/zapret-gui/blob/main/core/singbox_manager.py): `core/singbox_manager.py`
- [mihomo manager](https://github.com/avatardd/zapret-gui/blob/main/core/mihomo_manager.py): `core/mihomo_manager.py`
- [WARP/MASQUE manager](https://github.com/avatardd/zapret-gui/blob/main/core/usque_manager.py): `core/usque_manager.py`
- [Opera Proxy](https://github.com/avatardd/zapret-gui/blob/main/core/opera_proxy_manager.py): `core/opera_proxy_manager.py`
- [Telegram Tunnel](https://github.com/avatardd/zapret-gui/blob/main/core/tgproxy_manager.py): `core/tgproxy_manager.py`

### Unified routing

- [Unified routing](https://github.com/avatardd/zapret-gui/blob/main/core/unified/manager.py): `core/unified/manager.py`
- [Routing manager](https://github.com/avatardd/zapret-gui/blob/main/core/routing/manager.py): `core/routing/manager.py`
- [Rule storage](https://github.com/avatardd/zapret-gui/blob/main/core/routing/storage.py): `core/routing/storage.py`

### Shared services

- [Settings store](https://github.com/avatardd/zapret-gui/blob/main/core/config_manager.py): `core/config_manager.py`
- [Log buffer](https://github.com/avatardd/zapret-gui/blob/main/core/log_buffer.py): `core/log_buffer.py`

### Other components

- **Router administrator**

## Connections

- Router administrator → Web SPA: configures (evidence: `README.md`)
- Web SPA → HTTP backend: uses backend (evidence: `README.md`)
- Routing UI → Routing API
- DPI controls → HTTP backend
- HTTP backend → Engine API: manages engines (evidence: `app.py`)
- HTTP backend → Routing API: routes requests (evidence: `app.py`)
- Engine API → AmneziaWG manager: imports manager (evidence: `api/engine_wrapper.py`)
- Engine API → sing-box manager: imports manager (evidence: `api/engine_wrapper.py`)
- Engine API → mihomo manager: imports manager (evidence: `api/engine_wrapper.py`)
- DPI bypass engine → nfqws2 manager: starts or checks (evidence: `core/bypass_engine.py`)
- DPI bypass engine → Geneva manager: checks engine (evidence: `core/bypass_engine.py`)
- Routing API → AmneziaWG manager: references manager (evidence: `api/routing.py`)
- Routing API → sing-box manager: references manager (evidence: `api/routing.py`)
- Routing API → mihomo manager: references manager (evidence: `api/routing.py`)
- Routing API → WARP/MASQUE manager: references manager (evidence: `api/routing.py`)
- Unified routing → AmneziaWG manager: dispatches to (evidence: `core/unified/manager.py`)
- Unified routing → sing-box manager: dispatches to (evidence: `core/unified/manager.py`)
- Unified routing → mihomo manager: dispatches to (evidence: `core/unified/manager.py`)
- Unified routing → WARP/MASQUE manager: dispatches to (evidence: `core/unified/manager.py`)
- Unified routing → Routing manager: uses routing (evidence: `core/unified/manager.py`)
- Routing manager → Rule storage: loads rules (evidence: `core/routing/manager.py`)
- Rule storage → Settings store: reads and saves (evidence: `core/routing/storage.py`)
- Engine API → nfqws2 manager
- Engine API → Geneva manager
- Router administrator → Opera Proxy
- Router administrator → Telegram Tunnel
