# hoangtl2/vgn-hub-linux architecture

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

- Interactive diagram: https://gitdiagram.com/hoangtl2/vgn-hub-linux
- Repository: https://github.com/hoangtl2/vgn-hub-linux

## Overview

VGN Hub Linux configures supported VGN mice through either a GTK/WebKit desktop interface or a CLI, with commands translated into the vgn-ry-mouse protocol and Linux hidraw feature reports. The README also highlights device discovery, DPI and performance tuning, button bindings and macros, wallpaper customization, profiles, backup/restore, and Waybar battery output. Several core files are excerpted; README feature claims preserve major capabilities, while unshown relationships are omitted rather than inferred.

Main entry points: [`vgn_hub/gui.py`](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/gui.py) (GTK GUI host), [`vgn_hub/protocols/ry_mouse.py`](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/protocols/ry_mouse.py) (RY mouse protocol), [`vgn_hub/transport.py`](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/transport.py) (HID discovery and transport), [`vgn_hub/cli.py`](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/cli.py) (CLI commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_gui["GTK GUI host<br/>[gui.py]"]
  node_webui["Web UI<br/>[app.js]"]
end

subgraph group_device["Device access"]
  node_registry["Device registry<br/>[registry.py]"]
  node_transport["HID discovery and transport<br/>[transport.py]"]
end

subgraph group_domain["Mouse protocol and state"]
  node_keycodes["Bindings and keycodes<br/>[keycodes.py]"]
  node_factory["Protocol factory<br/>[__init__.py]"]
  node_protocol["RY mouse protocol<br/>[ry_mouse.py]"]
  node_state["Mouse state and backup<br/>[base.py]"]
end

subgraph group_settings["UI settings"]
  node_config[("UI configuration<br/>[config.py]")]
end

node_user(("Mouse user"))
node_hid{{"VGN mouse or receiver"}}
node_waybar(("Waybar"))

node_user -->|"runs commands"| node_cli
node_user -->|"opens GUI"| node_gui
node_webui -->|"sends actions"| node_gui
node_cli -->|"creates client"| node_factory
node_cli -->|"opens transport"| node_transport
node_cli -->|"launches GUI"| node_gui
node_gui -->|"discovers devices"| node_transport
node_gui -->|"creates client"| node_factory
node_gui -->|"manages device"| node_protocol
node_gui -->|"loads settings"| node_config
node_transport -->|"matches devices"| node_registry
node_factory -->|"selects implementation"| node_protocol
node_protocol -->|"sends reports"| node_transport
node_protocol -->|"reads capabilities"| node_registry
node_protocol -->|"encodes bindings"| node_keycodes
node_protocol -->|"builds state"| node_state
node_transport -->|"exchanges reports"| node_hid
node_state -->|"formats battery"| node_waybar
node_webui -.->|"shows controls"| node_user

click node_cli "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/cli.py"
click node_gui "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/gui.py"
click node_webui "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/web/app.js"
click node_config "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/config.py"
click node_keycodes "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/keycodes.py"
click node_registry "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/registry.py"
click node_transport "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/transport.py"
click node_factory "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/protocols/__init__.py"
click node_protocol "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/protocols/ry_mouse.py"
click node_state "https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/protocols/base.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_cli,node_gui,node_webui,node_user toneBlue
class node_registry,node_transport toneAmber
class node_keycodes,node_factory,node_protocol,node_state toneMint
class node_config toneRose
class node_hid,node_waybar toneIndigo
```

## Components

### User interfaces

- [CLI commands](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/cli.py): `vgn_hub/cli.py`
- [GTK GUI host](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/gui.py): `vgn_hub/gui.py`
- [Web UI](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/web/app.js): `vgn_hub/web/app.js`

### Device access

- [Device registry](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/registry.py): `vgn_hub/registry.py`
- [HID discovery and transport](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/transport.py): `vgn_hub/transport.py`

### Mouse protocol and state

- [Bindings and keycodes](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/keycodes.py): `vgn_hub/keycodes.py`
- [Protocol factory](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/protocols/__init__.py): `vgn_hub/protocols/__init__.py`
- [RY mouse protocol](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/protocols/ry_mouse.py): `vgn_hub/protocols/ry_mouse.py`
- [Mouse state and backup](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/protocols/base.py): `vgn_hub/protocols/base.py`

### UI settings

- [UI configuration](https://github.com/hoangtl2/vgn-hub-linux/blob/main/vgn_hub/config.py): `vgn_hub/config.py`

### Other components

- **Mouse user**
- **VGN mouse or receiver**
- **Waybar**

## Connections

- Mouse user → CLI commands: runs commands (evidence: `README.md`)
- Mouse user → GTK GUI host: opens GUI (evidence: `README.md`)
- Web UI → GTK GUI host: sends actions (evidence: `vgn_hub/web/app.js`)
- CLI commands → Protocol factory: creates client (evidence: `vgn_hub/cli.py`)
- CLI commands → HID discovery and transport: opens transport (evidence: `vgn_hub/cli.py`)
- CLI commands → GTK GUI host: launches GUI (evidence: `vgn_hub/cli.py`)
- GTK GUI host → HID discovery and transport: discovers devices (evidence: `vgn_hub/gui.py`)
- GTK GUI host → Protocol factory: creates client (evidence: `vgn_hub/gui.py`)
- GTK GUI host → RY mouse protocol: manages device (evidence: `vgn_hub/gui.py`)
- GTK GUI host → UI configuration: loads settings (evidence: `vgn_hub/gui.py`)
- HID discovery and transport → Device registry: matches devices (evidence: `vgn_hub/transport.py`)
- Protocol factory → RY mouse protocol: selects implementation (evidence: `vgn_hub/protocols/__init__.py`)
- RY mouse protocol → HID discovery and transport: sends reports (evidence: `vgn_hub/protocols/ry_mouse.py`)
- RY mouse protocol → Device registry: reads capabilities (evidence: `vgn_hub/protocols/ry_mouse.py`)
- RY mouse protocol → Bindings and keycodes: encodes bindings (evidence: `vgn_hub/protocols/ry_mouse.py`)
- RY mouse protocol → Mouse state and backup: builds state (evidence: `vgn_hub/protocols/ry_mouse.py`)
- HID discovery and transport → VGN mouse or receiver: exchanges reports (evidence: `README.md`)
- Mouse state and backup → Waybar: formats battery (evidence: `vgn_hub/protocols/base.py`)
- Web UI → Mouse user: shows controls
