# amurcanov/csqtt architecture

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

- Interactive diagram: https://gitdiagram.com/amurcanov/csqtt
- Repository: https://github.com/amurcanov/csqtt

## Overview

CSQTT is an Android client and Rust server for a protected tunnel carried over TURN/RTP. The user configures a connection in the app, starts it, and routes device traffic through the tunnel; server-side components provide the proxy dataplane and administrative web panel. The graph includes the client’s VPN boundary, Rust runtime, server control/dataplane, and shared framing. Some cross-process wiring and unsampled subsystems are shown only where documented; dashed links mark unverified integration.

Main entry points: [`rust-client/main.rs`](https://github.com/amurcanov/csqtt/blob/main/rust-client/main.rs) (Client runtime), [`app/src/main/java/com/csqtt/client/TunnelManager.kt`](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/TunnelManager.kt) (Tunnel lifecycle), [`rust-server/main.rs`](https://github.com/amurcanov/csqtt/blob/main/rust-server/main.rs) (Server runtime), [`rust-server/protocol.rs`](https://github.com/amurcanov/csqtt/blob/main/rust-server/protocol.rs) (Protocol service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android app"]
  node_main_ui["App screens<br/>[MainActivity.kt]"]
  node_settings[("Connection settings<br/>[SettingsStore.kt]")]
  node_tunnel_mgr["Tunnel lifecycle<br/>[TunnelManager.kt]"]
  node_tunnel_service["Tunnel service<br/>[TunnelService.kt]"]
  node_vpn_service["Android VPN<br/>[TunVpnService.kt]"]
  node_captcha["Captcha WebView"]
  node_vk_auth["VK authentication"]
end

subgraph group_client["Rust client"]
  node_client_entry["Client runtime<br/>[main.rs]"]
  node_client_auth["Credential auth<br/>[auth.rs]"]
  node_client_dispatch["Packet dispatcher<br/>[dispatcher.rs]"]
  node_client_session["Session handling<br/>[session.rs]"]
  node_client_turn["TURN transport<br/>[turn_core.rs]"]
  node_client_tun["Client TUN<br/>[tun.rs]"]
end

subgraph group_server["Rust server"]
  node_server_entry["Server runtime<br/>[main.rs]"]
  node_server_protocol["Protocol service<br/>[protocol.rs]"]
  node_server_dataplane["Server dataplane<br/>[dataplane.rs]"]
  node_server_proxy["Proxy routing<br/>[proxy_route.rs]"]
  node_server_tproxy["Transparent proxy<br/>[tproxy.rs]"]
  node_server_model[("Server state<br/>[model.rs]")]
  node_web_panel["Admin web panel<br/>[web_panel.rs]"]
end

subgraph group_shared["Shared transport"]
  node_flow_frame["Flow framing<br/>[flow_frame.rs]"]
end

node_user(("User"))
node_turn_network{{"TURN/RTP network"}}

node_user -->|"configures"| node_main_ui
node_main_ui -->|"stores settings"| node_settings
node_main_ui -->|"starts tunnel"| node_tunnel_mgr
node_tunnel_mgr -->|"reads settings"| node_settings
node_tunnel_service -->|"starts lifecycle"| node_tunnel_mgr
node_tunnel_service -->|"starts VPN"| node_vpn_service
node_tunnel_mgr -->|"uses captcha"| node_captcha
node_user -.->|"authenticates"| node_vk_auth
node_tunnel_mgr -.->|"launches client"| node_client_entry
node_client_entry -->|"uses auth"| node_client_auth
node_client_entry -->|"starts dispatcher"| node_client_dispatch
node_client_entry -->|"starts sessions"| node_client_session
node_client_entry -->|"uses TUN"| node_client_tun
node_client_entry -->|"uses TURN"| node_client_turn
node_client_turn -.->|"sends tunnel traffic"| node_turn_network
node_turn_network -.->|"reaches server"| node_server_entry
node_server_entry -->|"starts protocol"| node_server_protocol
node_server_entry -->|"starts dataplane"| node_server_dataplane
node_server_entry -->|"starts panel"| node_web_panel
node_server_protocol -->|"uses state"| node_server_model
node_server_dataplane -->|"uses protocol"| node_server_protocol
node_server_proxy -->|"uses state"| node_server_model
node_server_proxy -->|"uses proxy"| node_server_tproxy
node_web_panel -->|"manages credentials"| node_server_protocol
node_web_panel -->|"reads state"| node_server_model
node_client_dispatch -.->|"uses framing"| node_flow_frame
node_server_dataplane -.->|"uses framing"| node_flow_frame

click node_main_ui "https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/MainActivity.kt"
click node_settings "https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/SettingsStore.kt"
click node_tunnel_mgr "https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/TunnelManager.kt"
click node_tunnel_service "https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/TunnelService.kt"
click node_vpn_service "https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/TunVpnService.kt"
click node_captcha "https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/CaptchaWebViewManager.kt"
click node_vk_auth "https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/VkAuthWebViewManager.kt"
click node_client_entry "https://github.com/amurcanov/csqtt/blob/main/rust-client/main.rs"
click node_client_auth "https://github.com/amurcanov/csqtt/blob/main/rust-client/auth.rs"
click node_client_dispatch "https://github.com/amurcanov/csqtt/blob/main/rust-client/dispatcher.rs"
click node_client_session "https://github.com/amurcanov/csqtt/blob/main/rust-client/session.rs"
click node_client_turn "https://github.com/amurcanov/csqtt/blob/main/rust-client/turn_core.rs"
click node_client_tun "https://github.com/amurcanov/csqtt/blob/main/rust-client/tun.rs"
click node_server_entry "https://github.com/amurcanov/csqtt/blob/main/rust-server/main.rs"
click node_server_protocol "https://github.com/amurcanov/csqtt/blob/main/rust-server/protocol.rs"
click node_server_dataplane "https://github.com/amurcanov/csqtt/blob/main/rust-server/dataplane.rs"
click node_server_proxy "https://github.com/amurcanov/csqtt/blob/main/rust-server/proxy_route.rs"
click node_server_tproxy "https://github.com/amurcanov/csqtt/blob/main/rust-server/tproxy.rs"
click node_server_model "https://github.com/amurcanov/csqtt/blob/main/rust-server/model.rs"
click node_web_panel "https://github.com/amurcanov/csqtt/blob/main/rust-server/web_panel.rs"
click node_flow_frame "https://github.com/amurcanov/csqtt/blob/main/shared/flow_frame.rs"

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_main_ui,node_settings,node_tunnel_mgr,node_tunnel_service,node_vpn_service,node_captcha,node_vk_auth,node_user toneBlue
class node_client_entry,node_client_auth,node_client_dispatch,node_client_session,node_client_turn,node_client_tun toneAmber
class node_server_entry,node_server_protocol,node_server_dataplane,node_server_proxy,node_server_tproxy,node_server_model,node_web_panel toneMint
class node_flow_frame toneRose
class node_turn_network toneIndigo
```

## Components

### Android app

- [App screens](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/MainActivity.kt): `app/src/main/java/com/csqtt/client/MainActivity.kt`
- [Connection settings](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/SettingsStore.kt): `app/src/main/java/com/csqtt/client/SettingsStore.kt`
- [Tunnel lifecycle](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/TunnelManager.kt): `app/src/main/java/com/csqtt/client/TunnelManager.kt`
- [Tunnel service](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/TunnelService.kt): `app/src/main/java/com/csqtt/client/TunnelService.kt`
- [Android VPN](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/TunVpnService.kt): `app/src/main/java/com/csqtt/client/TunVpnService.kt`
- [Captcha WebView](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/CaptchaWebViewManager.kt): `app/src/main/java/com/csqtt/client/CaptchaWebViewManager.kt`
- [VK authentication](https://github.com/amurcanov/csqtt/blob/main/app/src/main/java/com/csqtt/client/VkAuthWebViewManager.kt): `app/src/main/java/com/csqtt/client/VkAuthWebViewManager.kt`

### Rust client

- [Client runtime](https://github.com/amurcanov/csqtt/blob/main/rust-client/main.rs): `rust-client/main.rs`
- [Credential auth](https://github.com/amurcanov/csqtt/blob/main/rust-client/auth.rs): `rust-client/auth.rs`
- [Packet dispatcher](https://github.com/amurcanov/csqtt/blob/main/rust-client/dispatcher.rs): `rust-client/dispatcher.rs`
- [Session handling](https://github.com/amurcanov/csqtt/blob/main/rust-client/session.rs): `rust-client/session.rs`
- [TURN transport](https://github.com/amurcanov/csqtt/blob/main/rust-client/turn_core.rs): `rust-client/turn_core.rs`
- [Client TUN](https://github.com/amurcanov/csqtt/blob/main/rust-client/tun.rs): `rust-client/tun.rs`

### Rust server

- [Server runtime](https://github.com/amurcanov/csqtt/blob/main/rust-server/main.rs): `rust-server/main.rs`
- [Protocol service](https://github.com/amurcanov/csqtt/blob/main/rust-server/protocol.rs): `rust-server/protocol.rs`
- [Server dataplane](https://github.com/amurcanov/csqtt/blob/main/rust-server/dataplane.rs): `rust-server/dataplane.rs`
- [Proxy routing](https://github.com/amurcanov/csqtt/blob/main/rust-server/proxy_route.rs): `rust-server/proxy_route.rs`
- [Transparent proxy](https://github.com/amurcanov/csqtt/blob/main/rust-server/tproxy.rs): `rust-server/tproxy.rs`
- [Server state](https://github.com/amurcanov/csqtt/blob/main/rust-server/model.rs): `rust-server/model.rs`
- [Admin web panel](https://github.com/amurcanov/csqtt/blob/main/rust-server/web_panel.rs): `rust-server/web_panel.rs`

### Shared transport

- [Flow framing](https://github.com/amurcanov/csqtt/blob/main/shared/flow_frame.rs): `shared/flow_frame.rs`

### Other components

- **User**
- **TURN/RTP network**

## Connections

- User → App screens: configures
- App screens → Connection settings: stores settings (evidence: `app/src/main/java/com/csqtt/client/MainActivity.kt`)
- App screens → Tunnel lifecycle: starts tunnel (evidence: `app/src/main/java/com/csqtt/client/MainActivity.kt`)
- Tunnel lifecycle → Connection settings: reads settings (evidence: `app/src/main/java/com/csqtt/client/TunnelManager.kt`)
- Tunnel service → Tunnel lifecycle: starts lifecycle (evidence: `app/src/main/java/com/csqtt/client/TunnelService.kt`)
- Tunnel service → Android VPN: starts VPN (evidence: `app/src/main/java/com/csqtt/client/TunnelService.kt`)
- Tunnel lifecycle → Captcha WebView: uses captcha (evidence: `app/src/main/java/com/csqtt/client/TunnelManager.kt`)
- User → VK authentication: authenticates
- Tunnel lifecycle → Client runtime: launches client
- Client runtime → Credential auth: uses auth (evidence: `rust-client/main.rs`)
- Client runtime → Packet dispatcher: starts dispatcher (evidence: `rust-client/main.rs`)
- Client runtime → Session handling: starts sessions (evidence: `rust-client/main.rs`)
- Client runtime → Client TUN: uses TUN (evidence: `rust-client/main.rs`)
- Client runtime → TURN transport: uses TURN (evidence: `rust-client/main.rs`)
- TURN transport → TURN/RTP network: sends tunnel traffic
- TURN/RTP network → Server runtime: reaches server
- Server runtime → Protocol service: starts protocol (evidence: `rust-server/main.rs`)
- Server runtime → Server dataplane: starts dataplane (evidence: `rust-server/main.rs`)
- Server runtime → Admin web panel: starts panel (evidence: `rust-server/main.rs`)
- Protocol service → Server state: uses state (evidence: `rust-server/protocol.rs`)
- Server dataplane → Protocol service: uses protocol (evidence: `rust-server/dataplane.rs`)
- Proxy routing → Server state: uses state (evidence: `rust-server/proxy_route.rs`)
- Proxy routing → Transparent proxy: uses proxy (evidence: `rust-server/proxy_route.rs`)
- Admin web panel → Protocol service: manages credentials (evidence: `rust-server/web_panel.rs`)
- Admin web panel → Server state: reads state (evidence: `rust-server/web_panel.rs`)
- Packet dispatcher → Flow framing: uses framing
- Server dataplane → Flow framing: uses framing
