# overfl0w11/mmm-netatmo-thermostat architecture

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

- Interactive diagram: https://gitdiagram.com/overfl0w11/mmm-netatmo-thermostat
- Repository: https://github.com/overfl0w11/mmm-netatmo-thermostat

## Overview

##### Main Components
- MagicMirror Core: Represent the overall MagicMirror framework that loads modules.
- MMM-Netatmo-Thermostat Module:
- Frontend/UI Component – indicated by the MMM-Netatmo-Thermostat.js file and the accompanying CSS (MMM-Netatmo-Thermostat.css). This part is responsible for rendering thermostat information (temperature and heating status) on the MagicMirror display.
- Node Helper/Backend Component – represented by node_helper.js which is used for backend API calls. This file handles interactions with Netatmo (such as requesting data using credentials) and communicating results back to the frontend part.
- External Netatmo API: This is the external service where thermostat data is fetched using your client credentials (clientId, clientSecret, and refreshToken).
- Supporting Utilities:
- Translations (translations folder with multiple language JSON files) to support internationalization.
- Utility scripts (e.g., String.format.js) for string formatting.
- Configuration & Build:
- Configuration files (package.json, Gruntfile.js, .eslintrc.json, .stylelintrc) that help in building, linting, and packaging the module.
- CHANGELOG.md and LICENSE.txt, which while not part of runtime, help define versioning and usage rights.

##### Relationships and Data Flow
- MagicMirror loads the MMM-Netatmo-Thermostat module as one of its built-in modules.
- Initialization: The MagicMirror core instructs the module to render.
- API Trigger: The module (or its node_helper) initiates an API call to the external Netatmo service using credentials provided in the configuration (clientId, clientSecret, refreshToken).
- The node_helper.js fetches thermostat data from the Netatmo API at defined update intervals.
- Additionally, the translations utilize the language JSONs from the translations folder to render locale-specific text if necessary.
- The build tools (Gruntfile.js) and ESLint/Stylelint configuration files ensure the module’s quality but do not directly affect runtime architecture.

##### Architectural Patterns and Principles
- Separation of Concerns: The module cleanly separates the UI (MMM-Netatmo-Thermostat.js) from the backend/API logic (node_helper.js).
- Modular Design: Serving as a plug-in to MagicMirror, it follows a component-based architecture, making it easy to update or replace either part.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% MagicMirror Core
    MM["MagicMirror Core"]:::core

    %% MMM-Netatmo-Thermostat Module Subgraph
    subgraph "MMM-Netatmo-Thermostat Module"
        UI["UI Component (MMM-Netatmo-Thermostat.js & CSS)"]:::frontend
        NODE["Node Helper (node_helper.js)"]:::backend
    end

    %% External Netatmo API
    NET["Netatmo API"]:::external

    %% Supporting Utilities Subgraph
    subgraph "Supporting Utilities"
        TRANS["Translations"]:::translations
        UTIL["Utility Scripts (String.format.js)"]:::utility
    end

    %% Build & Configuration Subgraph
    subgraph "Build & Configuration"
        PKG["package.json"]:::config
        GRNT["Gruntfile.js"]:::config
        ESL[".eslintrc.json"]:::config
        STYLE[".stylelintrc"]:::config
        CHANGE["CHANGELOG.md"]:::config
        LIC["LICENSE.txt"]:::config
    end

    %% Connections / Data Flow
    MM -->|"loads"| UI
    MM -->|"loads"| NODE
    NODE -->|"FetchData"| NET
    NET -->|"ReturnData"| NODE
    NODE -->|"Update"| UI
    UI -->|"Translate"| TRANS
    TRANS -->|"ProvideText"| UI
    UTIL -->|"FormatText"| UI

    %% Click Events
    click UI "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/MMM-Netatmo-Thermostat.js"
    click UI "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/MMM-Netatmo-Thermostat.css"
    click NODE "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/node_helper.js"
    click TRANS "https://github.com/overfl0w11/mmm-netatmo-thermostat/tree/master/translations/"
    click UTIL "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/String.format.js"
    click PKG "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/package.json"
    click GRNT "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/Gruntfile.js"
    click ESL "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/.eslintrc.json"
    click STYLE "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/.stylelintrc"
    click CHANGE "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/CHANGELOG.md"
    click LIC "https://github.com/overfl0w11/mmm-netatmo-thermostat/blob/master/LICENSE.txt"

    %% Styles
    classDef core fill:#A1CAF1,stroke:#000,stroke-width:1px;
    classDef frontend fill:#B8E0D2,stroke:#000,stroke-width:1px,stroke-dasharray:5, 5;
    classDef backend fill:#FAD4A1,stroke:#000,stroke-width:1px;
    classDef external fill:#FF9AA2,stroke:#000,stroke-width:1px;
    classDef translations fill:#FFFFB5,stroke:#000,stroke-width:1px;
    classDef utility fill:#C4C8FF,stroke:#000,stroke-width:1px;
    classDef config fill:#D5A6BD,stroke:#000,stroke-width:1px;
```
