# iot-team-ute-n2/iot-project architecture

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

- Interactive diagram: https://gitdiagram.com/iot-team-ute-n2/iot-project
- Repository: https://github.com/iot-team-ute-n2/iot-project

## Overview

This is a multi-pump agricultural IoT monitoring and control system. A user signs in, views a fleet overview, selects a pump, and monitors its live readings and history; they can also configure watering thresholds and control pumps. Device telemetry travels through MQTT and Node-RED into InfluxDB, while the web app also receives live MQTT updates and uses the API to seed readings and retrieve history. The map follows README-described infrastructure and sampled frontend/API code; Node-RED flow details and pump-command wiring were not sampled, so those links are limited to documented behavior.

Main entry points: [`backend/api/src/app.js`](https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/app.js) (API application), [`backend/mosquitto/config`](https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/mosquitto/config) (Mosquitto MQTT), [`fontend_mul/src/hooks/useFleetHistoryStore.js`](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/hooks/useFleetHistoryStore.js) (History store), [`fontend_mul/src/lib/apiClient.js`](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/lib/apiClient.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web dashboard"]
  node_frontend["React app<br/>[App.jsx]"]
  node_authpage["Sign-in UI<br/>[AuthPage.jsx]"]
  node_authprovider["Auth provider<br/>[AuthProvider.jsx]"]
  node_fleetview["Fleet overview<br/>[DeviceOverview.jsx]"]
  node_pumpview["Pump dashboard<br/>[Dashboard.jsx]"]
  node_history["History store"]
  node_mqttclient["Live telemetry client"]
  node_pumpcontrol["Pump controls"]
  node_thresholdui["Threshold form"]
  node_apiadapter["API client<br/>[apiClient.js]"]
end

subgraph group_api["REST API"]
  node_apiserver["API application<br/>[app.js]"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_deviceroutes["Device routes<br/>[devices.js]"]
  node_configroutes["Config routes<br/>[config.js]"]
  node_telemetryroutes["Telemetry routes<br/>[telemetry.js]"]
end

subgraph group_telemetry["Telemetry pipeline"]
  node_simulator["ESP32 simulator"]
  node_broker["Mosquitto MQTT"]
  node_nodered["Node-RED flow"]
  node_influx[("InfluxDB")]
end

subgraph group_state["Accounts and state"]
  node_store[("Device configuration<br/>[store.js]")]
  node_mysql[("MySQL accounts")]
end

node_user(("User"))

node_user -->|"signs in"| node_authpage
node_authpage -->|"submits credentials"| node_authprovider
node_authprovider -->|"calls auth API"| node_apiadapter
node_apiadapter -->|"REST requests"| node_apiserver
node_apiserver -->|"dispatches auth"| node_authroutes
node_authroutes -->|"reads/writes users"| node_mysql
node_authroutes -->|"returns session result"| node_authprovider
node_authprovider -->|"provides session"| node_frontend
node_frontend -->|"shows fleet"| node_fleetview
node_frontend -->|"starts fleet tracking"| node_history
node_frontend -->|"opens selected pump"| node_pumpview
node_history -->|"subscribes"| node_mqttclient
node_mqttclient -->|"receives live data"| node_broker
node_broker -->|"accepts telemetry"| node_simulator
node_broker -->|"publishes readings"| node_mqttclient
node_history -->|"seeds latest readings"| node_apiadapter
node_apiadapter -->|"requests readings"| node_apiserver
node_apiserver -->|"dispatches telemetry"| node_telemetryroutes
node_telemetryroutes -->|"queries measurements"| node_influx
node_history -->|"supplies history"| node_pumpview
node_history -->|"persists rollups locally"| node_user
node_simulator -->|"publishes telemetry"| node_broker
node_broker -->|"forwards telemetry"| node_nodered
node_nodered -->|"writes measurements"| node_influx
node_user -->|"requests pump action"| node_pumpcontrol
node_pumpcontrol -.->|"sends pump command"| node_broker
node_user -->|"sets thresholds"| node_thresholdui
node_thresholdui -->|"submits config"| node_apiadapter
node_apiserver -->|"dispatches config"| node_configroutes
node_configroutes -->|"reads/writes config"| node_store
node_apiserver -->|"dispatches devices"| node_deviceroutes
node_deviceroutes -->|"reads device list"| node_store

click node_frontend "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/App.jsx"
click node_authpage "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/AuthPage.jsx"
click node_authprovider "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/AuthProvider.jsx"
click node_fleetview "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/DeviceOverview.jsx"
click node_pumpview "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/Dashboard.jsx"
click node_history "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/hooks/useFleetHistoryStore.js"
click node_mqttclient "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/hooks/useFleetTelemetry.js"
click node_pumpcontrol "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/PumpControlPanel.jsx"
click node_thresholdui "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/ThresholdConfigForm.jsx"
click node_simulator "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/esp32-simulator.cjs"
click node_broker "https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/mosquitto/config"
click node_nodered "https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/node-red/data"
click node_influx "https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/influxdb"
click node_apiserver "https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/app.js"
click node_authroutes "https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/auth.js"
click node_deviceroutes "https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/devices.js"
click node_configroutes "https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/config.js"
click node_telemetryroutes "https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/telemetry.js"
click node_store "https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/store.js"
click node_mysql "https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/mysql/init"
click node_apiadapter "https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/lib/apiClient.js"

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_frontend,node_authpage,node_authprovider,node_fleetview,node_pumpview,node_history,node_mqttclient,node_pumpcontrol,node_thresholdui,node_apiadapter,node_user toneBlue
class node_apiserver,node_authroutes,node_deviceroutes,node_configroutes,node_telemetryroutes toneAmber
class node_simulator,node_broker,node_nodered,node_influx toneMint
class node_store,node_mysql toneRose
```

## Components

### Web dashboard

- [React app](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/App.jsx): `fontend_mul/src/App.jsx`
- [Sign-in UI](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/AuthPage.jsx): `fontend_mul/src/components/AuthPage.jsx`
- [Auth provider](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/AuthProvider.jsx): `fontend_mul/src/components/AuthProvider.jsx`
- [Fleet overview](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/DeviceOverview.jsx): `fontend_mul/src/components/DeviceOverview.jsx`
- [Pump dashboard](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/Dashboard.jsx): `fontend_mul/src/components/Dashboard.jsx`
- [History store](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/hooks/useFleetHistoryStore.js): `fontend_mul/src/hooks/useFleetHistoryStore.js`
- [Live telemetry client](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/hooks/useFleetTelemetry.js): `fontend_mul/src/hooks/useFleetTelemetry.js`
- [Pump controls](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/PumpControlPanel.jsx): `fontend_mul/src/components/PumpControlPanel.jsx`
- [Threshold form](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/components/ThresholdConfigForm.jsx): `fontend_mul/src/components/ThresholdConfigForm.jsx`
- [API client](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/src/lib/apiClient.js): `fontend_mul/src/lib/apiClient.js`

### REST API

- [API application](https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/app.js): `backend/api/src/app.js`
- [Auth routes](https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/auth.js): `backend/api/src/routes/auth.js`
- [Device routes](https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/devices.js): `backend/api/src/routes/devices.js`
- [Config routes](https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/config.js): `backend/api/src/routes/config.js`
- [Telemetry routes](https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/routes/telemetry.js): `backend/api/src/routes/telemetry.js`

### Telemetry pipeline

- [ESP32 simulator](https://github.com/iot-team-ute-n2/iot-project/blob/main/fontend_mul/esp32-simulator.cjs): `fontend_mul/esp32-simulator.cjs`
- [Mosquitto MQTT](https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/mosquitto/config): `backend/mosquitto/config`
- [Node-RED flow](https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/node-red/data): `backend/node-red/data`
- [InfluxDB](https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/influxdb): `backend/influxdb`

### Accounts and state

- [Device configuration](https://github.com/iot-team-ute-n2/iot-project/blob/main/backend/api/src/store.js): `backend/api/src/store.js`
- [MySQL accounts](https://github.com/iot-team-ute-n2/iot-project/tree/main/backend/mysql/init): `backend/mysql/init`

### Other components

- **User**

## Connections

- User → Sign-in UI: signs in
- Sign-in UI → Auth provider: submits credentials
- Auth provider → API client: calls auth API
- API client → API application: REST requests
- API application → Auth routes: dispatches auth
- Auth routes → MySQL accounts: reads/writes users
- Auth routes → Auth provider: returns session result
- Auth provider → React app: provides session
- React app → Fleet overview: shows fleet
- React app → History store: starts fleet tracking
- React app → Pump dashboard: opens selected pump
- History store → Live telemetry client: subscribes
- Live telemetry client → Mosquitto MQTT: receives live data
- Mosquitto MQTT → ESP32 simulator: accepts telemetry
- Mosquitto MQTT → Live telemetry client: publishes readings
- History store → API client: seeds latest readings
- API client → API application: requests readings
- API application → Telemetry routes: dispatches telemetry
- Telemetry routes → InfluxDB: queries measurements
- History store → Pump dashboard: supplies history
- History store → User: persists rollups locally
- ESP32 simulator → Mosquitto MQTT: publishes telemetry
- Mosquitto MQTT → Node-RED flow: forwards telemetry
- Node-RED flow → InfluxDB: writes measurements
- User → Pump controls: requests pump action
- Pump controls → Mosquitto MQTT: sends pump command
- User → Threshold form: sets thresholds
- Threshold form → API client: submits config
- API application → Config routes: dispatches config
- Config routes → Device configuration: reads/writes config
- API application → Device routes: dispatches devices
- Device routes → Device configuration: reads device list
