# hans-kramer/qcctl architecture

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

- Interactive diagram: https://gitdiagram.com/hans-kramer/qcctl
- Repository: https://github.com/hans-kramer/qcctl

## Overview

qcctl is a board-specific CLI and daemon for applying CPU, GPU, thermal, and fan policy to the Ventuno Q. Operators select or inspect profiles through the CLI; configuration is validated against discovered hardware before writes are planned and committed, with snapshots supporting reset and profile switching. The daemon applies a startup profile, consumes telemetry from qcstats, and manages fan strategies and control requests. The README describes additional fan and profile capabilities; connections not evidenced by the excerpts are omitted. I have not inspected unsampled source.

Main entry points: [`src/daemon.c`](https://github.com/hans-kramer/qcctl/blob/main/src/daemon.c) (qcctld daemon), [`src/main.c`](https://github.com/hans-kramer/qcctl/blob/main/src/main.c) (qcctl CLI), [`src/apply.c`](https://github.com/hans-kramer/qcctl/blob/main/src/apply.c) (Apply and rollback), [`src/surface.c`](https://github.com/hans-kramer/qcctl/blob/main/src/surface.c) (Hardware discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_profile["Profiles and apply"]
  node_cli["qcctl CLI<br/>[main.c]"]
  node_profile_config["Profile parser<br/>[config.c]"]
  node_profile_check["Profile validator<br/>[profile_check.c]"]
  node_apply["Apply and rollback<br/>[apply.c]"]
end

subgraph group_daemon["Daemon and fan"]
  node_daemon["qcctld daemon<br/>[daemon.c]"]
  node_fan_strategy["Fan strategies<br/>[fancurve.c]"]
  node_fan_ownership["Fan ownership<br/>[fanown.c]"]
  node_fan_baseline["Fan baseline<br/>[fanbase.c]"]
  node_control_socket["Control socket<br/>[control.c]"]
  node_telemetry_reader["Telemetry reader<br/>[stats.c]"]
end

subgraph group_hardware["Board interface"]
  node_surface["Hardware discovery<br/>[surface.c]"]
end

subgraph group_runtime["Shared runtime"]
  node_io["Filesystem I/O<br/>[io.c]"]
  node_environment["Environment ID<br/>[envid.c]"]
end

node_operator(("Operator"))
node_qcstats["qcstats sampler"]
node_sysfs[("Board sysfs")]

node_operator -->|"invokes"| node_cli
node_cli -->|"loads"| node_profile_config
node_cli -->|"discovers"| node_surface
node_cli -->|"checks"| node_profile_check
node_profile_check -->|"validates"| node_profile_config
node_profile_check -->|"checks against"| node_surface
node_cli -->|"plans and commits"| node_apply
node_apply -->|"resolves writes"| node_surface
node_apply -->|"writes paths"| node_io
node_daemon -->|"loads"| node_profile_config
node_daemon -->|"discovers"| node_surface
node_daemon -->|"applies profiles"| node_apply
node_daemon -->|"reads samples"| node_telemetry_reader
node_telemetry_reader -->|"spawns and reads"| node_qcstats
node_daemon -->|"runs strategy"| node_fan_strategy
node_daemon -->|"commands fan"| node_fan_ownership
node_daemon -->|"services requests"| node_control_socket
node_daemon -->|"checks airflow"| node_fan_baseline
node_cli -->|"controls cooling"| node_fan_ownership
node_surface -->|"scans attributes"| node_io
node_apply -->|"tags snapshots"| node_environment
node_surface -->|"discovers controls"| node_sysfs
node_apply -->|"writes controls"| node_sysfs
node_fan_ownership -->|"takes and releases zone"| node_sysfs
node_fan_baseline -.->|"judges fan readings"| node_telemetry_reader

click node_cli "https://github.com/hans-kramer/qcctl/blob/main/src/main.c"
click node_profile_config "https://github.com/hans-kramer/qcctl/blob/main/src/config.c"
click node_profile_check "https://github.com/hans-kramer/qcctl/blob/main/src/profile_check.c"
click node_apply "https://github.com/hans-kramer/qcctl/blob/main/src/apply.c"
click node_daemon "https://github.com/hans-kramer/qcctl/blob/main/src/daemon.c"
click node_fan_strategy "https://github.com/hans-kramer/qcctl/blob/main/src/fancurve.c"
click node_fan_ownership "https://github.com/hans-kramer/qcctl/blob/main/src/fanown.c"
click node_fan_baseline "https://github.com/hans-kramer/qcctl/blob/main/src/fanbase.c"
click node_control_socket "https://github.com/hans-kramer/qcctl/blob/main/src/control.c"
click node_telemetry_reader "https://github.com/hans-kramer/qcctl/blob/main/src/stats.c"
click node_surface "https://github.com/hans-kramer/qcctl/blob/main/src/surface.c"
click node_io "https://github.com/hans-kramer/qcctl/blob/main/src/io.c"
click node_environment "https://github.com/hans-kramer/qcctl/blob/main/src/envid.c"

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_profile_config,node_profile_check,node_apply toneBlue
class node_daemon,node_fan_strategy,node_fan_ownership,node_fan_baseline,node_control_socket,node_telemetry_reader,node_sysfs toneAmber
class node_surface toneMint
class node_io,node_environment toneRose
class node_operator,node_qcstats toneIndigo
```

## Components

### Profiles and apply

- [qcctl CLI](https://github.com/hans-kramer/qcctl/blob/main/src/main.c): `src/main.c`
- [Profile parser](https://github.com/hans-kramer/qcctl/blob/main/src/config.c): `src/config.c`
- [Profile validator](https://github.com/hans-kramer/qcctl/blob/main/src/profile_check.c): `src/profile_check.c`
- [Apply and rollback](https://github.com/hans-kramer/qcctl/blob/main/src/apply.c): `src/apply.c`

### Daemon and fan

- [qcctld daemon](https://github.com/hans-kramer/qcctl/blob/main/src/daemon.c): `src/daemon.c`
- [Fan strategies](https://github.com/hans-kramer/qcctl/blob/main/src/fancurve.c): `src/fancurve.c`
- [Fan ownership](https://github.com/hans-kramer/qcctl/blob/main/src/fanown.c): `src/fanown.c`
- [Fan baseline](https://github.com/hans-kramer/qcctl/blob/main/src/fanbase.c): `src/fanbase.c`
- [Control socket](https://github.com/hans-kramer/qcctl/blob/main/src/control.c): `src/control.c`
- [Telemetry reader](https://github.com/hans-kramer/qcctl/blob/main/src/stats.c): `src/stats.c`

### Board interface

- [Hardware discovery](https://github.com/hans-kramer/qcctl/blob/main/src/surface.c): `src/surface.c`

### Shared runtime

- [Filesystem I/O](https://github.com/hans-kramer/qcctl/blob/main/src/io.c): `src/io.c`
- [Environment ID](https://github.com/hans-kramer/qcctl/blob/main/src/envid.c): `src/envid.c`

### Other components

- **Operator**
- **qcstats sampler**
- **Board sysfs**

## Connections

- Operator → qcctl CLI: invokes (evidence: `README.md`)
- qcctl CLI → Profile parser: loads (evidence: `src/main.c`)
- qcctl CLI → Hardware discovery: discovers (evidence: `src/main.c`)
- qcctl CLI → Profile validator: checks (evidence: `src/profile_check.c`)
- Profile validator → Profile parser: validates (evidence: `src/profile_check.c`)
- Profile validator → Hardware discovery: checks against (evidence: `src/profile_check.c`)
- qcctl CLI → Apply and rollback: plans and commits (evidence: `src/main.c`)
- Apply and rollback → Hardware discovery: resolves writes
- Apply and rollback → Filesystem I/O: writes paths (evidence: `src/apply.c`)
- qcctld daemon → Profile parser: loads (evidence: `src/daemon.c`)
- qcctld daemon → Hardware discovery: discovers (evidence: `src/daemon.c`)
- qcctld daemon → Apply and rollback: applies profiles (evidence: `src/daemon.c`)
- qcctld daemon → Telemetry reader: reads samples (evidence: `src/daemon.c`)
- Telemetry reader → qcstats sampler: spawns and reads
- qcctld daemon → Fan strategies: runs strategy (evidence: `src/daemon.c`)
- qcctld daemon → Fan ownership: commands fan (evidence: `src/daemon.c`)
- qcctld daemon → Control socket: services requests (evidence: `src/daemon.c`)
- qcctld daemon → Fan baseline: checks airflow (evidence: `src/daemon.c`)
- qcctl CLI → Fan ownership: controls cooling (evidence: `src/main.c`)
- Hardware discovery → Filesystem I/O: scans attributes (evidence: `src/surface.c`)
- Apply and rollback → Environment ID: tags snapshots (evidence: `src/apply.c`)
- Hardware discovery → Board sysfs: discovers controls
- Apply and rollback → Board sysfs: writes controls (evidence: `src/apply.c`)
- Fan ownership → Board sysfs: takes and releases zone
- Fan baseline → Telemetry reader: judges fan readings
