# endor-force/powermax-mqtt architecture

> Architecture diagram of the GitHub repository endor-force/powermax-mqtt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/endor-force/powermax-mqtt
- Repository: https://github.com/endor-force/powermax-mqtt

## Overview

##### Main Components
a. ESP8266-based Wemos D1 Hardware:
b. Firmware/Software Layers:
- That these files (e.g., .ino and .bin) are the actual code managing the alarm control functions and the MQTT communication.
c. MQTT Infrastructure:
d. Home Assistant (or other smart home controller):
e. (Optional) Additional Tools:

##### Architectural Patterns and Design Principles
- A modular design: the firmware is cleanly separated from the operational MQTT and Home Assistant integration. This separation allows you to update or swap firmware versions (v1 vs. v2) without impacting the overall system.
- Use of event-driven and publish/subscribe communication via MQTT.
- If applicable, note any port or network security configuration though details may be defined in the firmware code.

##### Relevant Technologies and Frameworks
- ESP8266 microcontroller and Wemos D1 board.
- Arduino-based firmware (as indicated by the .ino files).
- MQTT for messaging.
- Home Assistant for automation control.
- esptool.exe, which is used for flashing firmware onto the microcontroller.

##### Overall Detailing Approach
- Be comprehensive – capture every essential element from the board hardware to the external communication dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    WD["Wemos D1 (ESP8266)"]:::hardware

    subgraph "Firmware v1 Details"
        FW1["Firmware v1 (PowerMax)"]:::firmware
        F1S["Source (.ino)"]:::firmwareDetail
        F1B["Binary (.bin)"]:::firmwareDetail
    end

    subgraph "Firmware v2 Details"
        FW2["Firmware v2 (PowerMax)"]:::firmware
        F2S["Source (.ino)"]:::firmwareDetail
        F2B["Binary (.bin)"]:::firmwareDetail
    end

    MB["MQTT Broker"]:::mqtt
    HA["Home Assistant"]:::ha
    ET["ESP Tool (esptool.exe)"]:::tool

    %% Embedded system relationships
    WD -->|"runs"| FW1
    WD -->|"runs"| FW2
    FW1 --> F1S
    FW1 --> F1B
    FW2 --> F2S
    FW2 --> F2B

    %% Communication flows
    WD -->|"MQTTPublish/Subscribe"| MB
    MB <-->|"MQTTPublish/Subscribe"| HA

    %% Flashing process
    ET -->|"FlashingFirmware"| WD

    %% Click Events for Component Mapping
    click FW1 "https://github.com/endor-force/powermax-mqtt/tree/master/ESP-PowerMaxESP8266_WemosD1R2"
    click F1S "https://github.com/endor-force/powermax-mqtt/blob/master/ESP-PowerMaxESP8266_WemosD1R2/ESP-PowerMaxESP8266_WemosD1R2.ino"
    click F1B "https://github.com/endor-force/powermax-mqtt/blob/master/ESP-PowerMaxESP8266_WemosD1R2/ESP-PowerMaxESP8266_WemosD1R2.ino.d1_mini.bin"
    click FW2 "https://github.com/endor-force/powermax-mqtt/tree/master/ESP-PowerMaxESP8266_v2"
    click F2S "https://github.com/endor-force/powermax-mqtt/blob/master/ESP-PowerMaxESP8266_v2/ESP-PowerMaxESP8266_v2.ino"
    click F2B "https://github.com/endor-force/powermax-mqtt/blob/master/ESP-PowerMaxESP8266_v2/ESP-PowerMaxESP8266_v2.ino.d1.bin"
    click ET "https://github.com/endor-force/powermax-mqtt/blob/master/ESP-PowerMaxESP8266_WemosD1R2/esptool.exe"

    %% Styles
    classDef hardware fill:#ffdead,stroke:#8b4513,stroke-width:2px
    classDef firmware fill:#add8e6,stroke:#00008b,stroke-width:2px
    classDef mqtt fill:#98fb98,stroke:#006400,stroke-width:2px
    classDef ha fill:#fffacd,stroke:#daa520,stroke-width:2px
    classDef tool fill:#ffe4e1,stroke:#cd5c5c,stroke-width:2px
    classDef firmwareDetail fill:#e0ffff,stroke:#4682b4,stroke-width:1px, font-size:10px

    %% Vertical Layout
    linkStyle default interpolate basis
```
