# lindouch9/esp32-iot-telegram-alert-system architecture

> Architecture diagram of the GitHub repository lindouch9/esp32-iot-telegram-alert-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lindouch9/esp32-iot-telegram-alert-system
- Repository: https://github.com/lindouch9/esp32-iot-telegram-alert-system

## Overview

This is an ESP32 temperature-and-humidity surveillance system with a Python/Telegram gateway. The ESP32 measures and displays readings, sounds a local buzzer at threshold violations, and contacts the gateway; the gateway alerts the user, accepts a “vu” acknowledgment, and triggers a voice call plus a PC alarm if no acknowledgment arrives within 60 seconds. The gateway source was excerpted; firmware behavior and the device-to-gateway exchange are represented from the README, so details beyond those documented are not inferred.

Main entry points: [`esp32_alert_system.ino`](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/esp32_alert_system.ino) (Monitor and display), [`relay_server.py`](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py) (HTTP request handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["ESP32 device"]
  node_sensor{{"DHT22 sensor"}}
  node_firmware["Monitor and display"]
  node_lcd["LCD display"]
  node_buzzer["Local buzzer"]
end

subgraph group_gateway["Python gateway"]
  node_handler["HTTP request handler<br/>[relay_server.py]"]
  node_telegram_listener["Telegram response listener<br/>[relay_server.py]"]
  node_logging[("Alert history logging<br/>[relay_server.py]")]
end

subgraph group_alerts["Alert delivery"]
  node_message_sender["Alert message sender<br/>[relay_server.py]"]
  node_call_dispatch["Voice call dispatch<br/>[relay_server.py]"]
  node_pc_alarm["PC sound and speech alarm<br/>[relay_server.py]"]
end

node_user(("User"))
node_telegram["Telegram"]
node_call_service["CallMeBot"]

node_sensor -->|"provides readings"| node_firmware
node_firmware -->|"displays readings"| node_lcd
node_firmware -->|"sounds on threshold"| node_buzzer
node_firmware -->|"sends alert requests"| node_handler
node_user -->|"replies “vu”"| node_telegram
node_telegram -->|"provides updates"| node_telegram_listener
node_handler -->|"records events"| node_logging
node_telegram_listener -->|"records acknowledgment"| node_logging
node_handler -->|"sends alert message"| node_message_sender
node_telegram_listener -->|"confirms acknowledgment"| node_message_sender
node_handler -->|"dispatches after timeout"| node_call_dispatch
node_call_dispatch -->|"starts local alarm"| node_pc_alarm
node_message_sender -->|"sends message"| node_telegram
node_message_sender -->|"fallback message"| node_call_service
node_call_dispatch -->|"requests voice call"| node_call_service

click node_firmware "https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/esp32_alert_system.ino"
click node_handler "https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py"
click node_telegram_listener "https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py"
click node_logging "https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py"
click node_message_sender "https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py"
click node_call_dispatch "https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py"
click node_pc_alarm "https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sensor,node_firmware,node_lcd,node_buzzer,node_user toneBlue
class node_handler,node_telegram_listener,node_logging toneAmber
class node_message_sender,node_call_dispatch,node_pc_alarm toneMint
class node_telegram,node_call_service toneIndigo
```

## Components

### ESP32 device

- **DHT22 sensor**
- [Monitor and display](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/esp32_alert_system.ino): `esp32_alert_system.ino`
- **LCD display**
- **Local buzzer**

### Python gateway

- [HTTP request handler](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py): `relay_server.py`
- [Telegram response listener](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py): `relay_server.py`
- [Alert history logging](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py): `relay_server.py`

### Alert delivery

- [Alert message sender](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py): `relay_server.py`
- [Voice call dispatch](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py): `relay_server.py`
- [PC sound and speech alarm](https://github.com/lindouch9/esp32-iot-telegram-alert-system/blob/main/relay_server.py): `relay_server.py`

### Other components

- **User**
- **Telegram**
- **CallMeBot**

## Connections

- DHT22 sensor → Monitor and display: provides readings (evidence: `README.md`)
- Monitor and display → LCD display: displays readings (evidence: `README.md`)
- Monitor and display → Local buzzer: sounds on threshold (evidence: `README.md`)
- Monitor and display → HTTP request handler: sends alert requests (evidence: `README.md`)
- User → Telegram: replies “vu” (evidence: `README.md`)
- Telegram → Telegram response listener: provides updates (evidence: `relay_server.py`)
- HTTP request handler → Alert history logging: records events (evidence: `relay_server.py`)
- Telegram response listener → Alert history logging: records acknowledgment (evidence: `relay_server.py`)
- HTTP request handler → Alert message sender: sends alert message (evidence: `relay_server.py`)
- Telegram response listener → Alert message sender: confirms acknowledgment (evidence: `relay_server.py`)
- HTTP request handler → Voice call dispatch: dispatches after timeout (evidence: `relay_server.py`)
- Voice call dispatch → PC sound and speech alarm: starts local alarm (evidence: `relay_server.py`)
- Alert message sender → Telegram: sends message (evidence: `relay_server.py`)
- Alert message sender → CallMeBot: fallback message (evidence: `relay_server.py`)
- Voice call dispatch → CallMeBot: requests voice call (evidence: `relay_server.py`)
