# sanderdw/hassio-addons architecture

> Architecture diagram of the GitHub repository sanderdw/hassio-addons, 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/sanderdw/hassio-addons
- Repository: https://github.com/sanderdw/hassio-addons

## Overview

##### Main Components
- Home Assistant Platform: Since the add-ons are installed via Home Assistant’s Supervisor, include a node representing Home Assistant.
- DSMR Datalogger: Represented by the “dsmr_datalogger” folder – this component is responsible for extracting DSMR protocol data from smart meters. Highlight its role in receiving data from the smart meter and forwarding it over MQTT and via a REST API.
- DSMR Reader: Represented by the “dsmr_reader” folder – this provides the API endpoint and may serve web interfaces (Nginx is used internally) to present and process the data.
- Metabase: Represented by the “metabase” folder – used for powerful data visualization. Emphasize its role in querying and visualizing data collected by the DSMR add-ons.

##### Relationships and Interactions
- Metabase component with the DSMR Reader/Datalogger data store, indicating that Metabase queries this data for visualization.
- Home Assistant Supervisor as the management layer that deploys and manages these containers, typically linking as a host orchestrator.

##### Architectural Patterns and Key Design Principles
- Containerization: Each add-on is built as a separate Docker container; note the use of Dockerfiles and rootfs directories.
- Microservices-Like Separation: The clear separation into DSMR Datalogger, DSMR Reader, and Metabase signifies a microservices approach where each service handles specific responsibilities.
- Use of Standard Utilities: Within DSMR Reader, for example, the presence of an Nginx configuration, CLI helper scripts, and S6-overlay service management indicates the use of established patterns for container initialization and service orchestration.
- Extensibility: The design supports exporting data (via REST API and MQTT), thus making it integrable with other systems.

##### Incorporate Relevant Technologies and Frameworks
- Docker: The usage of Dockerfiles across components.
- Nginx: As configured in DSMR Reader for web traffic routing.
- S6-overlay: To manage services inside containers (particularly in DSMR Reader).
- MQTT: For pushing data.
- REST API: For data pulling and external system integrations.
- The overall Home Assistant ecosystem: Which acts as the host environment for these add-ons.

- Do not hesitate to break down each component into further details: for example, showing that the DSMR Datalogger container contains its own lightweight service management (e.g., under “rootfs/etc/services.d/datalogger”) and has dedicated scripts (in /usr/bin).
- Similarly, detail the DSMR Reader’s use of Nginx and S6 overlay mechanisms.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Home Assistant Supervisor"]:::management
    B["DSMR Datalogger\n(MQTT Publisher, REST API)"]:::container
    subgraph "DSMR Reader Container"
        direction TB
        C["DSMR Reader\n(API & Web Interface)"]:::container
        C1["Nginx"]:::internal
        C2["S6-overlay"]:::internal
        C1 --> C
        C2 --> C
    end
    D["Metabase\n(Data Visualization)"]:::container
    E["MQTT Broker"]:::external
    F["External REST Client"]:::external

    A -->|"Manages"| B
    A -->|"Manages"| C
    A -->|"Manages"| D
    B -->|"REST_data"| C
    B -->|"MQTT_data"| E
    B -->|"REST_export"| F
    C -->|"API_calls"| F
    C -->|"Data_query"| D

    classDef management fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef container fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef internal fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:2px;

    click B "https://github.com/sanderdw/hassio-addons/tree/master/dsmr_datalogger/"
    click C "https://github.com/sanderdw/hassio-addons/tree/master/dsmr_reader/"
    click D "https://github.com/sanderdw/hassio-addons/tree/master/metabase/"
```
