# microsoft/iot-for-beginners architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/iot-for-beginners
- Repository: https://github.com/microsoft/iot-for-beginners

## Overview

##### Major architectural layers/components
a. Hardware/Device Layer:
b. Connectivity Layer:
c. Cloud/Server Layer:
d. Client/Presentation Layer:
e. Development Environment & Curriculum Content:

##### Architectural Patterns
- That the project uses a hands‑on, layered architecture: devices (on the edge) connect via network protocols (MQTT or HTTP) to cloud functions; these functions process or trigger further actions. This is very similar to common IoT patterns.
- Use of containerization (via .devcontainer and Dockerfile) and how development environments are standardized.

##### Detailed Labels
- For cloud functions, include file or folder references (for instance “IoT Hub Trigger – from code/functions/soil-moisture-trigger”) to show where the functionality is implemented.

- Use callouts or “zoom-in” insets to showcase specifics such as the differences between implementations on physical devices and virtual devices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Hardware/Device Layer"
        RP("RPi – Sensor/Actuator Code"):::hardware
        WT("Wio Terminal – Embedded Code"):::hardware
        VD("Virtual Device – Emulator Code"):::hardware
    end

    subgraph "Connectivity / Network Layer"
        MQTT("MQTT Protocol"):::connectivity
        CMD("Device Commands"):::connectivity
    end

    subgraph "Cloud IoT Hub & Functions"
        CS("Cloud Server Code"):::cloud
        IHT("IoT Hub Trigger Function"):::cloud
    end

    subgraph "Client/Presentation Layer"
        QA("Quiz App (Web UI)"):::quiz
    end

    subgraph "Development & Curriculum Content"
        CL("Curriculum Labs"):::edu
        ENV("Environment Configuration"):::edu
    end

    %% Data flows from Hardware to Connectivity
    RP -->|"publishes"| MQTT
    WT -->|"publishes"| MQTT
    VD -->|"publishes"| MQTT

    %% Connectivity forwards data to Cloud components
    MQTT -->|"forwards"| CS
    MQTT -->|"forwards"| IHT

    %% Cloud sends commands via Connectivity to Devices
    IHT -->|"sendsCommand"| CMD
    CMD -->|"delivers"| RP
    CMD -->|"delivers"| WT
    CMD -->|"delivers"| VD

    %% Cloud communicates with the Quiz App
    CS -->|"triggersUpdate"| QA
    IHT -->|"triggersUpdate"| QA

    %% Educational Content supports Devices and Cloud
    CL -- "providesLabs" --> RP
    CL -- "providesLabs" --> WT
    CL -- "providesLabs" --> VD
    CL -- "instructions" --> CS

    ENV -- "setupEnvironment" --> CL

    %% Click Events
    click RP "https://github.com/microsoft/iot-for-beginners/blob/main/1-getting-started/lessons/1-introduction-to-iot/code/pi/nightlight/app.py"
    click WT "https://github.com/microsoft/iot-for-beginners/blob/main/1-getting-started/lessons/1-introduction-to-iot/code/wio-terminal/nightlight/platformio.ini"
    click VD "https://github.com/microsoft/iot-for-beginners/blob/main/1-getting-started/lessons/1-introduction-to-iot/code/virtual-device/nightlight/app.py"
    click MQTT "https://github.com/microsoft/iot-for-beginners/tree/main/1-getting-started/lessons/4-connect-internet/code-mqtt"
    click CMD "https://github.com/microsoft/iot-for-beginners/tree/main/1-getting-started/lessons/4-connect-internet/code-commands"
    click CS "https://github.com/microsoft/iot-for-beginners/blob/main/1-getting-started/lessons/4-connect-internet/code-server/server/app.py"
    click IHT "https://github.com/microsoft/iot-for-beginners/blob/main/2-farm/lessons/5-migrate-application-to-the-cloud/code/functions/soil-moisture-trigger/iot-hub-trigger/__init__.py"
    click QA "https://github.com/microsoft/iot-for-beginners/tree/main/quiz-app/"
    click CL "https://github.com/microsoft/iot-for-beginners/tree/main/1-getting-started"
    click ENV "https://github.com/microsoft/iot-for-beginners/blob/main/.devcontainer"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef connectivity fill:#D8BFD8,stroke:#000,stroke-width:2px;
    classDef cloud fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef quiz fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef edu fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
