# smartboiler-kill/smartboiler-esp32 architecture

> Architecture diagram of the GitHub repository smartboiler-kill/smartboiler-esp32, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/smartboiler-kill/smartboiler-esp32
- Repository: https://github.com/smartboiler-kill/smartboiler-esp32

## Overview

##### Project type and purpose
- This is an IoT-embedded firmware project for an ESP32 (“SmartBoiler”) that provides precise boiler temperature control plus local/global network interfaces, a physical display, user-input buttons, and persistent storage.

##### File structure
- Top-level:
- lib/ — contains 9 C++ modules, each encapsulating a subsystem (Boiler, PID, TemperatureSensor, Display, LocalNetwork, GlobalNetwork, Memory, KiLL, Utils).
- src/main.cpp — the firmware entry point.
- platformio.ini — build & deployment config for ESP32 under Arduino/PlatformIO.
- test/ — test scaffolding.

##### README for additional insights
- The KiLL module is the central “control system” orchestrating all other libraries.
- Features map directly to modules in lib/ (e.g., PID for control logic, Display for UI, Memory for persistent storage, LocalNetwork/GlobalNetwork for connectivity).

##### Detail
- Don’t lump everything as “ESP32 firmware.” Break out each lib/ component.
- Persistent state flow: Memory ←→ KiLL.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% ESP32 boundary
    subgraph "ESP32 Firmware"
        direction TB

        %% Utils shared
        Utils["Utils"]:::utils

        %% Hardware Abstraction Layer
        subgraph "Hardware Abstraction" 
            direction TB
            TempSensor["TemperatureSensor"]:::hardware
            DisplayModule["Display"]:::hardware
            BoilerModule["Boiler"]:::hardware
        end

        %% Control Logic Layer
        subgraph "Control Logic"
            direction TB
            PIDCtrl["PID Controller"]:::control
            KiLL["KiLL Orchestrator"]:::control
        end

        %% Persistence Layer
        MemoryModule["Memory (EEPROM/SPIFFS)"]:::persistence

        %% Connectivity Layer
        subgraph "Connectivity"
            direction TB
            LocalNet["LocalNetwork"]:::connectivity
            GlobalNet["GlobalNetwork"]:::connectivity
        end

        %% Entry Point
        Main["main.cpp"]:::entry

    end

    %% Hardware peripherals
    TempProbe[(Temperature Probe)]:::peripheral
    Buttons[(Control Buttons)]:::peripheral
    Relay[(Boiler Relay/SSR)]:::peripheral
    PhysDisplay[(Physical Display)]:::peripheral

    %% External systems
    UserDevice[(User Device Web UI)]:::external
    CloudService[(Cloud Service)]:::external

    %% Data and control flows
    TempProbe -->|reads data| TempSensor
    Buttons -->|events| KiLL
    TempSensor -->|temperature data| KiLL
    KiLL -->|compute| PIDCtrl
    PIDCtrl -->|output| KiLL
    KiLL -->|command| BoilerModule
    BoilerModule -->|drive| Relay
    KiLL -->|update| DisplayModule
    DisplayModule -->|render| PhysDisplay
    KiLL -->|save/load| MemoryModule
    KiLL -->|serve API| LocalNet
    LocalNet -->|HTTP/WebSocket| UserDevice
    KiLL -->|connect| GlobalNet
    GlobalNet -->|sync| CloudService

    %% Utils dependencies
    Utils -.-> TempSensor
    Utils -.-> PIDCtrl
    Utils -.-> BoilerModule
    Utils -.-> DisplayModule
    Utils -.-> MemoryModule
    Utils -.-> LocalNet
    Utils -.-> GlobalNet
    Utils -.-> KiLL

    %% Entry point dependency
    Main --> KiLL
    Main --> Utils
    Main --> TempSensor
    Main --> PIDCtrl
    Main --> BoilerModule
    Main --> DisplayModule
    Main --> MemoryModule
    Main --> LocalNet
    Main --> GlobalNet

    %% Click events
    click KiLL "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/KiLL/KiLL.cpp"
    click TempSensor "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/TemperatureSensor/TemperatureSensor.cpp"
    click PIDCtrl "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/PID/PID.cpp"
    click BoilerModule "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/Boiler/Boiler.cpp"
    click DisplayModule "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/Display/Display.cpp"
    click Utils "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/Utils/Utils.cpp"
    click MemoryModule "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/Memory/Memory.cpp"
    click LocalNet "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/LocalNetwork/LocalNetwork.cpp"
    click GlobalNet "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/lib/GlobalNetwork/GlobalNetwork.cpp"
    click Main "https://github.com/smartboiler-kill/smartboiler-esp32/blob/master/src/main.cpp"

    %% Styles
    classDef hardware fill:#AED6F1,stroke:#2980B9,color:#1B2631;
    classDef control fill:#ABEBC6,stroke:#27AE60,color:#1B2631;
    classDef persistence fill:#F9E79F,stroke:#B7950B,color:#1B2631;
    classDef connectivity fill:#F5B7B1,stroke:#C0392B,color:#1B2631;
    classDef utils fill:#D7BDE2,stroke:#8E44AD,color:#1B2631;
    classDef entry fill:#D5DBDB,stroke:#7B7D7D,color:#1B2631;
    classDef peripheral fill:#F0F3F4,stroke:#566573,color:#1B2631,shape:roundrectangle;
    classDef external fill:#FDFEFE,stroke:#566573,color:#1B2631,shape:roundrectangle;
```
