# ironwolf437/smart-greenhouse architecture

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

- Interactive diagram: https://gitdiagram.com/ironwolf437/smart-greenhouse
- Repository: https://github.com/ironwolf437/smart-greenhouse

## Overview

Smart Greenhouse combines ESP32-based environmental monitoring and control with a Raspberry Pi runtime for telemetry logging, camera surveillance, and scheduled or manually triggered plant-disease detection. Its principal workflow runs from sensor readings over serial to logging, while the Pi can also send configuration back to the ESP32. The README documents Telegram remote management and automated boot services; the Telegram implementation is not sampled, so its internal interactions are left unspecified. Firmware behavior is inferred from filenames and README rather than sampled source.

Main entry points: [`Pi code/main.py`](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/main.py) (Runtime Orchestrator), [`ESP32 code/greenhouse_test.ino`](https://github.com/ironwolf437/smart-greenhouse/blob/main/ESP32%20code/greenhouse_test.ino) (ESP32 Firmware), [`Pi code/database.py`](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/database.py) (Telemetry and Detection Logging), [`Pi code/cam.py`](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/cam.py) (Camera Capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Greenhouse Control"]
  node_sensors["Sensors"]
  node_actuators["Relays and Actuators"]
  node_esp32["ESP32 Firmware"]
end

subgraph group_pi["Raspberry Pi Runtime"]
  node_pi_main["Runtime Orchestrator<br/>[main.py]"]
  node_serial["Serial Link<br/>[main.py]"]
  node_log_logic["Telemetry and Detection Logging<br/>[database.py]"]
  node_csv_logs[("Greenhouse CSV Logs<br/>[database.py]")]
end

subgraph group_vision["Plant Health Vision"]
  node_camera["Camera Capture<br/>[cam.py]"]
  node_model["YOLO Detector<br/>[best.pt]"]
  node_training["Disease Model Workflow"]
end

subgraph group_remote["Remote Management"]
  node_telegram_bot["Telegram Bot<br/>[tlg_test.py]"]
end

node_environment(("Greenhouse Environment"))
node_telegram_user(("Telegram User"))

node_environment -->|"measured by"| node_sensors
node_sensors -->|"sensor readings"| node_esp32
node_esp32 -->|"controls"| node_actuators
node_actuators -->|"adjusts"| node_environment
node_esp32 -->|"sends telemetry"| node_serial
node_serial -->|"delivers telemetry"| node_pi_main
node_pi_main -->|"writes configuration"| node_serial
node_serial -->|"forwards configuration"| node_esp32
node_pi_main -->|"runs detection"| node_camera
node_camera -->|"runs inference"| node_model
node_training -.->|"produces weights"| node_model
node_pi_main -->|"formats records"| node_log_logic
node_log_logic -->|"records motion video"| node_camera
node_log_logic -->|"appends records"| node_csv_logs
node_telegram_user -.->|"remote management"| node_telegram_bot

click node_sensors "https://github.com/ironwolf437/smart-greenhouse/blob/main/ESP32%20code/greenhouse_test.ino"
click node_actuators "https://github.com/ironwolf437/smart-greenhouse/blob/main/ESP32%20code/greenhouse_test.ino"
click node_esp32 "https://github.com/ironwolf437/smart-greenhouse/blob/main/ESP32%20code/greenhouse_test.ino"
click node_pi_main "https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/main.py"
click node_serial "https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/main.py"
click node_camera "https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/cam.py"
click node_model "https://github.com/ironwolf437/smart-greenhouse/blob/main/AI/train/weights/best.pt"
click node_training "https://github.com/ironwolf437/smart-greenhouse/blob/main/AI/plant-disease-detection-yolov11.ipynb"
click node_log_logic "https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/database.py"
click node_csv_logs "https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/database.py"
click node_telegram_bot "https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/tlg_test.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_sensors,node_actuators,node_esp32,node_telegram_user toneBlue
class node_pi_main,node_serial,node_log_logic,node_csv_logs toneAmber
class node_camera,node_model,node_training toneMint
class node_telegram_bot toneRose
class node_environment toneIndigo
```

## Components

### Greenhouse Control

- [Sensors](https://github.com/ironwolf437/smart-greenhouse/blob/main/ESP32%20code/greenhouse_test.ino): `ESP32 code/greenhouse_test.ino`
- [Relays and Actuators](https://github.com/ironwolf437/smart-greenhouse/blob/main/ESP32%20code/greenhouse_test.ino): `ESP32 code/greenhouse_test.ino`
- [ESP32 Firmware](https://github.com/ironwolf437/smart-greenhouse/blob/main/ESP32%20code/greenhouse_test.ino): `ESP32 code/greenhouse_test.ino`

### Raspberry Pi Runtime

- [Runtime Orchestrator](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/main.py): `Pi code/main.py`
- [Serial Link](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/main.py): `Pi code/main.py`
- [Telemetry and Detection Logging](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/database.py): `Pi code/database.py`
- [Greenhouse CSV Logs](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/database.py): `Pi code/database.py`

### Plant Health Vision

- [Camera Capture](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/cam.py): `Pi code/cam.py`
- [YOLO Detector](https://github.com/ironwolf437/smart-greenhouse/blob/main/AI/train/weights/best.pt): `AI/train/weights/best.pt`
- [Disease Model Workflow](https://github.com/ironwolf437/smart-greenhouse/blob/main/AI/plant-disease-detection-yolov11.ipynb): `AI/plant-disease-detection-yolov11.ipynb`

### Remote Management

- [Telegram Bot](https://github.com/ironwolf437/smart-greenhouse/blob/main/Pi%20code/tlg_test.py): `Pi code/tlg_test.py`

### Other components

- **Greenhouse Environment**
- **Telegram User**

## Connections

- Greenhouse Environment → Sensors: measured by
- Sensors → ESP32 Firmware: sensor readings
- ESP32 Firmware → Relays and Actuators: controls
- Relays and Actuators → Greenhouse Environment: adjusts
- ESP32 Firmware → Serial Link: sends telemetry
- Serial Link → Runtime Orchestrator: delivers telemetry
- Runtime Orchestrator → Serial Link: writes configuration
- Serial Link → ESP32 Firmware: forwards configuration
- Runtime Orchestrator → Camera Capture: runs detection
- Camera Capture → YOLO Detector: runs inference
- Disease Model Workflow → YOLO Detector: produces weights
- Runtime Orchestrator → Telemetry and Detection Logging: formats records
- Telemetry and Detection Logging → Camera Capture: records motion video
- Telemetry and Detection Logging → Greenhouse CSV Logs: appends records
- Telegram User → Telegram Bot: remote management
