# nix-ui/practica_2_iot architecture

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

- Interactive diagram: https://gitdiagram.com/nix-ui/practica_2_iot
- Repository: https://github.com/nix-ui/practica_2_iot

## Overview

##### Project Type and Purpose
- This project is an IoT application designed to control LEDs and capture sensor data, using ESP32 boards for both LED management (esp_leds) and sensor data capture (esp_sensor).

##### Main Components
- Hardware Modules:
- ESP32 for LED control (contained in the esp_leds folder) with supporting classes: Led, LedController, LedExecute, and a ServerClient communication module.
- ESP32 for sensor measurement (contained in the esp_sensor folder) which uses classes like UltraSonicSensor and SensorExecute, as well as its own ServerClient module.
- Communication/Networking:
- A common ServerClient component used by both ESP software components.
- The server (server.py) which acts as the central orchestrator to receive sensor readings, update LED states, and manage the protocol commands (GET, POST, UPDATE).
- Additional Supporting Items:

##### Methodology to Represent the System
- Shared modules (ServerClient) as connecting sub-components within both nodes.

b. Establish the Relationships and Data Flow:

c. Internal architectural abstractions:

d. Mention the Key Technologies and Protocols:
- That the server.py (likely running on a standard server platform) manages connections through a WiFi network.

##### Architectural Pattern and Design Principles
- This project demonstrates a modular microcontroller-based design where each ESP32 unit encapsulates its own functions (actuator or sensor) while sharing a common communication protocol.
- The separation between the IoT edge nodes and the central server emphasizes decoupled design and real-time communication.
- The use of classes and defined protocols indicates adherence to principles of modularity and layered architecture.

##### Practical Steps
- Communication methods (ServerClient usage) and indicate the WiFi network as the medium for the data flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Central Server Component
    central["Server – ESPCRUDProtocol"]:::server

    %% LED Node Subgraph
    subgraph "ESP32 – LED Node"
        LED1["Led"]:::hardware
        LED2["LedController"]:::hardware
        LED3["LedExecute"]:::hardware
        LED4["ServerClient"]:::hardware
        LED5["esp_leds.ino"]:::hardware
    end

    %% Sensor Node Subgraph
    subgraph "ESP32 – Sensor Node"
        SEN1["UltraSonicSensor"]:::hardware
        SEN2["SensorExecute"]:::hardware
        SEN3["ServerClient"]:::hardware
        SEN4["esp_sensor.ino"]:::hardware
    end

    %% Communication Flows
    LED4 -->|"POST_LED"| central
    central -->|"UPDATE_LED"| LED4
    SEN3 -->|"UPDATE_SENSOR"| central
    central -->|"GET_INTERVALS"| SEN3

    %% Styles
    classDef server fill:#ffecb3,stroke:#ff9800,stroke-width:2px;
    classDef hardware fill:#e0f7fa,stroke:#00796b,stroke-width:2px;

    %% Click Events for LED Node Components
    click LED1 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_leds/Led.hpp"
    click LED2 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_leds/LedController.hpp"
    click LED3 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_leds/LedExecute.hpp"
    click LED4 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_leds/ServerClient.hpp"
    click LED5 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_leds/esp_leds.ino"

    %% Click Events for Sensor Node Components
    click SEN1 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_sensor/UltraSonicSensor.hpp"
    click SEN2 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_sensor/SensorExecute.hpp"
    click SEN3 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_sensor/ServerClient.hpp"
    click SEN4 "https://github.com/nix-ui/practica_2_iot/blob/main/esp_sensor/esp_sensor.ino"

    %% Click Event for Central Server Component
    click central "https://github.com/nix-ui/practica_2_iot/blob/main/server.py"
```
