# naufalmuafi/iot-project_midterm architecture

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

- Interactive diagram: https://gitdiagram.com/naufalmuafi/iot-project_midterm
- Repository: https://github.com/naufalmuafi/iot-project_midterm

## Overview

##### Project type and purpose
- This is an ESP-IDF based embedded firmware project targeting Espressif ESP32 variants.
- Its purpose is to read temperature/humidity data from a DHT22 sensor and render output on an SSD1306 display.
- The build system is CMake (via `idf.py`), and it follows the ESP-IDF component model.

##### File structure
- Top-level:
- `.devcontainer/` & `.vscode/`: IDE/dev‐container configs
- `CMakeLists.txt`, `sdkconfig`: project root build and configuration
- `components/`: custom user components (DHT22 driver, SSD1306 driver)
- `main/`: application entrypoint (`main.c`) and its CMake setup
- `components/DHT22/`: source + headers for sensor driver
- `components/ssd1306/`: source + headers + projbuild Kconfig for display driver
- `build/`: generated build artifacts, partition table, bootloader, libraries

##### README
- Confirms this is the simplest “create-project” template example for ESP-IDF.
- Explains use of CMakeLists to declare source files and targets.

##### Detailed elements to capture
- **Bootloader**: small IDF bootloader image, configuration
- **Partition Table**: addresses of bootloader, app, NVS, etc.
- **Application**: main task + RTOS scheduler
- **Peripherals**: I2C driver instance, GPIO drivers
- **Components**: include header/implementation grouping

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build Artifacts
    subgraph "Build Artifacts"
        Bootloader["Bootloader"]:::build
        PartitionTable["Partition Table"]:::build
    end

    %% Application Layer
    subgraph "Application Layer"
        AppFirmware["Application Firmware (main)"]:::application
        AppCMake["Application CMakeLists.txt"]:::build
    end

    %% Components
    subgraph "Components"
        subgraph "DHT22 Component"
            DHT22_c["DHT22.c"]:::component
            DHT22_h["DHT22.h"]:::component
            DHT22_cm["CMakeLists.txt"]:::build
        end
        subgraph "SSD1306 Component"
            SSD_src["ssd1306.c"]:::component
            SSD_i2c["ssd1306_i2c.c"]:::component
            SSD_spi["ssd1306_spi.c"]:::component
            SSD_h["ssd1306.h"]:::component
            SSD_cm["CMakeLists.txt"]:::build
            SSD_kconf["Kconfig.projbuild"]:::build
            SSD_font["font8x8_basic.h"]:::component
        end
    end

    %% ESP-IDF Framework
    subgraph "ESP-IDF Framework"
        ESP_System["esp_system"]:::framework
        FreeRTOS["FreeRTOS"]:::framework
        Driver["Peripheral Drivers"]:::framework
        lwIP["lwIP"]:::framework
    end

    %% Hardware
    subgraph "Hardware"
        BootROM["Boot ROM"]:::hardware
        MCU["ESP32 Xtensa Core + Flash + RAM"]:::hardware
        Sensor["DHT22 Sensor (GPIO)"]:::hardwareDev
        Display["SSD1306 Display (I2C/SPI)"]:::hardwareDev
    end

    %% Connections
    BootROM -->|reset→| Bootloader
    Bootloader -->|"load partitions"| PartitionTable
    PartitionTable -->|"start app"| AppFirmware

    AppFirmware -->|"init system"| ESP_System
    AppFirmware -->|"start scheduler"| FreeRTOS
    AppFirmware -->|"use peripherals"| Driver
    AppFirmware -->|"optional networking"| lwIP

    AppFirmware -->|"read data"| DHT22_c
    DHT22_c -->|"GPIO access"| Driver
    Sensor -->|"signal"| DHT22_c

    AppFirmware -->|"display data"| SSD_src
    SSD_src -->|"I2C/SPI bus"| Driver
    SSD_src --> SSD_i2c
    SSD_src --> SSD_spi
    SSD_h --> SSD_src
    SSD_font --> SSD_src
    Display -->|"pixels"| SSD_src

    %% Build-time link
    AppFirmware --> AppCMake
    DHT22_c --> DHT22_cm
    DHT22_h --> DHT22_cm
    SSD_src --> SSD_cm
    SSD_i2c --> SSD_cm
    SSD_spi --> SSD_cm
    SSD_h --> SSD_cm
    SSD_kconf --> SSD_cm

    %% Click Events
    click Bootloader "https://github.com/naufalmuafi/iot-project_midterm/tree/master/build/bootloader"
    click PartitionTable "https://github.com/naufalmuafi/iot-project_midterm/tree/master/build/partition_table"
    click AppFirmware "https://github.com/naufalmuafi/iot-project_midterm/blob/master/main/main.c"
    click AppCMake "https://github.com/naufalmuafi/iot-project_midterm/blob/master/main/CMakeLists.txt"
    click DHT22_c "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/DHT22/DHT22.c"
    click DHT22_h "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/DHT22/include/DHT22.h"
    click DHT22_cm "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/DHT22/CMakeLists.txt"
    click SSD_src "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/ssd1306/ssd1306.c"
    click SSD_i2c "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/ssd1306/ssd1306_i2c.c"
    click SSD_spi "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/ssd1306/ssd1306_spi.c"
    click SSD_h "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/ssd1306/ssd1306.h"
    click SSD_cm "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/ssd1306/CMakeLists.txt"
    click SSD_kconf "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/ssd1306/Kconfig.projbuild"
    click SSD_font "https://github.com/naufalmuafi/iot-project_midterm/blob/master/components/ssd1306/font8x8_basic.h"
    click FreeRTOS "https://github.com/naufalmuafi/iot-project_midterm/tree/master/build/esp-idf/freertos"
    click Driver "https://github.com/naufalmuafi/iot-project_midterm/tree/master/build/esp-idf/driver"
    click lwIP "https://github.com/naufalmuafi/iot-project_midterm/tree/master/build/esp-idf/lwip"
    click ESP_System "https://github.com/naufalmuafi/iot-project_midterm/tree/master/build/esp-idf/esp_system"
    click RootCMake "https://github.com/naufalmuafi/iot-project_midterm/blob/master/CMakeLists.txt"
    click SDKConfig "https://github.com/naufalmuafi/iot-project_midterm/tree/master/sdkconfig"

    %% Styles
    classDef hardware fill:#dddddd,stroke:#333,stroke-width:1px;
    classDef hardwareDev fill:#eceff1,stroke:#607d8b,stroke-width:1px;
    classDef framework fill:#bbdefb,stroke:#0d47a1,stroke-width:1px;
    classDef component fill:#c8e6c9,stroke:#256029,stroke-width:1px;
    classDef application fill:#dcedc8,stroke:#558b2f,stroke-width:1px;
    classDef build fill:#f0f4c3,stroke:#827717,stroke-width:1px;
```
