# buglyz/ecc architecture

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

- Interactive diagram: https://gitdiagram.com/buglyz/ecc
- Repository: https://github.com/buglyz/ecc

## Overview

ECC Fan Controller is a Windows laptop fan-control application. The main workflow is: a user edits a curve or mode in the local web console; the dashboard applies and saves configuration; the controller samples CPU/GPU temperatures, combines and smooths them, interpolates a target speed, then conditionally writes both fan registers and records monitoring history. The application also exposes RPM feedback, named presets, startup-task management, and tray status/alerts. README documents these capabilities; some subsystem links below rely on documentation because their implementation was not sampled.

Main entry points: [`internal/controller/controller.go`](https://github.com/buglyz/ecc/blob/main/internal/controller/controller.go) (Fan controller), [`internal/dashboard/handlers.go`](https://github.com/buglyz/ecc/blob/main/internal/dashboard/handlers.go) (API handlers), [`cmd/fan-controller/main.go`](https://github.com/buglyz/ecc/blob/main/cmd/fan-controller/main.go) (Application entry), [`internal/dashboard`](https://github.com/buglyz/ecc/tree/main/internal/dashboard) (HTTP dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Application entry<br/>[main.go]"]
  node_config[("Configuration")]
  node_startup["Startup tasks<br/>[startup.go]"]
  node_tray["System tray"]
end

subgraph group_console["Web Console"]
  node_dashboard["HTTP dashboard"]
  node_webui["Web UI<br/>[index.html]"]
  node_handlers["API handlers<br/>[handlers.go]"]
end

subgraph group_control["Control Loop"]
  node_controller["Fan controller<br/>[controller.go]"]
  node_logic["Temperature and curve logic<br/>[logic.go]"]
  node_history[("Monitoring history<br/>[history.go]")]
end

subgraph group_hardware["Hardware I/O"]
  node_sensors["Temperature reader<br/>[powershell.go]"]
  node_ecwriter["EC writer<br/>[writer.go]"]
  node_ecreader["EC RPM reader<br/>[reader.go]"]
end

node_user(("User"))
node_browser(("Browser"))
node_schtasks["Windows Task Scheduler"]
node_powershell["PowerShell and LHM"]
node_probe["ec-probe<br/>[ec-probe.exe]"]
node_ec["Embedded Controller"]

node_user -->|"edits settings"| node_browser
node_browser -->|"requests console"| node_dashboard
node_dashboard -->|"serves page"| node_webui
node_dashboard -->|"dispatches API"| node_handlers
node_handlers -->|"updates mode"| node_controller
node_handlers -->|"saves settings"| node_config
node_handlers -->|"reads status"| node_controller
node_handlers -->|"manages startup"| node_startup
node_startup -->|"runs commands"| node_schtasks
node_main -->|"loads configuration"| node_config
node_main -->|"creates and starts"| node_controller
node_main -->|"starts server"| node_dashboard
node_main -->|"starts tray"| node_tray
node_controller -->|"reads temperatures"| node_sensors
node_sensors -->|"requests readings"| node_powershell
node_powershell -->|"returns temperatures"| node_sensors
node_controller -->|"combines and interpolates"| node_logic
node_controller -->|"writes fan speed"| node_ecwriter
node_controller -->|"reads fan RPM"| node_ecreader
node_ecwriter -->|"invokes write"| node_probe
node_ecreader -->|"invokes read"| node_probe
node_probe -->|"accesses registers"| node_ec
node_controller -->|"records samples"| node_history
node_handlers -->|"requests history"| node_history
node_controller -->|"signals write failure"| node_tray
node_tray -->|"opens console"| node_browser

click node_main "https://github.com/buglyz/ecc/blob/main/cmd/fan-controller/main.go"
click node_config "https://github.com/buglyz/ecc/tree/main/internal/config"
click node_startup "https://github.com/buglyz/ecc/blob/main/internal/startup/startup.go"
click node_tray "https://github.com/buglyz/ecc/tree/main/internal/tray"
click node_dashboard "https://github.com/buglyz/ecc/tree/main/internal/dashboard"
click node_webui "https://github.com/buglyz/ecc/blob/main/internal/dashboard/web/index.html"
click node_handlers "https://github.com/buglyz/ecc/blob/main/internal/dashboard/handlers.go"
click node_controller "https://github.com/buglyz/ecc/blob/main/internal/controller/controller.go"
click node_logic "https://github.com/buglyz/ecc/blob/main/internal/controller/logic.go"
click node_history "https://github.com/buglyz/ecc/blob/main/internal/controller/history.go"
click node_sensors "https://github.com/buglyz/ecc/blob/main/internal/sensors/powershell.go"
click node_ecwriter "https://github.com/buglyz/ecc/blob/main/internal/ec/writer.go"
click node_ecreader "https://github.com/buglyz/ecc/blob/main/internal/ec/reader.go"
click node_probe "https://github.com/buglyz/ecc/blob/main/assets/ec-probe.exe"

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_config,node_startup,node_tray,node_user,node_browser toneBlue
class node_dashboard,node_webui,node_handlers toneAmber
class node_controller,node_logic,node_history toneMint
class node_sensors,node_ecwriter,node_ecreader,node_schtasks toneRose
class node_powershell,node_ec toneIndigo
class node_probe toneTeal
```

## Components

### Application

- [Application entry](https://github.com/buglyz/ecc/blob/main/cmd/fan-controller/main.go): `cmd/fan-controller/main.go`
- [Configuration](https://github.com/buglyz/ecc/tree/main/internal/config): `internal/config`
- [Startup tasks](https://github.com/buglyz/ecc/blob/main/internal/startup/startup.go): `internal/startup/startup.go`
- [System tray](https://github.com/buglyz/ecc/tree/main/internal/tray): `internal/tray`

### Web Console

- [HTTP dashboard](https://github.com/buglyz/ecc/tree/main/internal/dashboard): `internal/dashboard`
- [Web UI](https://github.com/buglyz/ecc/blob/main/internal/dashboard/web/index.html): `internal/dashboard/web/index.html`
- [API handlers](https://github.com/buglyz/ecc/blob/main/internal/dashboard/handlers.go): `internal/dashboard/handlers.go`

### Control Loop

- [Fan controller](https://github.com/buglyz/ecc/blob/main/internal/controller/controller.go): `internal/controller/controller.go`
- [Temperature and curve logic](https://github.com/buglyz/ecc/blob/main/internal/controller/logic.go): `internal/controller/logic.go`
- [Monitoring history](https://github.com/buglyz/ecc/blob/main/internal/controller/history.go): `internal/controller/history.go`

### Hardware I/O

- [Temperature reader](https://github.com/buglyz/ecc/blob/main/internal/sensors/powershell.go): `internal/sensors/powershell.go`
- [EC writer](https://github.com/buglyz/ecc/blob/main/internal/ec/writer.go): `internal/ec/writer.go`
- [EC RPM reader](https://github.com/buglyz/ecc/blob/main/internal/ec/reader.go): `internal/ec/reader.go`

### Other components

- **User**
- **Browser**
- **Windows Task Scheduler**
- **PowerShell and LHM**
- [ec-probe](https://github.com/buglyz/ecc/blob/main/assets/ec-probe.exe): `assets/ec-probe.exe`
- **Embedded Controller**

## Connections

- User → Browser: edits settings
- Browser → HTTP dashboard: requests console
- HTTP dashboard → Web UI: serves page
- HTTP dashboard → API handlers: dispatches API
- API handlers → Fan controller: updates mode
- API handlers → Configuration: saves settings
- API handlers → Fan controller: reads status
- API handlers → Startup tasks: manages startup
- Startup tasks → Windows Task Scheduler: runs commands
- Application entry → Configuration: loads configuration
- Application entry → Fan controller: creates and starts
- Application entry → HTTP dashboard: starts server
- Application entry → System tray: starts tray
- Fan controller → Temperature reader: reads temperatures
- Temperature reader → PowerShell and LHM: requests readings
- PowerShell and LHM → Temperature reader: returns temperatures
- Fan controller → Temperature and curve logic: combines and interpolates
- Fan controller → EC writer: writes fan speed
- Fan controller → EC RPM reader: reads fan RPM
- EC writer → ec-probe: invokes write
- EC RPM reader → ec-probe: invokes read
- ec-probe → Embedded Controller: accesses registers
- Fan controller → Monitoring history: records samples
- API handlers → Monitoring history: requests history
- Fan controller → System tray: signals write failure
- System tray → Browser: opens console
