# nanak011/iot_ga2 architecture

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

- Interactive diagram: https://gitdiagram.com/nanak011/iot_ga2
- Repository: https://github.com/nanak011/iot_ga2

## Overview

This is a virtual post-flood drinking-water surveillance system: simulated sensor readings are evaluated locally, committed to a SQLite store-and-forward buffer, then synchronized to ThingsBoard over MQTT/TLS. Operators can trigger scenarios and inspect status; ThingsBoard provides cloud-side alarms and dashboards, while metrics tooling evaluates runs. The graph follows the documented workflow and sampled call references; unsampled cloud exports and runtime wiring are included only where README documentation supports them.

Main entry points: [`edge_node.py`](https://github.com/nanak011/iot_ga2/blob/main/edge_node.py) (Fleet runtime), [`metrics.py`](https://github.com/nanak011/iot_ga2/blob/main/metrics.py) (Run metrics), [`provision_thingsboard.py`](https://github.com/nanak011/iot_ga2/blob/main/provision_thingsboard.py) (Device provisioning), [`store.py`](https://github.com/nanak011/iot_ga2/blob/main/store.py) (Reading buffer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge simulation"]
  node_settings["Node settings<br/>[config.py]"]
  node_sites["Node sites<br/>[nodes.json]"]
  node_scenarios["Scenario timelines"]
  node_runtime["Fleet runtime<br/>[edge_node.py]"]
  node_sensor["Sensor model<br/>[sensor_model.py]"]
  node_alarms["Edge alarms<br/>[alarms.py]"]
end

subgraph group_buffer["Local buffering"]
  node_store[("Reading buffer<br/>[store.py]")]
  node_schema["SQLite schema<br/>[schema.sql]"]
  node_transport["MQTT transport<br/>[transport.py]"]
end

subgraph group_cloud["ThingsBoard monitoring"]
  node_thingsboard{{"ThingsBoard"}}
  node_provision["Device provisioning"]
  node_alarm_profile["Cloud alarm profile"]
  node_cloud_rules["Cloud processing rules"]
  node_dashboard["Water quality dashboard"]
end

subgraph group_analysis["Run analysis"]
  node_metrics["Run metrics<br/>[metrics.py]"]
  node_results["Metric results<br/>[metrics.json]"]
end

node_operator(("Operator"))

node_operator -->|"controls"| node_runtime
node_runtime -->|"loads settings"| node_settings
node_runtime -->|"loads sites"| node_sites
node_runtime -->|"plays timeline"| node_scenarios
node_runtime -->|"generates readings"| node_sensor
node_runtime -->|"evaluates alarms"| node_alarms
node_runtime -->|"commits readings"| node_store
node_store -->|"uses schema"| node_schema
node_runtime -->|"syncs backlog"| node_transport
node_transport -->|"publishes telemetry"| node_thingsboard
node_thingsboard -->|"applies alarm rules"| node_alarm_profile
node_thingsboard -->|"processes telemetry"| node_cloud_rules
node_thingsboard -->|"shows monitoring"| node_dashboard
node_provision -->|"provisions devices"| node_thingsboard
node_provision -->|"loads credentials"| node_settings
node_operator -->|"sets up devices"| node_provision
node_operator -->|"runs analysis"| node_metrics
node_metrics -->|"reads edge data"| node_store
node_metrics -->|"fetches cloud data"| node_thingsboard
node_metrics -->|"writes metrics"| node_results

click node_settings "https://github.com/nanak011/iot_ga2/blob/main/config.py"
click node_sites "https://github.com/nanak011/iot_ga2/blob/main/nodes.json"
click node_scenarios "https://github.com/nanak011/iot_ga2/tree/main/scenarios"
click node_runtime "https://github.com/nanak011/iot_ga2/blob/main/edge_node.py"
click node_sensor "https://github.com/nanak011/iot_ga2/blob/main/sensor_model.py"
click node_alarms "https://github.com/nanak011/iot_ga2/blob/main/alarms.py"
click node_store "https://github.com/nanak011/iot_ga2/blob/main/store.py"
click node_schema "https://github.com/nanak011/iot_ga2/blob/main/schema.sql"
click node_transport "https://github.com/nanak011/iot_ga2/blob/main/transport.py"
click node_provision "https://github.com/nanak011/iot_ga2/blob/main/provision_thingsboard.py"
click node_alarm_profile "https://github.com/nanak011/iot_ga2/blob/main/thingsboard/device_profile_water_node.json"
click node_cloud_rules "https://github.com/nanak011/iot_ga2/blob/main/thingsboard/rule_chain_scripts.js"
click node_dashboard "https://github.com/nanak011/iot_ga2/blob/main/thingsboard/dasbhoard_water_quality.json"
click node_metrics "https://github.com/nanak011/iot_ga2/blob/main/metrics.py"
click node_results "https://github.com/nanak011/iot_ga2/blob/main/results/metrics.json"

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_settings,node_sites,node_scenarios,node_runtime,node_sensor,node_alarms toneBlue
class node_store,node_schema,node_transport toneAmber
class node_thingsboard,node_provision,node_alarm_profile,node_cloud_rules,node_dashboard toneMint
class node_metrics,node_results toneRose
class node_operator toneIndigo
```

## Components

### Edge simulation

- [Node settings](https://github.com/nanak011/iot_ga2/blob/main/config.py): `config.py`
- [Node sites](https://github.com/nanak011/iot_ga2/blob/main/nodes.json): `nodes.json`
- [Scenario timelines](https://github.com/nanak011/iot_ga2/tree/main/scenarios): `scenarios`
- [Fleet runtime](https://github.com/nanak011/iot_ga2/blob/main/edge_node.py): `edge_node.py`
- [Sensor model](https://github.com/nanak011/iot_ga2/blob/main/sensor_model.py): `sensor_model.py`
- [Edge alarms](https://github.com/nanak011/iot_ga2/blob/main/alarms.py): `alarms.py`

### Local buffering

- [Reading buffer](https://github.com/nanak011/iot_ga2/blob/main/store.py): `store.py`
- [SQLite schema](https://github.com/nanak011/iot_ga2/blob/main/schema.sql): `schema.sql`
- [MQTT transport](https://github.com/nanak011/iot_ga2/blob/main/transport.py): `transport.py`

### ThingsBoard monitoring

- **ThingsBoard**
- [Device provisioning](https://github.com/nanak011/iot_ga2/blob/main/provision_thingsboard.py): `provision_thingsboard.py`
- [Cloud alarm profile](https://github.com/nanak011/iot_ga2/blob/main/thingsboard/device_profile_water_node.json): `thingsboard/device_profile_water_node.json`
- [Cloud processing rules](https://github.com/nanak011/iot_ga2/blob/main/thingsboard/rule_chain_scripts.js): `thingsboard/rule_chain_scripts.js`
- [Water quality dashboard](https://github.com/nanak011/iot_ga2/blob/main/thingsboard/dasbhoard_water_quality.json): `thingsboard/dasbhoard_water_quality.json`

### Run analysis

- [Run metrics](https://github.com/nanak011/iot_ga2/blob/main/metrics.py): `metrics.py`
- [Metric results](https://github.com/nanak011/iot_ga2/blob/main/results/metrics.json): `results/metrics.json`

### Other components

- **Operator**

## Connections

- Operator → Fleet runtime: controls (evidence: `README.md`)
- Fleet runtime → Node settings: loads settings (evidence: `edge_node.py`)
- Fleet runtime → Node sites: loads sites (evidence: `README.md`)
- Fleet runtime → Scenario timelines: plays timeline (evidence: `README.md`)
- Fleet runtime → Sensor model: generates readings (evidence: `edge_node.py`)
- Fleet runtime → Edge alarms: evaluates alarms (evidence: `edge_node.py`)
- Fleet runtime → Reading buffer: commits readings (evidence: `README.md`)
- Reading buffer → SQLite schema: uses schema (evidence: `store.py`)
- Fleet runtime → MQTT transport: syncs backlog (evidence: `README.md`)
- MQTT transport → ThingsBoard: publishes telemetry (evidence: `README.md`)
- ThingsBoard → Cloud alarm profile: applies alarm rules (evidence: `README.md`)
- ThingsBoard → Cloud processing rules: processes telemetry (evidence: `thingsboard/rule_chain_scripts.js`)
- ThingsBoard → Water quality dashboard: shows monitoring (evidence: `README.md`)
- Device provisioning → ThingsBoard: provisions devices (evidence: `provision_thingsboard.py`)
- Device provisioning → Node settings: loads credentials (evidence: `provision_thingsboard.py`)
- Operator → Device provisioning: sets up devices (evidence: `README.md`)
- Operator → Run metrics: runs analysis (evidence: `README.md`)
- Run metrics → Reading buffer: reads edge data (evidence: `README.md`)
- Run metrics → ThingsBoard: fetches cloud data (evidence: `README.md`)
- Run metrics → Metric results: writes metrics (evidence: `README.md`)
