# spin24/bsdsensors architecture

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

- Interactive diagram: https://gitdiagram.com/spin24/bsdsensors
- Repository: https://github.com/spin24/bsdsensors

## Overview

bsdsensors is a FreeBSD hardware-monitoring CLI. The principal workflow parses command-line options, probes supported Super I/O chip families through /dev/io, reads temperature, voltage, fan-speed, and fan-control state into protobuf sensor data, optionally adds disk temperatures via smartctl, then prints tables, protobuf text, or JSON. Configuration requests branch into chip-specific fan-control or temperature-source writes. The graph preserves documented chip families and integrations; several family implementations are represented from the tree without claiming unsampled internal call details.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI Orchestration"]
  node_main["CLI Runner<br/>[main.cc]"]
  node_device_db["Device Registry<br/>[dev_db.cc]"]
  node_output["Output Formatter<br/>[util.cc]"]
end

subgraph group_hardware["Hardware Access"]
  node_port_io["Port I/O<br/>[port_io.cc]"]
  node_super_io["Super I/O<br/>[super_io.cc]"]
  node_banked_io["Banked Registers<br/>[banked_io.cc]"]
  node_nuvoton["Nuvoton Adapter<br/>[nuvoton_chip.cc]"]
  node_ite["ITE Adapter<br/>[ite_chip.cc]"]
  node_fintek["Fintek Adapter<br/>[fintek_chip.cc]"]
  node_microchip["Microchip Adapter<br/>[microchip_chip.cc]"]
  node_chip_metadata["Chip Metadata"]
end

subgraph group_sensing["Sensing Control"]
  node_temperatures["Temperature Sensors"]
  node_voltages["Voltage Sensors"]
  node_fan_speeds["Fan Speed Sensors"]
  node_fan_control["Fan Control"]
end

subgraph group_formats["Data Integrations"]
  node_sensor_data["Sensor Data<br/>[sensors.proto]"]
  node_request_data["Request Schema<br/>[request.proto]"]
  node_disk_temps["Disk Temperatures<br/>[disk_temp.cc]"]
end

node_user(("Operator"))
node_smartctl["smartctl"]

node_user -->|"runs"| node_main
node_main -->|"creates"| node_port_io
node_main -->|"probes"| node_nuvoton
node_main -->|"probes"| node_ite
node_main -->|"probes"| node_fintek
node_main -->|"probes"| node_microchip
node_main -->|"registers"| node_device_db
node_main -->|"parses"| node_request_data
node_main -.->|"adds disks"| node_disk_temps
node_main -->|"prints"| node_output
node_nuvoton -->|"initializes"| node_super_io
node_ite -->|"initializes"| node_super_io
node_fintek -->|"initializes"| node_super_io
node_microchip -->|"initializes"| node_super_io
node_nuvoton -->|"reads registers"| node_banked_io
node_nuvoton -->|"loads metadata"| node_chip_metadata
node_nuvoton -->|"loads sensors"| node_temperatures
node_nuvoton -->|"loads sensors"| node_voltages
node_nuvoton -->|"loads sensors"| node_fan_speeds
node_nuvoton -->|"loads controls"| node_fan_control
node_nuvoton -->|"fills readings"| node_sensor_data
node_ite -->|"fills readings"| node_sensor_data
node_fintek -->|"fills readings"| node_sensor_data
node_microchip -->|"fills readings"| node_sensor_data
node_fan_control -->|"writes settings"| node_banked_io
node_temperatures -->|"reads values"| node_banked_io
node_voltages -->|"reads values"| node_banked_io
node_fan_speeds -->|"reads values"| node_banked_io
node_disk_temps -.->|"invokes"| node_smartctl
node_disk_temps -.->|"adds readings"| node_sensor_data
node_output -->|"formats"| node_sensor_data

click node_main "https://github.com/spin24/bsdsensors/blob/master/src/main.cc"
click node_device_db "https://github.com/spin24/bsdsensors/blob/master/lib/dev_db.cc"
click node_output "https://github.com/spin24/bsdsensors/blob/master/lib/util.cc"
click node_port_io "https://github.com/spin24/bsdsensors/blob/master/lib/port_io.cc"
click node_super_io "https://github.com/spin24/bsdsensors/blob/master/lib/super_io.cc"
click node_banked_io "https://github.com/spin24/bsdsensors/blob/master/lib/banked_io.cc"
click node_nuvoton "https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_chip.cc"
click node_ite "https://github.com/spin24/bsdsensors/blob/master/lib/ite_chip.cc"
click node_fintek "https://github.com/spin24/bsdsensors/blob/master/lib/fintek_chip.cc"
click node_microchip "https://github.com/spin24/bsdsensors/blob/master/lib/microchip_chip.cc"
click node_chip_metadata "https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_chip_info.cc"
click node_temperatures "https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_temp_sensor.cc"
click node_voltages "https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_volt_sensor.cc"
click node_fan_speeds "https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_fan_speed.cc"
click node_fan_control "https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_fan_control.cc"
click node_sensor_data "https://github.com/spin24/bsdsensors/blob/master/proto/sensors.proto"
click node_request_data "https://github.com/spin24/bsdsensors/blob/master/proto/request.proto"
click node_disk_temps "https://github.com/spin24/bsdsensors/blob/master/lib/disk_temp.cc"

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,node_device_db,node_output toneBlue
class node_port_io,node_super_io,node_banked_io,node_nuvoton,node_ite,node_fintek,node_microchip,node_chip_metadata toneAmber
class node_temperatures,node_voltages,node_fan_speeds,node_fan_control toneMint
class node_sensor_data,node_request_data,node_disk_temps toneRose
class node_user,node_smartctl toneIndigo
```

## Components

### CLI Orchestration

- [CLI Runner](https://github.com/spin24/bsdsensors/blob/master/src/main.cc): `src/main.cc`
- [Device Registry](https://github.com/spin24/bsdsensors/blob/master/lib/dev_db.cc): `lib/dev_db.cc`
- [Output Formatter](https://github.com/spin24/bsdsensors/blob/master/lib/util.cc): `lib/util.cc`

### Hardware Access

- [Port I/O](https://github.com/spin24/bsdsensors/blob/master/lib/port_io.cc): `lib/port_io.cc`
- [Super I/O](https://github.com/spin24/bsdsensors/blob/master/lib/super_io.cc): `lib/super_io.cc`
- [Banked Registers](https://github.com/spin24/bsdsensors/blob/master/lib/banked_io.cc): `lib/banked_io.cc`
- [Nuvoton Adapter](https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_chip.cc): `lib/nuvoton_chip.cc`
- [ITE Adapter](https://github.com/spin24/bsdsensors/blob/master/lib/ite_chip.cc): `lib/ite_chip.cc`
- [Fintek Adapter](https://github.com/spin24/bsdsensors/blob/master/lib/fintek_chip.cc): `lib/fintek_chip.cc`
- [Microchip Adapter](https://github.com/spin24/bsdsensors/blob/master/lib/microchip_chip.cc): `lib/microchip_chip.cc`
- [Chip Metadata](https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_chip_info.cc): `lib/nuvoton_chip_info.cc`

### Sensing Control

- [Temperature Sensors](https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_temp_sensor.cc): `lib/nuvoton_temp_sensor.cc`
- [Voltage Sensors](https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_volt_sensor.cc): `lib/nuvoton_volt_sensor.cc`
- [Fan Speed Sensors](https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_fan_speed.cc): `lib/nuvoton_fan_speed.cc`
- [Fan Control](https://github.com/spin24/bsdsensors/blob/master/lib/nuvoton_fan_control.cc): `lib/nuvoton_fan_control.cc`

### Data Integrations

- [Sensor Data](https://github.com/spin24/bsdsensors/blob/master/proto/sensors.proto): `proto/sensors.proto`
- [Request Schema](https://github.com/spin24/bsdsensors/blob/master/proto/request.proto): `proto/request.proto`
- [Disk Temperatures](https://github.com/spin24/bsdsensors/blob/master/lib/disk_temp.cc): `lib/disk_temp.cc`

### Other components

- **Operator**
- **smartctl**

## Connections

- Operator → CLI Runner: runs
- CLI Runner → Port I/O: creates
- CLI Runner → Nuvoton Adapter: probes
- CLI Runner → ITE Adapter: probes
- CLI Runner → Fintek Adapter: probes
- CLI Runner → Microchip Adapter: probes
- CLI Runner → Device Registry: registers
- CLI Runner → Request Schema: parses
- CLI Runner → Disk Temperatures: adds disks
- CLI Runner → Output Formatter: prints
- Nuvoton Adapter → Super I/O: initializes
- ITE Adapter → Super I/O: initializes
- Fintek Adapter → Super I/O: initializes
- Microchip Adapter → Super I/O: initializes
- Nuvoton Adapter → Banked Registers: reads registers
- Nuvoton Adapter → Chip Metadata: loads metadata
- Nuvoton Adapter → Temperature Sensors: loads sensors
- Nuvoton Adapter → Voltage Sensors: loads sensors
- Nuvoton Adapter → Fan Speed Sensors: loads sensors
- Nuvoton Adapter → Fan Control: loads controls
- Nuvoton Adapter → Sensor Data: fills readings
- ITE Adapter → Sensor Data: fills readings
- Fintek Adapter → Sensor Data: fills readings
- Microchip Adapter → Sensor Data: fills readings
- Fan Control → Banked Registers: writes settings
- Temperature Sensors → Banked Registers: reads values
- Voltage Sensors → Banked Registers: reads values
- Fan Speed Sensors → Banked Registers: reads values
- Disk Temperatures → smartctl: invokes
- Disk Temperatures → Sensor Data: adds readings
- Output Formatter → Sensor Data: formats
