# lumapu/ahoy architecture

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

- Interactive diagram: https://gitdiagram.com/lumapu/ahoy
- Repository: https://github.com/lumapu/ahoy

## Overview

Ahoy is ESP32/ESP8266 firmware that communicates with Hoymiles solar inverters over radio, exposes monitoring and configuration through a web/JSON interface, and publishes data through MQTT or serial. The principal runtime centers on `app`, which initializes inverter state and coordinates radio, scheduling, history, and publishing. The README documents power-limit control and zero-export use, but the excerpts do not show the complete command path or all web/network registrations; those links are omitted where their callers are not evidenced.

Main entry points: [`src/app.h`](https://github.com/lumapu/ahoy/blob/main/src/app.h) (Application coordinator), [`src/main.cpp`](https://github.com/lumapu/ahoy/blob/main/src/main.cpp) (Firmware runtime), [`src/hm/hmSystem.h`](https://github.com/lumapu/ahoy/blob/main/src/hm/hmSystem.h) (Inverter system), [`src/hms/CmtRadio.h`](https://github.com/lumapu/ahoy/blob/main/src/hms/CmtRadio.h) (CMT radio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Firmware core"]
  node_firmware["Firmware runtime<br/>[main.cpp]"]
  node_app["Application coordinator<br/>[app.h]"]
  node_settings[("Settings and configuration<br/>[settings.h]")]
  node_scheduler["Task scheduler<br/>[scheduler.h]"]
  node_system["Inverter system<br/>[hmSystem.h]"]
  node_inverter["Inverter model<br/>[hmInverter.h]"]
end

subgraph group_radio["Inverter radio"]
  node_communication["Command communication<br/>[Communication.h]"]
  node_nrf["NRF radio<br/>[NrfRadio.h]"]
  node_cmt["CMT radio<br/>[CmtRadio.h]"]
  node_cmtchip["CMT2300A driver<br/>[cmt2300a.h]"]
end

subgraph group_interfaces["User interfaces"]
  node_web["Web interface<br/>[web.h]"]
  node_rest["JSON REST API<br/>[RestApi.h]"]
  node_protection["Access protection<br/>[Protection.h]"]
end

subgraph group_telemetry["Telemetry and output"]
  node_history[("History data<br/>[history.h]")]
  node_mqtt["MQTT publisher<br/>[pubMqtt.h]"]
  node_mqttdata["MQTT inverter data<br/>[pubMqttIvData.h]"]
  node_serial["Serial publisher<br/>[pubSerial.h]"]
  node_maxpower["Power limiting<br/>[MaxPower.h]"]
end

node_operator(("Solar operator"))

node_operator -->|"monitors and configures"| node_firmware
node_firmware -->|"starts"| node_app
node_app -->|"uses configuration"| node_settings
node_app -->|"coordinates"| node_system
node_system -->|"creates inverter"| node_inverter
node_app -->|"selects radio"| node_nrf
node_app -->|"selects radio"| node_cmt
node_communication -->|"sends commands"| node_nrf
node_cmt -->|"uses driver"| node_cmtchip
node_app -.->|"coordinates tasks"| node_scheduler
node_app -->|"records history"| node_history
node_app -->|"configures publisher"| node_mqtt
node_mqtt -->|"publishes inverter data"| node_mqttdata
node_app -->|"configures publisher"| node_serial
node_app -.->|"provides interface"| node_web
node_app -->|"provides JSON API"| node_rest
node_app -->|"delegates access checks"| node_protection
node_app -->|"uses power limit"| node_maxpower

click node_firmware "https://github.com/lumapu/ahoy/blob/main/src/main.cpp"
click node_app "https://github.com/lumapu/ahoy/blob/main/src/app.h"
click node_settings "https://github.com/lumapu/ahoy/blob/main/src/config/settings.h"
click node_scheduler "https://github.com/lumapu/ahoy/blob/main/src/utils/scheduler.h"
click node_system "https://github.com/lumapu/ahoy/blob/main/src/hm/hmSystem.h"
click node_inverter "https://github.com/lumapu/ahoy/blob/main/src/hm/hmInverter.h"
click node_communication "https://github.com/lumapu/ahoy/blob/main/src/hm/Communication.h"
click node_nrf "https://github.com/lumapu/ahoy/blob/main/src/hm/NrfRadio.h"
click node_cmt "https://github.com/lumapu/ahoy/blob/main/src/hms/CmtRadio.h"
click node_cmtchip "https://github.com/lumapu/ahoy/blob/main/src/hms/cmt2300a.h"
click node_web "https://github.com/lumapu/ahoy/blob/main/src/web/web.h"
click node_rest "https://github.com/lumapu/ahoy/blob/main/src/web/RestApi.h"
click node_protection "https://github.com/lumapu/ahoy/blob/main/src/web/Protection.h"
click node_history "https://github.com/lumapu/ahoy/blob/main/src/plugins/history.h"
click node_mqtt "https://github.com/lumapu/ahoy/blob/main/src/publisher/pubMqtt.h"
click node_mqttdata "https://github.com/lumapu/ahoy/blob/main/src/publisher/pubMqttIvData.h"
click node_serial "https://github.com/lumapu/ahoy/blob/main/src/publisher/pubSerial.h"
click node_maxpower "https://github.com/lumapu/ahoy/blob/main/src/plugins/MaxPower.h"

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_firmware,node_app,node_settings,node_scheduler,node_system,node_inverter toneBlue
class node_communication,node_nrf,node_cmt,node_cmtchip toneAmber
class node_web,node_rest,node_protection toneMint
class node_history,node_mqtt,node_mqttdata,node_serial,node_maxpower toneRose
class node_operator toneIndigo
```

## Components

### Firmware core

- [Firmware runtime](https://github.com/lumapu/ahoy/blob/main/src/main.cpp): `src/main.cpp`
- [Application coordinator](https://github.com/lumapu/ahoy/blob/main/src/app.h): `src/app.h`
- [Settings and configuration](https://github.com/lumapu/ahoy/blob/main/src/config/settings.h): `src/config/settings.h`
- [Task scheduler](https://github.com/lumapu/ahoy/blob/main/src/utils/scheduler.h): `src/utils/scheduler.h`
- [Inverter system](https://github.com/lumapu/ahoy/blob/main/src/hm/hmSystem.h): `src/hm/hmSystem.h`
- [Inverter model](https://github.com/lumapu/ahoy/blob/main/src/hm/hmInverter.h): `src/hm/hmInverter.h`

### Inverter radio

- [Command communication](https://github.com/lumapu/ahoy/blob/main/src/hm/Communication.h): `src/hm/Communication.h`
- [NRF radio](https://github.com/lumapu/ahoy/blob/main/src/hm/NrfRadio.h): `src/hm/NrfRadio.h`
- [CMT radio](https://github.com/lumapu/ahoy/blob/main/src/hms/CmtRadio.h): `src/hms/CmtRadio.h`
- [CMT2300A driver](https://github.com/lumapu/ahoy/blob/main/src/hms/cmt2300a.h): `src/hms/cmt2300a.h`

### User interfaces

- [Web interface](https://github.com/lumapu/ahoy/blob/main/src/web/web.h): `src/web/web.h`
- [JSON REST API](https://github.com/lumapu/ahoy/blob/main/src/web/RestApi.h): `src/web/RestApi.h`
- [Access protection](https://github.com/lumapu/ahoy/blob/main/src/web/Protection.h): `src/web/Protection.h`

### Telemetry and output

- [History data](https://github.com/lumapu/ahoy/blob/main/src/plugins/history.h): `src/plugins/history.h`
- [MQTT publisher](https://github.com/lumapu/ahoy/blob/main/src/publisher/pubMqtt.h): `src/publisher/pubMqtt.h`
- [MQTT inverter data](https://github.com/lumapu/ahoy/blob/main/src/publisher/pubMqttIvData.h): `src/publisher/pubMqttIvData.h`
- [Serial publisher](https://github.com/lumapu/ahoy/blob/main/src/publisher/pubSerial.h): `src/publisher/pubSerial.h`
- [Power limiting](https://github.com/lumapu/ahoy/blob/main/src/plugins/MaxPower.h): `src/plugins/MaxPower.h`

### Other components

- **Solar operator**

## Connections

- Solar operator → Firmware runtime: monitors and configures
- Firmware runtime → Application coordinator: starts (evidence: `src/main.cpp`)
- Application coordinator → Settings and configuration: uses configuration (evidence: `src/app.h`)
- Application coordinator → Inverter system: coordinates (evidence: `src/app.h`)
- Inverter system → Inverter model: creates inverter (evidence: `src/hm/hmSystem.h`)
- Application coordinator → NRF radio: selects radio (evidence: `src/app.h`)
- Application coordinator → CMT radio: selects radio (evidence: `src/app.h`)
- Command communication → NRF radio: sends commands (evidence: `src/hm/Communication.h`)
- CMT radio → CMT2300A driver: uses driver (evidence: `src/hms/CmtRadio.h`)
- Application coordinator → Task scheduler: coordinates tasks (evidence: `src/app.h`)
- Application coordinator → History data: records history (evidence: `src/app.h`)
- Application coordinator → MQTT publisher: configures publisher (evidence: `src/app.h`)
- MQTT publisher → MQTT inverter data: publishes inverter data (evidence: `src/publisher/pubMqtt.h`)
- Application coordinator → Serial publisher: configures publisher (evidence: `src/app.h`)
- Application coordinator → Web interface: provides interface (evidence: `src/app.h`)
- Application coordinator → JSON REST API: provides JSON API (evidence: `src/app.h`)
- Application coordinator → Access protection: delegates access checks (evidence: `src/app.h`)
- Application coordinator → Power limiting: uses power limit (evidence: `src/app.h`)
