# haswitchplate/openhasp architecture

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

- Interactive diagram: https://gitdiagram.com/haswitchplate/openhasp
- Repository: https://github.com/haswitchplate/openhasp

## Overview

openHASP is firmware for customizable touchscreen home-automation control, using LVGL to drive commodity displays and MQTT to connect with automation systems. The main runtime initializes configuration and first-run setup, starts the device UI and services, then runs periodic work. The product workflow is user interaction with touchscreen pages, with MQTT providing the documented automation connection. The graph also preserves device/display support, network and device services, and persistent configuration. Wiring beyond the sampled main and MQTT excerpts is inferred only at subsystem level; uncertain call relationships are omitted.

Main entry points: [`src/main.cpp`](https://github.com/haswitchplate/openhasp/blob/master/src/main.cpp) (Firmware runtime), [`src/hasp_gui.cpp`](https://github.com/haswitchplate/openhasp/blob/master/src/hasp_gui.cpp) (GUI runtime), [`src/hasp_config.cpp`](https://github.com/haswitchplate/openhasp/blob/master/src/hasp_config.cpp) (Runtime configuration), [`src/mqtt/hasp_mqtt.h`](https://github.com/haswitchplate/openhasp/blob/master/src/mqtt/hasp_mqtt.h) (MQTT integration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime setup"]
  node_main["Firmware runtime<br/>[main.cpp]"]
  node_oobe["First-run setup<br/>[hasp_oobe.cpp]"]
end

subgraph group_ui["Touch UI"]
  node_gui["GUI runtime<br/>[hasp_gui.cpp]"]
  node_pages["Pages and objects<br/>[hasp_page.cpp]"]
  node_events["Events and dispatch<br/>[hasp_dispatch.cpp]"]
  node_parser["Payload parsing<br/>[hasp_parser.cpp]"]
  node_fonts["Font loading"]
end

subgraph group_connectivity["Connectivity"]
  node_mqtt["MQTT integration<br/>[hasp_mqtt.h]"]
  node_network["Network connectivity<br/>[hasp_network.cpp]"]
  node_time["Time service<br/>[hasp_time.cpp]"]
  node_web["HTTP service<br/>[hasp_http.cpp]"]
  node_console["Console service<br/>[hasp_console.cpp]"]
  node_ota["Firmware updates<br/>[hasp_ota.cpp]"]
end

subgraph group_platform["Device platform"]
  node_device["Device integration<br/>[device.h]"]
  node_hal["Hardware abstraction<br/>[hasp_hal.cpp]"]
  node_display["Display drivers"]
  node_touch["Touch drivers"]
end

subgraph group_storage["Configuration and state"]
  node_config["Runtime configuration<br/>[hasp_config.cpp]"]
  node_filesystem[("Filesystem")]
  node_nvs[("Persistent settings<br/>[hasp_nvs.cpp]")]
end

node_user(("User"))
node_automation(("Home automation"))

node_user -->|"interacts"| node_gui
node_gui -->|"renders through"| node_display
node_touch -->|"provides input"| node_gui
node_gui -->|"manages pages"| node_pages
node_pages -->|"emits events"| node_events
node_mqtt -->|"dispatches commands"| node_events
node_mqtt -->|"exchanges messages"| node_automation
node_main -->|"loads configuration"| node_config
node_main -->|"starts setup"| node_oobe
node_main -->|"initializes device"| node_device
node_main -->|"starts MQTT"| node_mqtt
node_main -->|"starts service"| node_console
node_main -->|"starts service"| node_web
node_main -->|"starts service"| node_ota
node_main -->|"uses connectivity"| node_network
node_main -->|"runs time service"| node_time
node_device -->|"uses hardware"| node_hal
node_config -->|"uses storage"| node_filesystem
node_config -->|"uses settings"| node_nvs
node_gui -->|"loads fonts"| node_fonts
node_parser -->|"parses page data"| node_pages

click node_main "https://github.com/haswitchplate/openhasp/blob/master/src/main.cpp"
click node_oobe "https://github.com/haswitchplate/openhasp/blob/master/src/hasp_oobe.cpp"
click node_device "https://github.com/haswitchplate/openhasp/blob/master/src/dev/device.h"
click node_hal "https://github.com/haswitchplate/openhasp/blob/master/src/hal/hasp_hal.cpp"
click node_display "https://github.com/haswitchplate/openhasp/tree/master/src/drv/tft"
click node_touch "https://github.com/haswitchplate/openhasp/tree/master/src/drv/touch"
click node_gui "https://github.com/haswitchplate/openhasp/blob/master/src/hasp_gui.cpp"
click node_pages "https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_page.cpp"
click node_events "https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_dispatch.cpp"
click node_parser "https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_parser.cpp"
click node_fonts "https://github.com/haswitchplate/openhasp/blob/master/src/font/hasp_font_loader.cpp"
click node_mqtt "https://github.com/haswitchplate/openhasp/blob/master/src/mqtt/hasp_mqtt.h"
click node_network "https://github.com/haswitchplate/openhasp/blob/master/src/sys/net/hasp_network.cpp"
click node_time "https://github.com/haswitchplate/openhasp/blob/master/src/sys/net/hasp_time.cpp"
click node_web "https://github.com/haswitchplate/openhasp/blob/master/src/sys/svc/hasp_http.cpp"
click node_console "https://github.com/haswitchplate/openhasp/blob/master/src/sys/svc/hasp_console.cpp"
click node_ota "https://github.com/haswitchplate/openhasp/blob/master/src/sys/svc/hasp_ota.cpp"
click node_config "https://github.com/haswitchplate/openhasp/blob/master/src/hasp_config.cpp"
click node_filesystem "https://github.com/haswitchplate/openhasp/blob/master/src/hasp_filesystem.cpp"
click node_nvs "https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_nvs.cpp"

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_oobe,node_user toneBlue
class node_gui,node_pages,node_events,node_parser,node_fonts toneAmber
class node_mqtt,node_network,node_time,node_web,node_console,node_ota toneMint
class node_device,node_hal,node_display,node_touch toneRose
class node_config,node_filesystem,node_nvs,node_automation toneIndigo
```

## Components

### Runtime setup

- [Firmware runtime](https://github.com/haswitchplate/openhasp/blob/master/src/main.cpp): `src/main.cpp`
- [First-run setup](https://github.com/haswitchplate/openhasp/blob/master/src/hasp_oobe.cpp): `src/hasp_oobe.cpp`

### Touch UI

- [GUI runtime](https://github.com/haswitchplate/openhasp/blob/master/src/hasp_gui.cpp): `src/hasp_gui.cpp`
- [Pages and objects](https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_page.cpp): `src/hasp/hasp_page.cpp`
- [Events and dispatch](https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_dispatch.cpp): `src/hasp/hasp_dispatch.cpp`
- [Payload parsing](https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_parser.cpp): `src/hasp/hasp_parser.cpp`
- [Font loading](https://github.com/haswitchplate/openhasp/blob/master/src/font/hasp_font_loader.cpp): `src/font/hasp_font_loader.cpp`

### Connectivity

- [MQTT integration](https://github.com/haswitchplate/openhasp/blob/master/src/mqtt/hasp_mqtt.h): `src/mqtt/hasp_mqtt.h`
- [Network connectivity](https://github.com/haswitchplate/openhasp/blob/master/src/sys/net/hasp_network.cpp): `src/sys/net/hasp_network.cpp`
- [Time service](https://github.com/haswitchplate/openhasp/blob/master/src/sys/net/hasp_time.cpp): `src/sys/net/hasp_time.cpp`
- [HTTP service](https://github.com/haswitchplate/openhasp/blob/master/src/sys/svc/hasp_http.cpp): `src/sys/svc/hasp_http.cpp`
- [Console service](https://github.com/haswitchplate/openhasp/blob/master/src/sys/svc/hasp_console.cpp): `src/sys/svc/hasp_console.cpp`
- [Firmware updates](https://github.com/haswitchplate/openhasp/blob/master/src/sys/svc/hasp_ota.cpp): `src/sys/svc/hasp_ota.cpp`

### Device platform

- [Device integration](https://github.com/haswitchplate/openhasp/blob/master/src/dev/device.h): `src/dev/device.h`
- [Hardware abstraction](https://github.com/haswitchplate/openhasp/blob/master/src/hal/hasp_hal.cpp): `src/hal/hasp_hal.cpp`
- [Display drivers](https://github.com/haswitchplate/openhasp/tree/master/src/drv/tft): `src/drv/tft`
- [Touch drivers](https://github.com/haswitchplate/openhasp/tree/master/src/drv/touch): `src/drv/touch`

### Configuration and state

- [Runtime configuration](https://github.com/haswitchplate/openhasp/blob/master/src/hasp_config.cpp): `src/hasp_config.cpp`
- [Filesystem](https://github.com/haswitchplate/openhasp/blob/master/src/hasp_filesystem.cpp): `src/hasp_filesystem.cpp`
- [Persistent settings](https://github.com/haswitchplate/openhasp/blob/master/src/hasp/hasp_nvs.cpp): `src/hasp/hasp_nvs.cpp`

### Other components

- **User**
- **Home automation**

## Connections

- User → GUI runtime: interacts
- GUI runtime → Display drivers: renders through
- Touch drivers → GUI runtime: provides input
- GUI runtime → Pages and objects: manages pages
- Pages and objects → Events and dispatch: emits events
- MQTT integration → Events and dispatch: dispatches commands
- MQTT integration → Home automation: exchanges messages
- Firmware runtime → Runtime configuration: loads configuration
- Firmware runtime → First-run setup: starts setup
- Firmware runtime → Device integration: initializes device
- Firmware runtime → MQTT integration: starts MQTT
- Firmware runtime → Console service: starts service
- Firmware runtime → HTTP service: starts service
- Firmware runtime → Firmware updates: starts service
- Firmware runtime → Network connectivity: uses connectivity
- Firmware runtime → Time service: runs time service
- Device integration → Hardware abstraction: uses hardware
- Runtime configuration → Filesystem: uses storage
- Runtime configuration → Persistent settings: uses settings
- GUI runtime → Font loading: loads fonts
- Payload parsing → Pages and objects: parses page data
