# ayoubziat/retrofit-heizungsanlage architecture

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

- Interactive diagram: https://gitdiagram.com/ayoubziat/retrofit-heizungsanlage
- Repository: https://github.com/ayoubziat/retrofit-heizungsanlage

## Overview

##### Main Components
- Main Application: Represented by src/main.cpp, which is the entry point.
- Communication Module: Found under lib/Comm including configuration files and credentials. This handles data transmission and communication with external services.
- Sensor Integration: The lib/dht module (dht_sensor.cpp, dht_sensor.h) provides sensor data (likely temperature and possibly humidity) for the heating system.
- Opto Module: Located in lib/Opto (optolink.cpp & optolink.h), this seems to handle control or interfacing with specific heating system components.
- External Integration Services:
- Grafana—under lib/Grafana, which provides a dashboard (grafana_dashboard.json).
- Node-RED flows—under lib/Node-red-flow for wiring up flows and orchestrating external automation.
- InfluxDB—mentioned in the README setup guide and likely used to store time-series sensor data.

##### Interactions
- The Main Application initiates the system and calls upon the Communication Module (Comm) to handle data transfer.
- The Communication Module likely utilizes configuration and credentials (credentials.h) to securely transmit sensor or control data.
- Sensor data is retrieved from the DHT module and may also integrate readings via the Opto module.
- External services are connected via APIs or other communication protocols defined in the Comm module.

##### Architectural Patterns & Design Principles
- Modularity: The clear separation into various lib directories (Comm, dht, Opto, Grafana, Node-red-flow) emphasizes a modular structure where each component encapsulates a specific functionality.
- Integration with External Systems: Note that the external services (InfluxDB, Grafana, Node-RED) are critical to the project’s monitoring and control capabilities.

## Diagram (Mermaid)

```mermaid
graph TD

    %% Embedded System
    subgraph "Embedded System"
        MA["Main Application"]:::internal

        subgraph "Sensors"
            DHT["DHT Sensor"]:::internal
            DHT_CPP["dht_sensor.cpp"]:::internal
            DHT_H["dht_sensor.h"]:::internal
            Opto["Opto Module"]:::internal
            Opto_CPP["optolink.cpp"]:::internal
            Opto_H["optolink.h"]:::internal
        end

        subgraph "Communication"
            COMM["Communication Module"]:::internal
            CONFIG["configuration.h"]:::internal
            CRED["credentials_example.h"]:::internal
        end
    end

    %% External Services
    subgraph "External Services"
        INFLUX["InfluxDB"]:::external
        GRAFANA["Grafana Dashboard"]:::external
        subgraph "Node-RED Flows"
            NR1["flows_1.0.json"]:::external
            NR2["flows_1.1.json"]:::external
            NR3["flows_1.2.json"]:::external
            NR4["flows_1.3.json"]:::external
        end
    end

    %% Connections
    DHT -->|"providesData"| MA
    Opto -->|"providesData"| MA
    MA -->|"sendsData"| COMM
    COMM -->|"storesData"| INFLUX
    INFLUX -->|"visualizesData"| GRAFANA
    COMM -->|"triggersFlows"| NR1

    %% Click Events
    click MA "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/src/main.cpp"
    click COMM "https://github.com/ayoubziat/retrofit-heizungsanlage/tree/master/lib/Comm"
    click CONFIG "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Comm/src/configuration.h"
    click CRED "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Comm/src/credentials_example.h"
    click DHT_CPP "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/dht/src/dht_sensor.cpp"
    click DHT_H "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/dht/src/dht_sensor.h"
    click Opto_CPP "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Opto/optolink.cpp"
    click Opto_H "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Opto/optolink.h"
    click GRAFANA "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Grafana/grafana_dashboard.json"
    click NR1 "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Node-red-flow/flows_1.0.json"
    click NR2 "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Node-red-flow/flows_1.1.json"
    click NR3 "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Node-red-flow/flows_1.2.json"
    click NR4 "https://github.com/ayoubziat/retrofit-heizungsanlage/blob/master/lib/Node-red-flow/flows_1.3.json"

    %% Styles
    classDef internal fill:#E0F7FA,stroke:#00796B,stroke-width:2px;
    classDef external fill:#FFECB3,stroke:#FF9800,stroke-width:2px;
```
