# rubens05/tfg architecture

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

- Interactive diagram: https://gitdiagram.com/rubens05/tfg
- Repository: https://github.com/rubens05/tfg

## Overview

##### Project type and purpose
- This is an IoT telemetry testbench tying together embedded firmware (ESP32 + FreeRTOS), a custom Python logging library, a Docker-based data pipeline (Mosquitto → Telegraf → MongoDB), plus InfluxDB experiments.
- Primary flow: ESP32 publishes telemetry via MQTT → Mosquitto broker → Telegraf collects and writes to MongoDB.

##### File structure
- codigo/FreeRTOS: FreeRTOS C++ examples (parallel tasks, queues).
- codigo/Python_LIBRERIA: Custom Python logging library (loggingrg), setup scripts, tests.
- codigo/InfluxDB: Python scripts to insert/consume data in InfluxDB.
- codigo/docker-compose: docker-compose.yml + configs (mosquitto.conf, telegraf.conf).
- codigo/pruebasMQTT_src_placas: ESP32 C++ examples for single/multi-topic MQTT.
- src/main.cpp & platformio.ini: main embedded firmware project.

##### Extract architectural insights from README
- Docker services:
- mqtt5 (Mosquitto broker with auth)
- telegraf (MQTT input → MongoDB output)
- mongo-container (MongoDB with root user)
- External repos (not in this tree): RemoteLogLibrary (firmware logging library) and RemoteLogLibraryUI (GUI).
- Setup steps for Mosquitto auth, MongoDB users, Telegraf input/output.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Embedded Layer
    subgraph "Embedded Layer"
        ESP32Client["ESP32 FreeRTOS Client"]:::embedded
        subgraph "MQTT Sketches"
            EM1["emisor_singletopic.cpp"]:::embedded
            EM2["emisor_multitopic.cpp"]:::embedded
            MAC["MAC.cpp"]:::embedded
            INFO["info.txt"]:::embedded
        end
        subgraph "FreeRTOS Examples"
            FR1["Tareas_Paralelas.cpp"]:::embedded
            FR2["Colas_Paralelas.cpp"]:::embedded
            FR3["FullParalelismo.cpp"]:::embedded
        end
    end

    %% Messaging Layer
    subgraph "Messaging Layer"
        Mosquitto["Mosquitto MQTT Broker"]:::messaging
        MosqConf["mosquitto.conf"]:::messaging
    end

    %% Processing Layer
    subgraph "Processing Layer"
        Telegraf["Telegraf Collector"]:::processing
        TelegrafConf["telegraf.conf"]:::processing
    end

    %% Storage Layer
    subgraph "Storage Layer"
        MongoDB["MongoDB"]:::storage
        InfluxDB["InfluxDB"]:::storage
    end

    %% Tools & Scripts
    subgraph "Tools & Scripts"
        PythonLibBase["setup.py"]:::tools
        Init["__init__.py"]:::tools
        Func["funcionalidades.py"]:::tools
        LibPy["libreria.py"]:::tools
        TestPy["test.py"]:::tools
        Compose["docker-compose.yml"]:::tools
        Insert["insertInfluxdb.py"]:::tools
        Consume["consumeInfluxdb.py"]:::tools
        GUI["RemoteLogLibraryUI GUI"]:::tools
    end

    %% Data Flows
    ESP32Client -->|"publishes MQTT"| Mosquitto
    EM1 --> Mosquitto
    EM2 --> Mosquitto
    MAC --> Mosquitto
    INFO --> Mosquitto

    Mosquitto -->|"subscribed by"| Telegraf
    Telegraf -->|"writes to"| MongoDB
    MongoDB -->|"visualized by"| GUI

    Insert <-->|"TSDB experiment"| InfluxDB
    Consume <-->|"TSDB experiment"| InfluxDB

    %% Click Events
    click ESP32Client "https://github.com/rubens05/tfg/blob/master/src/main.cpp"
    click ESP32Client "https://github.com/rubens05/tfg/blob/master/platformio.ini"
    click EM1 "https://github.com/rubens05/tfg/blob/master/codigo/pruebasMQTT_src_placas/emisor_singletopic.cpp"
    click EM2 "https://github.com/rubens05/tfg/blob/master/codigo/pruebasMQTT_src_placas/emisor_multitopic.cpp"
    click MAC "https://github.com/rubens05/tfg/blob/master/codigo/pruebasMQTT_src_placas/MAC.cpp"
    click INFO "https://github.com/rubens05/tfg/blob/master/codigo/pruebasMQTT_src_placas/info.txt"
    click FR1 "https://github.com/rubens05/tfg/blob/master/codigo/FreeRTOS/Tareas_Paralelas.cpp"
    click FR2 "https://github.com/rubens05/tfg/blob/master/codigo/FreeRTOS/Colas_Paralelas.cpp"
    click FR3 "https://github.com/rubens05/tfg/blob/master/codigo/FreeRTOS/FullParalelismo.cpp"
    click PythonLibBase "https://github.com/rubens05/tfg/blob/master/codigo/Python_LIBRERIA/loggingrg-base/setup.py"
    click Init "https://github.com/rubens05/tfg/blob/master/codigo/Python_LIBRERIA/loggingrg-base/loggingrg/__init__.py"
    click Func "https://github.com/rubens05/tfg/blob/master/codigo/Python_LIBRERIA/loggingrg-base/loggingrg/funcionalidades.py"
    click LibPy "https://github.com/rubens05/tfg/blob/master/codigo/Python_LIBRERIA/libreria.py"
    click TestPy "https://github.com/rubens05/tfg/blob/master/codigo/Python_LIBRERIA/test.py"
    click Compose "https://github.com/rubens05/tfg/blob/master/codigo/docker-compose/docker-compose.yml"
    click MosqConf "https://github.com/rubens05/tfg/blob/master/codigo/docker-compose/config/mosquitto.conf"
    click TelegrafConf "https://github.com/rubens05/tfg/blob/master/codigo/docker-compose/telegraf.conf"
    click Insert "https://github.com/rubens05/tfg/blob/master/codigo/InfluxDB/insertInfluxdb.py"
    click Consume "https://github.com/rubens05/tfg/blob/master/codigo/InfluxDB/consumeInfluxdb.py"

    %% Styles
    classDef embedded fill:#e0f7fa,stroke:#0277bd,color:#000
    classDef messaging fill:#ffe0b2,stroke:#ef6c00,color:#000
    classDef processing fill:#c8e6c9,stroke:#2e7d32,color:#000
    classDef storage fill:#ffcdd2,stroke:#c62828,color:#000
    classDef tools fill:#e0e0e0,stroke:#616161,color:#000
```
