# nikolai-kummer/remote-data-collection architecture

> Architecture diagram of the GitHub repository nikolai-kummer/remote-data-collection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikolai-kummer/remote-data-collection
- Repository: https://github.com/nikolai-kummer/remote-data-collection

## Overview

##### IoT Device and Embedded Firmware
- Firmware directories (e.g., firmware/CloudSketch, firmware/ConnectWithWPA, firmware/azure-iot, etc.) house the Arduino sketches and related code that run on the devices.
- The firmware components are responsible for sensor communications, local decision-making, and communication (via WiFi, MQTT, etc.) with the cloud.
- They include modules for managing specific hardware aspects like battery, GPS, IMU, and IoT communications.

##### Reinforcement Learning Core (Agent and Environment)
- Directories such as RL_nz and agent provide the RL logic. Inside RL_nz, you see different agent types (baseline_agent.py, tabular_agent.py) and environment definitions (in RL_nz/environment: gym_environment.py, custom_env.py, etc.), as well as training scripts.
- There is also a separate agent folder that contains variants of the RL agent and test suites demonstrating modular design and verifiability.
- The RL agent (a Q-learning agent as per README) uses simulated environments (battery drain, solar collection, etc.) to learn optimal behavior to maximize rewards (sending data to the cloud) and minimize penalties.

##### External Integration and Data Handling
- From the README, the cloud element is the IoT hub instance running on Azure. This is where sensor data is sent after local processing.
- Data directories (with CSV files) provide experimental or calibration data (such as estimates on solar gains and power consumption) that could be used for simulation inputs or subsequent analysis.
- The “paper” directory and simulation notebooks (in the “rl sim” directory) indicate that this project is research-focused—for reproducibility and further study—and assist in validating the performance of the RL agent in simulation.

A. Outline the Primary Components:
1. IoT Device Firmware Layer:
- A block for “IoT Device / Edge Hardware” where the firmware (CloudSketch, ConnectWithWPA, azure-iot, etc.) resides.
- Detail sub-components to show sensor interactions, power management (battery and solar), and wireless communications modules.
2. RL Agent and Environment:
- Agent Modules: Baseline, Tabular, and Q-learning agents (from RL_nz/agent and agent directories).
- Environment/Simulation: Components in RL_nz/environment representing simulation of battery drain, solar conditions, and sensor dynamics.
3. Cloud and Data Analytics:
- External “Azure IoT Hub” as the destination for data from the IoT devices.
- Optionally, include a “Data & Analytics” block where incoming sensor data is stored and possibly processed or used to update simulation models.
4. Supporting and Experimental Modules:
- Smaller blocks for “Simulations & Testing” (rl sim directory, tests directories) and “Data Inputs” (CSV files in data/).
- A “Documentation & Research” component (paper directory) that underscores the academic and reproducibility aspects of the project.

B. Describe the Interactions:
- The IoT device firmware sends data via wireless channels to the Azure IoT Hub.
- Simultaneously, the RL agent interacts with its simulated environment locally to learn optimal strategies.
- Testing frameworks and simulation notebooks feed into iterative improvements of the agent.
- Dependency relationships such as how configuration files (e.g., YAML config files in RL_nz) are used across simulation and training scripts.

C. Emphasize Architectural Patterns and Technologies:
- Clearly label separation between edge (firmware/Arduino) and cloud (Azure IoT Hub).
- That the reinforcement learning components adopt modular design—separating the agent logic from the environment simulation.
- Utilization of common patterns such as “separation of concerns” (distinct directories for firmware, RL agent, simulation, and tests) and interoperability between hardware and cloud components.

- Components should be clearly labeled (e.g., “RL Agent”, “Device Firmware”, “IoT Hub”, “Simulation Environment”, “Data Sources”).
- Maintain clarity and detail—include as many components as possible to capture every major module within your multifaceted structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "IoT Device and Embedded Firmware Layer"
        DF("Device Firmware (Sensor, Battery, Wireless)"):::firmware
    end

    subgraph "Reinforcement Learning Core"
        subgraph "Agent Modules"
            RA1("RL Agent - RL_nz"):::agent
            RA2("RL Agent - agent"):::agent
        end
        SE("Simulation Environment (Battery,Solar,SensorDynamics)"):::simulation
    end

    subgraph "External Integration and Data Handling"
        IOT("Azure IoT Hub"):::cloud
        DI("Data Inputs (CSV Data)"):::data
    end

    subgraph "Simulations & Testing"
        T1("RL Tests"):::test
        T2("Agent Tests"):::test
        SN("Simulation Notebooks"):::test
    end

    D("Documentation & Research"):::docs

    %% Connections
    DF -->|"sendsData"| IOT
    IOT -->|"forAnalytics"| DI
    DI -->|"calibrates"| SE
    SE -->|"observations"| RA1
    RA1 -->|"act"| SE
    SE -->|"observations"| RA2
    RA2 -->|"act"| SE
    SN -->|"improves"| SE
    T1 -->|"feedsFeedback"| RA1
    T2 -->|"feedsFeedback"| RA2
    D -->|"providesInfo"| SE

    %% Click Events
    click DF "https://github.com/nikolai-kummer/remote-data-collection/tree/main/firmware/"
    click RA1 "https://github.com/nikolai-kummer/remote-data-collection/tree/main/RL_nz/agent/"
    click RA2 "https://github.com/nikolai-kummer/remote-data-collection/tree/main/agent/"
    click SE "https://github.com/nikolai-kummer/remote-data-collection/tree/main/RL_nz/environment/"
    click DI "https://github.com/nikolai-kummer/remote-data-collection/tree/main/data/"
    click SN "https://github.com/nikolai-kummer/remote-data-collection/tree/main/rl sim/"
    click T1 "https://github.com/nikolai-kummer/remote-data-collection/tree/main/RL_nz/tests/"
    click T2 "https://github.com/nikolai-kummer/remote-data-collection/tree/main/agent/tests/"
    click D "https://github.com/nikolai-kummer/remote-data-collection/tree/main/paper/"

    %% Styles
    classDef firmware fill:#f9c,stroke:#333,stroke-width:2px;
    classDef agent fill:#bbf,stroke:#333,stroke-width:2px;
    classDef simulation fill:#ff9,stroke:#333,stroke-width:2px;
    classDef cloud fill:#9f9,stroke:#333,stroke-width:2px;
    classDef data fill:#aff,stroke:#333,stroke-width:2px;
    classDef test fill:#f99,stroke:#333,stroke-width:2px;
    classDef docs fill:#ccc,stroke:#333,stroke-width:2px;
```
