# vishnu1307-cse/federated_environment_monitoring architecture

> Architecture diagram of the GitHub repository vishnu1307-cse/federated_environment_monitoring, 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/vishnu1307-cse/federated_environment_monitoring
- Repository: https://github.com/vishnu1307-cse/federated_environment_monitoring

## Overview

FedShield carries out edge sensor inference, sends telemetry and federated updates to a Flask service, aggregates client weights, and presents live network and model status in a React dashboard. The README documents this end-to-end flow and capabilities including bidirectional model sync, node timeout handling, QoS, and alerts. Firmware and backend implementation excerpts are limited, so links based on documented behavior cite the README; unsampled implementation details are not inferred.

Main entry points: [`app.py`](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/app.py) (Flask API), [`frontend/src/App.jsx`](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/App.jsx) (Dashboard application), [`frontend/src/services/socket.js`](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/services/socket.js) (Socket client), [`frontend/src/components/FederatedLearningView.jsx`](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/FederatedLearningView.jsx) (Federated learning view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge sensing"]
  node_esp_nodes["ESP32 nodes<br/>[Camera.ino]"]
  node_camera["Camera firmware<br/>[Camera.ino]"]
  node_gas["Gas firmware<br/>[Gas.ino]"]
  node_ir["IR firmware<br/>[IR.ino]"]
  node_motion["Motion firmware<br/>[Motion_sensor.ino]"]
  node_temperature["Temperature firmware<br/>[Temp.ino]"]
end

subgraph group_backend["Backend services"]
  node_api["Flask API<br/>[app.py]"]
  node_database_layer["Data access<br/>[database.py]"]
  node_store[("Application database<br/>[database.db]")]
end

subgraph group_learning["Federated learning"]
  node_aggregator["FedAvg engine<br/>[fedavg.py]"]
  node_model_generator["Model generation<br/>[model_generator.py]"]
end

subgraph group_ui["Dashboard"]
  node_frontend_app["Dashboard application<br/>[App.jsx]"]
  node_socket_client["Socket client<br/>[socket.js]"]
  node_sensor_view["Sensor node view<br/>[SensorNodeView.jsx]"]
  node_fl_view["Federated learning view"]
  node_overview["Dashboard overview"]
  node_qos["QoS health view<br/>[QoSHealthView.jsx]"]
  node_alerts["Alerts log<br/>[AlertsLogView.jsx]"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_frontend_app
node_esp_nodes -->|"sends telemetry and weights"| node_api
node_api -->|"returns global model"| node_esp_nodes
node_api -->|"orchestrates aggregation"| node_aggregator
node_api -->|"publishes live updates"| node_frontend_app
node_frontend_app -->|"requests status and models"| node_api
node_frontend_app -->|"opens socket"| node_socket_client
node_sensor_view -->|"subscribes updates"| node_socket_client
node_fl_view -->|"subscribes updates"| node_socket_client
node_fl_view -->|"requests aggregation"| node_api
node_overview -->|"uses live telemetry"| node_socket_client
node_frontend_app -.->|"displays nodes"| node_sensor_view
node_frontend_app -.->|"displays learning"| node_fl_view
node_frontend_app -.->|"displays QoS"| node_qos
node_frontend_app -.->|"displays alerts"| node_alerts
node_api -.->|"uses data access"| node_database_layer
node_database_layer -.->|"reads and writes"| node_store
node_aggregator -.->|"uses generated models"| node_model_generator
node_camera -.->|"uploads sensor data"| node_api
node_gas -.->|"uploads sensor data"| node_api
node_ir -.->|"uploads sensor data"| node_api
node_motion -.->|"uploads sensor data"| node_api
node_temperature -.->|"uploads sensor data"| node_api

click node_esp_nodes "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Camera/Camera.ino"
click node_camera "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Camera/Camera.ino"
click node_gas "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Gas/Gas/Gas.ino"
click node_ir "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/IR/IR/IR.ino"
click node_motion "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Motion_sensor/Motion_sensor.ino"
click node_temperature "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Temperature/Temp/Temp.ino"
click node_api "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/app.py"
click node_database_layer "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/database.py"
click node_store "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/database.db"
click node_aggregator "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/fedavg.py"
click node_model_generator "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/model_generator.py"
click node_frontend_app "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/App.jsx"
click node_socket_client "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/services/socket.js"
click node_sensor_view "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/SensorNodeView.jsx"
click node_fl_view "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/FederatedLearningView.jsx"
click node_overview "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/DashboardOverview.jsx"
click node_qos "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/QoSHealthView.jsx"
click node_alerts "https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/AlertsLogView.jsx"

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_esp_nodes,node_camera,node_gas,node_ir,node_motion,node_temperature toneBlue
class node_api,node_database_layer,node_store toneAmber
class node_aggregator,node_model_generator toneMint
class node_frontend_app,node_socket_client,node_sensor_view,node_fl_view,node_overview,node_qos,node_alerts toneRose
class node_operator toneIndigo
```

## Components

### Edge sensing

- [ESP32 nodes](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Camera/Camera.ino): `Camera/Camera.ino`
- [Camera firmware](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Camera/Camera.ino): `Camera/Camera.ino`
- [Gas firmware](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Gas/Gas/Gas.ino): `Gas/Gas/Gas.ino`
- [IR firmware](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/IR/IR/IR.ino): `IR/IR/IR.ino`
- [Motion firmware](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Motion_sensor/Motion_sensor.ino): `Motion_sensor/Motion_sensor.ino`
- [Temperature firmware](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/Temperature/Temp/Temp.ino): `Temperature/Temp/Temp.ino`

### Backend services

- [Flask API](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/app.py): `app.py`
- [Data access](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/database.py): `database.py`
- [Application database](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/database.db): `database.db`

### Federated learning

- [FedAvg engine](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/fedavg.py): `fedavg.py`
- [Model generation](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/model_generator.py): `model_generator.py`

### Dashboard

- [Dashboard application](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Socket client](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/services/socket.js): `frontend/src/services/socket.js`
- [Sensor node view](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/SensorNodeView.jsx): `frontend/src/components/SensorNodeView.jsx`
- [Federated learning view](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/FederatedLearningView.jsx): `frontend/src/components/FederatedLearningView.jsx`
- [Dashboard overview](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/DashboardOverview.jsx): `frontend/src/components/DashboardOverview.jsx`
- [QoS health view](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/QoSHealthView.jsx): `frontend/src/components/QoSHealthView.jsx`
- [Alerts log](https://github.com/vishnu1307-cse/federated_environment_monitoring/blob/main/frontend/src/components/AlertsLogView.jsx): `frontend/src/components/AlertsLogView.jsx`

### Other components

- **Operator**

## Connections

- Operator → Dashboard application: uses (evidence: `README.md`)
- ESP32 nodes → Flask API: sends telemetry and weights (evidence: `README.md`)
- Flask API → ESP32 nodes: returns global model (evidence: `README.md`)
- Flask API → FedAvg engine: orchestrates aggregation (evidence: `README.md`)
- Flask API → Dashboard application: publishes live updates (evidence: `README.md`)
- Dashboard application → Flask API: requests status and models (evidence: `frontend/src/App.jsx`)
- Dashboard application → Socket client: opens socket (evidence: `frontend/src/App.jsx`)
- Sensor node view → Socket client: subscribes updates (evidence: `frontend/src/components/SensorNodeView.jsx`)
- Federated learning view → Socket client: subscribes updates (evidence: `frontend/src/components/FederatedLearningView.jsx`)
- Federated learning view → Flask API: requests aggregation (evidence: `frontend/src/components/FederatedLearningView.jsx`)
- Dashboard overview → Socket client: uses live telemetry (evidence: `frontend/src/components/DashboardOverview.jsx`)
- Dashboard application → Sensor node view: displays nodes
- Dashboard application → Federated learning view: displays learning
- Dashboard application → QoS health view: displays QoS
- Dashboard application → Alerts log: displays alerts
- Flask API → Data access: uses data access
- Data access → Application database: reads and writes
- FedAvg engine → Model generation: uses generated models
- Camera firmware → Flask API: uploads sensor data
- Gas firmware → Flask API: uploads sensor data
- IR firmware → Flask API: uploads sensor data
- Motion firmware → Flask API: uploads sensor data
- Temperature firmware → Flask API: uploads sensor data
