# michalsternadel/zbx-esp-env architecture

> Architecture diagram of the GitHub repository michalsternadel/zbx-esp-env, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/michalsternadel/zbx-esp-env
- Repository: https://github.com/michalsternadel/zbx-esp-env

## Overview

##### Hardware Layer
- ESP8266 Microcontroller
- DHT11 Sensors (multiple, as the system supports multiple sensors)
- Physical connections (3.3V, GND, Data pins)

##### Software Components
- Main Application (zbx-esp-env.ino)
- Sensor Management (sensors.h)
- WiFi Configuration (wificonfig.h)
- Web Server (ESPAsyncWebServer)

##### External Systems
- Zabbix Monitoring Server
- Web Browsers (for direct access)

##### Use a Multi-Layer Approach
- Bottom Layer: Hardware components
- Middle Layer: Firmware/Software components
- Top Layer: External interfaces and systems

##### Specific Elements

a. Hardware Section:
- Multiple DHT11 sensors connected to it
- Pin connections

b. Software Section:
- Main application logic
- Sensor management module
- AsyncWebServer component
- WiFi configuration module

c. Interface Section:
- HTTP endpoints (/sensors, /discovery)
- Serial output interface
- Web interface
- JSON API

d. External Systems:
- Zabbix server with template integration
- Web browser access

##### Data Flow Indicators
- Sensor data collection flow
- HTTP request/response paths
- Zabbix monitoring flow
- Serial output path

##### Important Notes
- Supported sensor configurations
- WiFi connectivity requirements
- Auto-discovery capability
- Template integration points

- The IoT nature of the project
- Multiple interface options (Web, Serial, JSON API)
- Integration with Zabbix monitoring
- Scalability with multiple sensors
- Real-time data collection and presentation

- All connection types
- Component types
- Data flow directions
- Protocol indicators

Keep the abstraction level focused on system architecture while including enough detail to show the unique aspects of this environmental monitoring solution, particularly its integration with Zabbix and multiple interface options.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef hardware fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef software fill:#90EE90,stroke:#333,stroke-width:2px
    classDef network fill:#FFA500,stroke:#333,stroke-width:2px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Hardware Layer
    subgraph Hardware
        ESP["ESP8266 MCU"]:::hardware
        DHT1["DHT11 Sensor 1"]:::hardware
        DHT2["DHT11 Sensor 2"]:::hardware
        DHT3["DHT11 Sensor n"]:::hardware
        
        ESP --- DHT1
        ESP --- DHT2
        ESP --- DHT3
    end

    %% Software Layer
    subgraph Firmware
        MAIN["Main Application"]:::software
        SENSOR["Sensor Management"]:::software
        WIFI["WiFi Configuration"]:::software
        WEB["AsyncWebServer"]:::software
        
        MAIN --> SENSOR
        MAIN --> WIFI
        MAIN --> WEB
    end

    %% Interface Layer
    subgraph Interfaces
        HTTP["/sensors API"]:::network
        DISC["/discovery API"]:::network
        SERIAL["Serial Output"]:::network
        WEBUI["Web Interface"]:::network
    end

    %% External Systems
    subgraph External
        ZABBIX["Zabbix Server"]:::external
        BROWSER["Web Browser"]:::external
    end

    %% Connections
    ESP --> MAIN
    WEB --> HTTP
    WEB --> DISC
    WEB --> WEBUI
    MAIN --> SERIAL
    HTTP -.-> ZABBIX
    DISC -.-> ZABBIX
    WEBUI -.-> BROWSER

    %% Legend
    subgraph Legend
        H1["Hardware Component"]:::hardware
        S1["Software Component"]:::software
        N1["Network Interface"]:::network
        E1["External System"]:::external
        
        L1[" "] --> L2[" "] --> L3[" "]
        L4[" "] -.- L5[" "]
        
        style L1 display:none
        style L2 display:none
        style L3 display:none
        style L4 display:none
        style L5 display:none
    end

    %% Click Events
    click MAIN "https://github.com/michalsternadel/zbx-esp-env/blob/master/zbx-esp-env.ino"
    click SENSOR "https://github.com/michalsternadel/zbx-esp-env/blob/master/sensors.h"
    click WIFI "https://github.com/michalsternadel/zbx-esp-env/blob/master/wificonfig-example.h"
    click ZABBIX "https://github.com/michalsternadel/zbx-esp-env/blob/master/zbx-esp-env_template.xml"
```
