# bladeandsoulx/vfang-razer-linux architecture

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

- Interactive diagram: https://gitdiagram.com/bladeandsoulx/vfang-razer-linux
- Repository: https://github.com/bladeandsoulx/vfang-razer-linux

## Overview

VFang is a Linux control center for Razer Blade laptops. Users choose a dashboard or control screen, whose bridge sends requests through the Tauri shell to fangd; the daemon validates and applies desired settings, samples telemetry, and returns status/events for display. The graph also preserves documented power automation, battery care, GPU/display, lighting, and tray/autostart capabilities. Source excerpts expose the bridge, shell, daemon entry and server, and hardware boundary; some feature-specific links are documented in the README rather than verified in sampled implementation.

Main entry points: [`crates/fangd/src/hw/razer.rs`](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/razer.rs) (Razer EC backend), [`app/src/lib/bridge.js`](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src/lib/bridge.js) (UI bridge), [`app/src/screens`](https://github.com/bladeandsoulx/vfang-razer-linux/tree/main/app/src/screens) (Control screens), [`crates/fangd/src/server.rs`](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/server.rs) (Socket API and events)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_screens["Control screens"]
  node_app["App navigation<br/>[App.svelte]"]
  node_stores["UI state stores<br/>[stores.js]"]
end

subgraph group_desktop["Desktop bridge"]
  node_bridge["UI bridge<br/>[bridge.js]"]
  node_tauri["Tauri commands<br/>[main.rs]"]
  node_client["Daemon client<br/>[client.rs]"]
  node_display["Display controls<br/>[display.rs]"]
  node_panel["Panel brightness<br/>[panel.rs]"]
end

subgraph group_daemon["Daemon runtime"]
  node_daemon_entry["Daemon startup<br/>[main.rs]"]
  node_server["Socket API and events<br/>[server.rs]"]
  node_core["Control and safety<br/>[core.rs]"]
  node_peripherals["GPU and monitor controls<br/>[peripherals.rs]"]
  node_gpu["GPU switching<br/>[gpu.rs]"]
  node_ddc["Monitor color controls<br/>[ddc.rs]"]
  node_power["Power automation<br/>[power.rs]"]
  node_process["System command runner<br/>[process.rs]"]
end

subgraph group_hardware["Hardware and telemetry"]
  node_hw_api["Hardware backend interface<br/>[mod.rs]"]
  node_razer["Razer EC backend<br/>[razer.rs]"]
  node_mock["Hardware simulator<br/>[mock.rs]"]
  node_sensors["Thermal and GPU sensors<br/>[sensors.rs]"]
  node_connection["EC discovery<br/>[connection.rs]"]
  node_transport["EC report transport<br/>[transport.rs]"]
  node_lighting_hw["Keyboard lighting<br/>[lighting.rs]"]
  node_runtime_pm["GPU runtime power<br/>[runtime_pm.rs]"]
end

subgraph group_protocol["API and state"]
  node_protocol["Request and response types<br/>[api.rs]"]
  node_packets["EC command packets<br/>[packet.rs]"]
  node_models["Supported Blade models<br/>[models.rs]"]
  node_state[("Persisted desired state<br/>[state.rs]")]
end

node_user(("Laptop user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_screens
node_app -->|"initializes"| node_bridge
node_screens -->|"requests controls"| node_bridge
node_bridge -->|"updates"| node_stores
node_bridge -->|"invokes commands"| node_tauri
node_tauri -->|"uses daemon client"| node_client
node_tauri -->|"delegates display"| node_display
node_tauri -->|"sets brightness"| node_panel
node_client -.->|"sends requests"| node_server
node_daemon_entry -->|"starts API"| node_server
node_daemon_entry -->|"initializes control"| node_core
node_daemon_entry -->|"starts discovery"| node_peripherals
node_server -->|"dispatches commands"| node_core
node_server -->|"dispatches peripheral commands"| node_peripherals
node_server -->|"parses API messages"| node_protocol
node_core -->|"controls and samples"| node_hw_api
node_core -->|"loads and saves"| node_state
node_core -.->|"automates profiles"| node_power
node_hw_api -->|"selects real backend"| node_razer
node_hw_api -->|"selects simulator"| node_mock
node_razer -->|"discovers EC"| node_connection
node_razer -->|"sends reports"| node_transport
node_razer -->|"reads telemetry"| node_sensors
node_razer -->|"applies lighting"| node_lighting_hw
node_sensors -->|"checks runtime power"| node_runtime_pm
node_razer -.->|"builds EC commands"| node_packets
node_peripherals -->|"delegates GPU control"| node_gpu
node_peripherals -->|"delegates monitor control"| node_ddc
node_ddc -->|"runs system tools"| node_process
node_peripherals -.->|"reads power status"| node_power
node_razer -.->|"identifies model"| node_models
node_screens -.->|"controls fans and lighting"| node_bridge
node_screens -.->|"controls GPU and displays"| node_bridge
node_screens -.->|"shows live telemetry"| node_bridge

click node_screens "https://github.com/bladeandsoulx/vfang-razer-linux/tree/main/app/src/screens"
click node_app "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src/App.svelte"
click node_bridge "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src/lib/bridge.js"
click node_tauri "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/main.rs"
click node_client "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/client.rs"
click node_display "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/display.rs"
click node_panel "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/panel.rs"
click node_daemon_entry "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/main.rs"
click node_server "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/server.rs"
click node_core "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/core.rs"
click node_peripherals "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/peripherals.rs"
click node_gpu "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/gpu.rs"
click node_ddc "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/ddc.rs"
click node_power "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/power.rs"
click node_process "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/process.rs"
click node_hw_api "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/mod.rs"
click node_razer "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/razer.rs"
click node_mock "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/mock.rs"
click node_sensors "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/sensors.rs"
click node_connection "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/connection.rs"
click node_transport "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/transport.rs"
click node_lighting_hw "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/lighting.rs"
click node_runtime_pm "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/runtime_pm.rs"
click node_protocol "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fang-protocol/src/api.rs"
click node_packets "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fang-protocol/src/packet.rs"
click node_models "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fang-protocol/src/models.rs"
click node_state "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/state.rs"
click node_stores "https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src/lib/stores.js"

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_screens,node_app,node_stores,node_user toneBlue
class node_bridge,node_tauri,node_client,node_display,node_panel toneAmber
class node_daemon_entry,node_server,node_core,node_peripherals,node_gpu,node_ddc,node_power,node_process toneMint
class node_hw_api,node_razer,node_mock,node_sensors,node_connection,node_transport,node_lighting_hw,node_runtime_pm toneRose
class node_protocol,node_packets,node_models,node_state toneIndigo
```

## Components

### User interface

- [Control screens](https://github.com/bladeandsoulx/vfang-razer-linux/tree/main/app/src/screens): `app/src/screens`
- [App navigation](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src/App.svelte): `app/src/App.svelte`
- [UI state stores](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src/lib/stores.js): `app/src/lib/stores.js`

### Desktop bridge

- [UI bridge](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src/lib/bridge.js): `app/src/lib/bridge.js`
- [Tauri commands](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/main.rs): `app/src-tauri/src/main.rs`
- [Daemon client](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/client.rs): `app/src-tauri/src/client.rs`
- [Display controls](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/display.rs): `app/src-tauri/src/display.rs`
- [Panel brightness](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/app/src-tauri/src/panel.rs): `app/src-tauri/src/panel.rs`

### Daemon runtime

- [Daemon startup](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/main.rs): `crates/fangd/src/main.rs`
- [Socket API and events](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/server.rs): `crates/fangd/src/server.rs`
- [Control and safety](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/core.rs): `crates/fangd/src/core.rs`
- [GPU and monitor controls](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/peripherals.rs): `crates/fangd/src/peripherals.rs`
- [GPU switching](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/gpu.rs): `crates/fangd/src/gpu.rs`
- [Monitor color controls](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/ddc.rs): `crates/fangd/src/ddc.rs`
- [Power automation](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/power.rs): `crates/fangd/src/power.rs`
- [System command runner](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/process.rs): `crates/fangd/src/process.rs`

### Hardware and telemetry

- [Hardware backend interface](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/mod.rs): `crates/fangd/src/hw/mod.rs`
- [Razer EC backend](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/razer.rs): `crates/fangd/src/hw/razer.rs`
- [Hardware simulator](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/mock.rs): `crates/fangd/src/hw/mock.rs`
- [Thermal and GPU sensors](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/sensors.rs): `crates/fangd/src/hw/sensors.rs`
- [EC discovery](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/connection.rs): `crates/fangd/src/hw/connection.rs`
- [EC report transport](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/transport.rs): `crates/fangd/src/hw/transport.rs`
- [Keyboard lighting](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/lighting.rs): `crates/fangd/src/hw/lighting.rs`
- [GPU runtime power](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/hw/runtime_pm.rs): `crates/fangd/src/hw/runtime_pm.rs`

### API and state

- [Request and response types](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fang-protocol/src/api.rs): `crates/fang-protocol/src/api.rs`
- [EC command packets](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fang-protocol/src/packet.rs): `crates/fang-protocol/src/packet.rs`
- [Supported Blade models](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fang-protocol/src/models.rs): `crates/fang-protocol/src/models.rs`
- [Persisted desired state](https://github.com/bladeandsoulx/vfang-razer-linux/blob/main/crates/fangd/src/state.rs): `crates/fangd/src/state.rs`

### Other components

- **Laptop user**

## Connections

- Laptop user → App navigation: uses (evidence: `README.md`)
- App navigation → Control screens: routes to (evidence: `app/src/App.svelte`)
- App navigation → UI bridge: initializes (evidence: `app/src/App.svelte`)
- Control screens → UI bridge: requests controls (evidence: `app/src/screens/Settings.svelte`)
- UI bridge → UI state stores: updates (evidence: `app/src/lib/bridge.js`)
- UI bridge → Tauri commands: invokes commands (evidence: `app/src/lib/bridge.js`)
- Tauri commands → Daemon client: uses daemon client (evidence: `app/src-tauri/src/main.rs`)
- Tauri commands → Display controls: delegates display (evidence: `app/src-tauri/src/main.rs`)
- Tauri commands → Panel brightness: sets brightness (evidence: `app/src-tauri/src/main.rs`)
- Daemon client → Socket API and events: sends requests
- Daemon startup → Socket API and events: starts API (evidence: `crates/fangd/src/main.rs`)
- Daemon startup → Control and safety: initializes control (evidence: `crates/fangd/src/main.rs`)
- Daemon startup → GPU and monitor controls: starts discovery (evidence: `crates/fangd/src/main.rs`)
- Socket API and events → Control and safety: dispatches commands (evidence: `crates/fangd/src/server.rs`)
- Socket API and events → GPU and monitor controls: dispatches peripheral commands (evidence: `crates/fangd/src/server.rs`)
- Socket API and events → Request and response types: parses API messages (evidence: `crates/fangd/src/server.rs`)
- Control and safety → Hardware backend interface: controls and samples (evidence: `crates/fangd/src/core.rs`)
- Control and safety → Persisted desired state: loads and saves (evidence: `crates/fangd/src/core.rs`)
- Control and safety → Power automation: automates profiles
- Hardware backend interface → Razer EC backend: selects real backend (evidence: `crates/fangd/src/hw/mod.rs`)
- Hardware backend interface → Hardware simulator: selects simulator (evidence: `crates/fangd/src/hw/mod.rs`)
- Razer EC backend → EC discovery: discovers EC (evidence: `crates/fangd/src/hw/razer.rs`)
- Razer EC backend → EC report transport: sends reports (evidence: `crates/fangd/src/hw/razer.rs`)
- Razer EC backend → Thermal and GPU sensors: reads telemetry (evidence: `crates/fangd/src/hw/razer.rs`)
- Razer EC backend → Keyboard lighting: applies lighting (evidence: `crates/fangd/src/hw/razer.rs`)
- Thermal and GPU sensors → GPU runtime power: checks runtime power (evidence: `crates/fangd/src/hw/sensors.rs`)
- Razer EC backend → EC command packets: builds EC commands
- GPU and monitor controls → GPU switching: delegates GPU control (evidence: `crates/fangd/src/peripherals.rs`)
- GPU and monitor controls → Monitor color controls: delegates monitor control (evidence: `crates/fangd/src/peripherals.rs`)
- Monitor color controls → System command runner: runs system tools (evidence: `crates/fangd/src/ddc.rs`)
- GPU and monitor controls → Power automation: reads power status
- Razer EC backend → Supported Blade models: identifies model
- Control screens → UI bridge: controls fans and lighting (evidence: `README.md`)
- Control screens → UI bridge: controls GPU and displays (evidence: `README.md`)
- Control screens → UI bridge: shows live telemetry (evidence: `README.md`)
