# python-iot/smart-iot-planting-system architecture

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

- Interactive diagram: https://gitdiagram.com/python-iot/smart-iot-planting-system
- Repository: https://github.com/python-iot/smart-iot-planting-system

## Overview

SIPS is an IoT greenhouse monitoring and control system spanning MCU devices, a Raspberry Pi gateway, and a Django-based cloud service. The runtime workflow begins with device-side sensing and actuation, passes device messages over LoRa to the gateway, and connects the gateway to cloud services over MQTT/HTTP; users monitor and control the system through the browser UI. README-documented capabilities include device tracking, scheduled/manual/automatic lighting and irrigation, security alarms, and gateway database-file management. Device and gateway code is sampled; cloud workflow details and several gateway features are documented but not shown in source excerpts.

Main entry points: [`device/src/main.py`](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/main.py) (Device Runtime), [`gateway/src/main.py`](https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/main.py) (Gateway Runtime), [`cloud/platform/sips`](https://github.com/python-iot/smart-iot-planting-system/tree/master/cloud/platform/sips) (Django Web Service), [`device/src/LoRa.py`](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/LoRa.py) (Device LoRa Link)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Field Device"]
  node_device_runtime["Device Runtime<br/>[main.py]"]
  node_light_sensor["Light Sensor<br/>[LightIntensity.py]"]
  node_moisture_sensor["Soil Moisture<br/>[moisture.py]"]
  node_rain_sensor["Rain Sensor<br/>[rainfall.py]"]
  node_water_sensor["Water Level<br/>[WaterLevel.py]"]
  node_security_sensor["Motion Sensor<br/>[security.py]"]
  node_irrigation["Pump Control<br/>[irrigate.py]"]
  node_device_lora["Device LoRa Link<br/>[LoRa.py]"]
end

subgraph group_gateway["Gateway"]
  node_gateway_runtime["Gateway Runtime<br/>[main.py]"]
  node_gateway_lora["Gateway LoRa Link<br/>[LoRa.py]"]
  node_gateway_store[("Gateway Database<br/>[database.py]")]
  node_file_management["Database File Management<br/>[backup_db.py]"]
end

subgraph group_cloud["Cloud Services"]
  node_cloud_portal["Django Web Service"]
  node_mqtt_publish["MQTT Publisher<br/>[pub.py]"]
  node_mqtt_subscribe["MQTT Subscriber<br/>[sub.py]"]
  node_cloud_store[("Cloud SQL Access<br/>[database.py]")]
  node_charts["Monitoring Charts<br/>[echarts-python.py]"]
end

subgraph group_user["User Interface"]
  node_browser["Browser UI"]
end

node_operator(("Greenhouse Operator"))

node_device_runtime -->|"reads"| node_light_sensor
node_device_runtime -->|"reads"| node_moisture_sensor
node_device_runtime -->|"reads"| node_rain_sensor
node_device_runtime -->|"reads"| node_water_sensor
node_device_runtime -->|"reads"| node_security_sensor
node_device_runtime -->|"controls"| node_irrigation
node_device_runtime -.->|"uses"| node_device_lora
node_device_lora -.->|"sends over LoRa"| node_gateway_lora
node_gateway_runtime -->|"receives"| node_gateway_lora
node_gateway_lora -.->|"replies over LoRa"| node_device_lora
node_gateway_runtime -.->|"exchanges via MQTT/HTTP"| node_mqtt_publish
node_mqtt_subscribe -.->|"forwards commands"| node_gateway_runtime
node_gateway_runtime -.->|"persists device data"| node_gateway_store
node_operator -->|"uses"| node_browser
node_browser -->|"accesses"| node_cloud_portal
node_cloud_portal -.->|"shows monitoring"| node_charts
node_cloud_portal -.->|"reads system data"| node_cloud_store
node_operator -.->|"controls planting"| node_cloud_portal
node_gateway_runtime -.->|"supports backup"| node_file_management

click node_device_runtime "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/main.py"
click node_light_sensor "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/LightIntensity.py"
click node_moisture_sensor "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/moisture.py"
click node_rain_sensor "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/rainfall.py"
click node_water_sensor "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/WaterLevel.py"
click node_security_sensor "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/security.py"
click node_irrigation "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/irrigate.py"
click node_device_lora "https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/LoRa.py"
click node_gateway_runtime "https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/main.py"
click node_gateway_lora "https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/LoRa.py"
click node_gateway_store "https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/database.py"
click node_file_management "https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/backup_db.py"
click node_cloud_portal "https://github.com/python-iot/smart-iot-planting-system/tree/master/cloud/platform/sips"
click node_mqtt_publish "https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/mqtt_server/pub.py"
click node_mqtt_subscribe "https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/mqtt_server/sub.py"
click node_cloud_store "https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/database.py"
click node_charts "https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/echarts-python.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_device_runtime,node_light_sensor,node_moisture_sensor,node_rain_sensor,node_water_sensor,node_security_sensor,node_irrigation,node_device_lora toneBlue
class node_gateway_runtime,node_gateway_lora,node_gateway_store,node_file_management toneAmber
class node_cloud_portal,node_mqtt_publish,node_mqtt_subscribe,node_cloud_store,node_charts toneMint
class node_browser toneRose
class node_operator toneIndigo
```

## Components

### Field Device

- [Device Runtime](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/main.py): `device/src/main.py`
- [Light Sensor](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/LightIntensity.py): `device/src/LightIntensity.py`
- [Soil Moisture](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/moisture.py): `device/src/moisture.py`
- [Rain Sensor](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/rainfall.py): `device/src/rainfall.py`
- [Water Level](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/WaterLevel.py): `device/src/WaterLevel.py`
- [Motion Sensor](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/security.py): `device/src/security.py`
- [Pump Control](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/irrigate.py): `device/src/irrigate.py`
- [Device LoRa Link](https://github.com/python-iot/smart-iot-planting-system/blob/master/device/src/LoRa.py): `device/src/LoRa.py`

### Gateway

- [Gateway Runtime](https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/main.py): `gateway/src/main.py`
- [Gateway LoRa Link](https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/LoRa.py): `gateway/src/LoRa.py`
- [Gateway Database](https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/database.py): `gateway/src/database.py`
- [Database File Management](https://github.com/python-iot/smart-iot-planting-system/blob/master/gateway/src/backup_db.py): `gateway/src/backup_db.py`

### Cloud Services

- [Django Web Service](https://github.com/python-iot/smart-iot-planting-system/tree/master/cloud/platform/sips): `cloud/platform/sips`
- [MQTT Publisher](https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/mqtt_server/pub.py): `cloud/mqtt_server/pub.py`
- [MQTT Subscriber](https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/mqtt_server/sub.py): `cloud/mqtt_server/sub.py`
- [Cloud SQL Access](https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/database.py): `cloud/database.py`
- [Monitoring Charts](https://github.com/python-iot/smart-iot-planting-system/blob/master/cloud/echarts-python.py): `cloud/echarts-python.py`

### User Interface

- **Browser UI**

### Other components

- **Greenhouse Operator**

## Connections

- Device Runtime → Light Sensor: reads (evidence: `device/src/main.py`)
- Device Runtime → Soil Moisture: reads (evidence: `device/src/main.py`)
- Device Runtime → Rain Sensor: reads (evidence: `device/src/main.py`)
- Device Runtime → Water Level: reads (evidence: `device/src/main.py`)
- Device Runtime → Motion Sensor: reads (evidence: `device/src/main.py`)
- Device Runtime → Pump Control: controls (evidence: `device/src/main.py`)
- Device Runtime → Device LoRa Link: uses
- Device LoRa Link → Gateway LoRa Link: sends over LoRa
- Gateway Runtime → Gateway LoRa Link: receives (evidence: `gateway/src/main.py`)
- Gateway LoRa Link → Device LoRa Link: replies over LoRa
- Gateway Runtime → MQTT Publisher: exchanges via MQTT/HTTP
- MQTT Subscriber → Gateway Runtime: forwards commands
- Gateway Runtime → Gateway Database: persists device data
- Greenhouse Operator → Browser UI: uses
- Browser UI → Django Web Service: accesses
- Django Web Service → Monitoring Charts: shows monitoring
- Django Web Service → Cloud SQL Access: reads system data
- Greenhouse Operator → Django Web Service: controls planting
- Gateway Runtime → Database File Management: supports backup
