# garzonsergio/iot-simulator architecture

> Architecture diagram of the GitHub repository garzonsergio/iot-simulator, 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/garzonsergio/iot-simulator
- Repository: https://github.com/garzonsergio/iot-simulator

## Overview

##### Main Components
- IoT Simulator Module: Centered on the script (scripts/simulate_device.sh) that generates simulated sensor data (temperature, humidity, timestamp) and publishes JSON messages via MQTT.
- AWS IoT Core: This is the external cloud service that receives the MQTT messages.
- Deployment Environment: Since there are a Dockerfile and docker-compose.yml, the simulation can be containerized. Represent the Docker container as an execution environment for the simulator.
- Certificates & Configuration: Although not in the file tree (they’re provided externally), the simulator depends on AWS IoT certificates (device cert, private key, root CA) and environment variables (e.g., AWS_IOT_ENDPOINT) to function securely.
- Dependencies: The use of mosquitto-clients and utilities like curl are integral to the simulation process.

##### Relationships and Interactions
- Configuration flows by showing how environment variables and certificate files are injected into the simulator (for example, from a configuration or secrets manager node).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The simulator script is a standalone program focusing solely on data generation and publishing, while AWS IoT Core represents the external messaging endpoint.
- Container Deployment: With Docker Compose available, the design encourages containerization for reproducible deployment.
- Security Best Practices: Highlight how certificates are managed (stored externally, permissions set appropriately) and that sensitive data is not kept in version control (note the .gitignore for certificates).

##### Technologies, Frameworks, and Dependencies
- MQTT communication (using mosquitto-clients).
- Docker and Docker Compose as deployment tools.
- Shell scripting (simulate_device.sh) as the logic engine.
- AWS IoT Core as the target messaging service.

##### Elements
- Clear labels: Name each component such as “IoT Simulator Script”, “Docker Container”, “AWS IoT Core”, and “Certificate/Configuration Manager”.
- Configuration/Data Flow: Optionally add smaller nodes to indicate configuration injection (environment variables and certificates).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Configuration and Dependencies
    Config["Certificates & Config Manager"]:::config
    Dependency["Dependencies (mosquitto-clients, curl)"]:::dependency

    %% Container Deployment Environment and Simulator
    subgraph "Container Deployment Environment"
        Simulator["IoT Simulator Script (simulate_device.sh)"]:::module
    end

    ContainerFiles["Container Files\n(Dockerfile, docker-compose.yml)"]:::container
    AWS["AWS IoT Core"]:::external

    %% Data and Control Flows
    Config -->|"InjectsConfiguration"| Simulator
    Simulator -->|"RunsInside"| ContainerFiles
    Simulator -->|"MQTTPublish(Temp&HumidityData)"| AWS
    Dependency -->|"ProvidesUtilities"| Simulator

    %% Click Events
    click Simulator "https://github.com/garzonsergio/iot-simulator/blob/main/scripts/simulate_device.sh"
    click ContainerFiles "https://github.com/garzonsergio/iot-simulator/tree/main/Dockerfile"
    click Config "https://github.com/garzonsergio/iot-simulator/blob/main/.gitignore"

    %% Styling
    classDef module fill:#ffe6f0,stroke:#cc0044,stroke-width:2px;
    classDef external fill:#e6f7ff,stroke:#007acc,stroke-width:2px;
    classDef container fill:#e6ffe6,stroke:#009900,stroke-width:2px;
    classDef config fill:#fff0e6,stroke:#cc6600,stroke-width:2px;
    classDef dependency fill:#fff9e6,stroke:#cc9900,stroke-width:2px;
```
