# cypher-monarch/cyphergate architecture

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

- Interactive diagram: https://gitdiagram.com/cypher-monarch/cyphergate
- Repository: https://github.com/cypher-monarch/cyphergate

## Overview

CypherGate is a Linux-first VPNGate desktop client. The documented user journey is to browse or choose a server (or auto-select the fastest), obtain and repair its VPN configuration, then connect through the privileged daemon and OpenVPN; the GUI also monitors connection status. The graph preserves the documented server/cache, themes/settings, tray, and update capabilities. Some subsystem links are documented in the README; source excerpts show IPC setup and VPN configuration handling, but do not expose the complete GUI/daemon call flow.

Main entry points: [`src/ui/main_window.py`](https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/main_window.py) (Main window), [`src/ui/widgets.py`](https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/widgets.py) (UI widgets), [`src/daemon/commands.py`](https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/commands.py) (VPN lifecycle), [`src/vpn/loader.py`](https://github.com/cypher-monarch/cyphergate/blob/main/src/vpn/loader.py) (VPNGate listings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_gui["Main window<br/>[main_window.py]"]
  node_widgets["UI widgets<br/>[widgets.py]"]
  node_tray["Tray and status<br/>[tray.py]"]
  node_icons["Icons<br/>[icons.py]"]
  node_spinner["Connection spinner<br/>[spinner.py]"]
  node_update["Update checker<br/>[update.py]"]
end

subgraph group_servers["Server and VPN"]
  node_serverlist["VPNGate listings<br/>[loader.py]"]
  node_connector["Config repair<br/>[connector.py]"]
  node_vpncache[("Server cache")]
end

subgraph group_backend["Privileged backend"]
  node_ipc["IPC client<br/>[ipc.py]"]
  node_daemon["Daemon dispatcher<br/>[cyphergated.py]"]
  node_socket["Unix socket<br/>[setup.py]"]
  node_validator["Config validator<br/>[validator.py]"]
  node_commands["VPN lifecycle<br/>[commands.py]"]
  node_state["Connection state<br/>[state.py]"]
end

subgraph group_config["Settings and themes"]
  node_settings["Settings manager<br/>[manager.py]"]
  node_defaults["Default settings<br/>[defaults.py]"]
  node_theme["Theme resolution<br/>[theme.py]"]
  node_watcher["Config watcher<br/>[watcher.py]"]
  node_themes["QSS themes"]
end

node_user(("User"))
node_openvpn["OpenVPN"]

node_user -->|"uses"| node_gui
node_gui -->|"creates widgets"| node_widgets
node_widgets -->|"loads icons"| node_icons
node_widgets -->|"creates spinner"| node_spinner
node_gui -.->|"browses servers"| node_serverlist
node_gui -.->|"prepares connection"| node_connector
node_serverlist -.->|"caches listings"| node_vpncache
node_connector -.->|"prepares configuration"| node_openvpn
node_gui -.->|"sends commands"| node_ipc
node_ipc -->|"connects"| node_socket
node_socket -->|"accepts requests"| node_daemon
node_daemon -->|"dispatches actions"| node_commands
node_commands -.->|"validates config"| node_validator
node_commands -.->|"manages lifecycle"| node_openvpn
node_gui -.->|"shows status"| node_tray
node_gui -.->|"loads settings"| node_settings
node_settings -->|"merges defaults"| node_defaults
node_watcher -->|"resolves theme"| node_theme
node_gui -.->|"watches changes"| node_watcher
node_theme -.->|"selects stylesheet"| node_themes
node_gui -.->|"checks version"| node_update

click node_gui "https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/main_window.py"
click node_widgets "https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/widgets.py"
click node_tray "https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/tray.py"
click node_icons "https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/icons.py"
click node_spinner "https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/spinner.py"
click node_serverlist "https://github.com/cypher-monarch/cyphergate/blob/main/src/vpn/loader.py"
click node_connector "https://github.com/cypher-monarch/cyphergate/blob/main/src/vpn/connector.py"
click node_ipc "https://github.com/cypher-monarch/cyphergate/blob/main/src/ipc.py"
click node_daemon "https://github.com/cypher-monarch/cyphergate/blob/main/src/cyphergated.py"
click node_socket "https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/setup.py"
click node_validator "https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/validator.py"
click node_commands "https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/commands.py"
click node_state "https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/state.py"
click node_settings "https://github.com/cypher-monarch/cyphergate/blob/main/src/config/manager.py"
click node_defaults "https://github.com/cypher-monarch/cyphergate/blob/main/src/config/defaults.py"
click node_theme "https://github.com/cypher-monarch/cyphergate/blob/main/src/config/theme.py"
click node_watcher "https://github.com/cypher-monarch/cyphergate/blob/main/src/config/watcher.py"
click node_themes "https://github.com/cypher-monarch/cyphergate/tree/main/src/themes"
click node_update "https://github.com/cypher-monarch/cyphergate/blob/main/src/update.py"
click node_vpncache "https://github.com/cypher-monarch/cyphergate/tree/main/src/vpn"

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_gui,node_widgets,node_tray,node_icons,node_spinner,node_update,node_user toneBlue
class node_serverlist,node_connector,node_vpncache toneAmber
class node_ipc,node_daemon,node_socket,node_validator,node_commands,node_state toneMint
class node_settings,node_defaults,node_theme,node_watcher,node_themes toneRose
class node_openvpn toneIndigo
```

## Components

### Desktop interface

- [Main window](https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/main_window.py): `src/ui/main_window.py`
- [UI widgets](https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/widgets.py): `src/ui/widgets.py`
- [Tray and status](https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/tray.py): `src/ui/tray.py`
- [Icons](https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/icons.py): `src/ui/icons.py`
- [Connection spinner](https://github.com/cypher-monarch/cyphergate/blob/main/src/ui/spinner.py): `src/ui/spinner.py`
- [Update checker](https://github.com/cypher-monarch/cyphergate/blob/main/src/update.py): `src/update.py`

### Server and VPN

- [VPNGate listings](https://github.com/cypher-monarch/cyphergate/blob/main/src/vpn/loader.py): `src/vpn/loader.py`
- [Config repair](https://github.com/cypher-monarch/cyphergate/blob/main/src/vpn/connector.py): `src/vpn/connector.py`
- [Server cache](https://github.com/cypher-monarch/cyphergate/tree/main/src/vpn): `src/vpn`

### Privileged backend

- [IPC client](https://github.com/cypher-monarch/cyphergate/blob/main/src/ipc.py): `src/ipc.py`
- [Daemon dispatcher](https://github.com/cypher-monarch/cyphergate/blob/main/src/cyphergated.py): `src/cyphergated.py`
- [Unix socket](https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/setup.py): `src/daemon/setup.py`
- [Config validator](https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/validator.py): `src/daemon/validator.py`
- [VPN lifecycle](https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/commands.py): `src/daemon/commands.py`
- [Connection state](https://github.com/cypher-monarch/cyphergate/blob/main/src/daemon/state.py): `src/daemon/state.py`

### Settings and themes

- [Settings manager](https://github.com/cypher-monarch/cyphergate/blob/main/src/config/manager.py): `src/config/manager.py`
- [Default settings](https://github.com/cypher-monarch/cyphergate/blob/main/src/config/defaults.py): `src/config/defaults.py`
- [Theme resolution](https://github.com/cypher-monarch/cyphergate/blob/main/src/config/theme.py): `src/config/theme.py`
- [Config watcher](https://github.com/cypher-monarch/cyphergate/blob/main/src/config/watcher.py): `src/config/watcher.py`
- [QSS themes](https://github.com/cypher-monarch/cyphergate/tree/main/src/themes): `src/themes`

### Other components

- **User**
- **OpenVPN**

## Connections

- User → Main window: uses (evidence: `README.md`)
- Main window → UI widgets: creates widgets (evidence: `src/ui/widgets.py`)
- UI widgets → Icons: loads icons (evidence: `src/ui/widgets.py`)
- UI widgets → Connection spinner: creates spinner (evidence: `src/ui/widgets.py`)
- Main window → VPNGate listings: browses servers (evidence: `README.md`)
- Main window → Config repair: prepares connection (evidence: `README.md`)
- VPNGate listings → Server cache: caches listings (evidence: `README.md`)
- Config repair → OpenVPN: prepares configuration (evidence: `README.md`)
- Main window → IPC client: sends commands (evidence: `README.md`)
- IPC client → Unix socket: connects (evidence: `src/ipc.py`)
- Unix socket → Daemon dispatcher: accepts requests (evidence: `src/cyphergated.py`)
- Daemon dispatcher → VPN lifecycle: dispatches actions (evidence: `src/cyphergated.py`)
- VPN lifecycle → Config validator: validates config (evidence: `README.md`)
- VPN lifecycle → OpenVPN: manages lifecycle (evidence: `README.md`)
- Main window → Tray and status: shows status (evidence: `README.md`)
- Main window → Settings manager: loads settings (evidence: `README.md`)
- Settings manager → Default settings: merges defaults (evidence: `src/config/manager.py`)
- Config watcher → Theme resolution: resolves theme (evidence: `src/config/watcher.py`)
- Main window → Config watcher: watches changes (evidence: `README.md`)
- Theme resolution → QSS themes: selects stylesheet (evidence: `README.md`)
- Main window → Update checker: checks version (evidence: `README.md`)
