# suyamagunaratne/greenpulse architecture

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

- Interactive diagram: https://gitdiagram.com/suyamagunaratne/greenpulse
- Repository: https://github.com/suyamagunaratne/greenpulse

## Overview

GreenPulse is a Python cloud backend for receiving and displaying IoT plant sensor readings. The documented main flow starts with the ESP32 publishing sensor JSON through AWS IoT Core; the backend connects using TLS, subscribes to the sensor topic after connection, then decodes, parses, extracts, and prints readings. The repository contains no implementation of the firmware, AWS service, persistence, care recommendations, alerts, or a Flask interface; README describes care, alerts, and status topics as reserved. The graph is based on the README and the sole sampled source file, app.py.

Main entry points: [`app.py`](https://github.com/suyamagunaratne/greenpulse/blob/main/app.py) (MQTT Backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["MQTT Ingestion"]
  node_backend["MQTT Backend<br/>[app.py]"]
  node_subscription["Sensor Subscription<br/>[app.py]"]
end

subgraph group_processing["Message Processing"]
  node_payload["JSON Parsing<br/>[app.py]"]
  node_extraction["Reading Extraction<br/>[app.py]"]
  node_display["Console Output<br/>[app.py]"]
end

node_esp32(("ESP32 Device"))
node_aws{{"AWS IoT Core"}}

node_esp32 -->|"publishes sensor JSON"| node_aws
node_aws -->|"forwards MQTT"| node_backend
node_backend -->|"connects TLS"| node_aws
node_backend -->|"registers callback"| node_subscription
node_subscription -->|"subscribes topic"| node_aws
node_backend -->|"routes messages"| node_payload
node_payload -->|"extracts readings"| node_extraction
node_extraction -->|"prints values"| node_display

click node_backend "https://github.com/suyamagunaratne/greenpulse/blob/main/app.py"
click node_subscription "https://github.com/suyamagunaratne/greenpulse/blob/main/app.py"
click node_payload "https://github.com/suyamagunaratne/greenpulse/blob/main/app.py"
click node_extraction "https://github.com/suyamagunaratne/greenpulse/blob/main/app.py"
click node_display "https://github.com/suyamagunaratne/greenpulse/blob/main/app.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_backend,node_subscription toneBlue
class node_payload,node_extraction,node_display toneAmber
class node_esp32,node_aws toneIndigo
```

## Components

### MQTT Ingestion

- [MQTT Backend](https://github.com/suyamagunaratne/greenpulse/blob/main/app.py): `app.py`
- [Sensor Subscription](https://github.com/suyamagunaratne/greenpulse/blob/main/app.py): `app.py`

### Message Processing

- [JSON Parsing](https://github.com/suyamagunaratne/greenpulse/blob/main/app.py): `app.py`
- [Reading Extraction](https://github.com/suyamagunaratne/greenpulse/blob/main/app.py): `app.py`
- [Console Output](https://github.com/suyamagunaratne/greenpulse/blob/main/app.py): `app.py`

### Other components

- **ESP32 Device**
- **AWS IoT Core**

## Connections

- ESP32 Device → AWS IoT Core: publishes sensor JSON (evidence: `README.md`)
- AWS IoT Core → MQTT Backend: forwards MQTT (evidence: `README.md`)
- MQTT Backend → AWS IoT Core: connects TLS (evidence: `app.py`)
- MQTT Backend → Sensor Subscription: registers callback (evidence: `app.py`)
- Sensor Subscription → AWS IoT Core: subscribes topic (evidence: `app.py`)
- MQTT Backend → JSON Parsing: routes messages (evidence: `app.py`)
- JSON Parsing → Reading Extraction: extracts readings (evidence: `app.py`)
- Reading Extraction → Console Output: prints values (evidence: `app.py`)
