# ducthang321/embedded-system architecture

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

- Interactive diagram: https://gitdiagram.com/ducthang321/embedded-system
- Repository: https://github.com/ducthang321/embedded-system

## Overview

##### Project Type & Purpose
- The core of the project centers around embedded firmware for hardware control. There are firmware files for STM32 platforms (e.g., Button-Relay/main.c, Button-Relay/main.h, stm32f1xx_it.c, stm32uart.c) and an Arduino sketch for the ESP32 (esp32uart.ino).
- Supporting files such as liquidcrystal_i2c.c/h indicate that the system uses an I2C-controlled LCD display.
- There is a web-based or server-side component evidenced by PHP files (get.php, view.php) and a database script (database.sql), which may serve as an interface or visualization of system data. The presence of platformio.ini highlights the use of PlatformIO as a development tool for embedded projects.
- Overall, the project likely controls a button relay (hardware switching via buttons) and communicates system states/data to an external application or server (via UART or another communication protocol).

##### Analyzing the File Structure for Architectural Insights
- Embedded Firmware: The “Button-Relay” directory and associated main firmware files for STM32 indicate the core embedded functionality.
- Peripheral/Driver Libraries: The liquidcrystal_i2c files are libraries to drive an LCD display.
- Communication Modules: Files like stm32uart.c and esp32uart.ino suggest UART communication implementations on multiple platforms.
- Web Components: The get.php and view.php files, along with database.sql, hint at a web interface or backend logging/monitoring component.
- Additional Build/Configuration: The platformio.ini sets up project configurations for PlatformIO, and the “template code” folder could be offering reusable examples or base code for new features.

##### Elements
– Clear labels for each component: “STM32 Controller”, “ESP32 Controller”, “LCD Display (I2C)”, “UART Communication Interface”, “Web Server (PHP)”, “Database”, and “PlatformIO Build Environment”.
– Include any middleware or communication modules if applicable.
– Finally, add annotations that specify protocols (e.g., "UART", "I2C") and any communication details.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Embedded Firmware"
        stm32["STM32 Controller"]:::hardware
        esp32["ESP32 Controller"]:::hardware
        lcd["LCD Display (I2C)"]:::peripheral
        uart["UART Communication Interface"]:::comm
    end

    subgraph "Backend & Server"
        web["Web Server (PHP)"]:::server
        db["Database"]:::database
    end

    subgraph "Development & Tools"
        pio["PlatformIO Build"]:::tool
        template["Template Code"]:::tool
    end

    stm32 -->|"UART"| uart
    esp32 -->|"UART"| uart
    stm32 -->|"I2C"| lcd
    uart -->|"dataFlow"| web
    web -->|"query"| db
    pio -->|"configures"| stm32
    pio -->|"configures"| esp32
    template -->|"scaffolds"| stm32
    template -->|"scaffolds"| esp32

    click stm32 "https://github.com/ducthang321/embedded-system/blob/master/Button-Relay/main.c"
    click esp32 "https://github.com/ducthang321/embedded-system/blob/master/esp32uart.ino"
    click lcd "https://github.com/ducthang321/embedded-system/blob/master/liquidcrystal_i2c.c"
    click web "https://github.com/ducthang321/embedded-system/blob/master/get.php"
    click db "https://github.com/ducthang321/embedded-system/blob/master/database.sql"
    click pio "https://github.com/ducthang321/embedded-system/blob/master/platformio.ini"
    click template "https://github.com/ducthang321/embedded-system/tree/master/template code"

    classDef hardware fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef peripheral fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef comm fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef server fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef database fill:#ffeeba,stroke:#333,stroke-width:2px;
    classDef tool fill:#e2e3e5,stroke:#333,stroke-width:2px;
```
