# sakshichak/smart-sensor-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/sakshichak/smart-sensor-dashboard
- Repository: https://github.com/sakshichak/smart-sensor-dashboard

## Overview

The product is a real-time temperature and humidity dashboard. Its principal workflow simulates readings, publishes them over MQTT, ingests them in the backend, and broadcasts them over Socket.IO for display in the React UI. The backend also persists readings through the SensorReading model. The graph preserves the simulator, broker, storage, gateway, and dashboard stages. Relationships are based on the excerpts or README; no historical-query or alert workflow is implemented in the shown product.

Main entry points: [`backend/mqttService.js`](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/mqttService.js) (MQTT ingestion), [`backend/server.js`](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/server.js) (Backend server), [`backend/websocket.js`](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/websocket.js) (Socket.IO gateway), [`frontend/src/App.jsx`](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/frontend/src/App.jsx) (Sensor dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Sensor simulation"]
  node_simulator["Sensor publisher<br/>[publisher.js]"]
end

subgraph group_backend["Backend ingestion"]
  node_server["Backend server<br/>[server.js]"]
  node_config["Backend config<br/>[config.js]"]
  node_ingestion["MQTT ingestion<br/>[mqttService.js]"]
  node_reading["Reading model<br/>[SensorReading.js]"]
end

subgraph group_realtime["Realtime dashboard"]
  node_gateway["Socket.IO gateway<br/>[websocket.js]"]
  node_bootstrap["React bootstrap<br/>[main.jsx]"]
  node_dashboard["Sensor dashboard<br/>[App.jsx]"]
end

node_broker{{"MQTT broker"}}
node_mongodb[("MongoDB")]
node_user(("Dashboard user"))

node_simulator -->|"publishes readings"| node_broker
node_broker -->|"delivers MQTT messages"| node_ingestion
node_server -->|"loads settings"| node_config
node_server -->|"starts service"| node_ingestion
node_server -->|"initializes gateway"| node_gateway
node_server -->|"connects"| node_mongodb
node_ingestion -->|"reads broker settings"| node_config
node_ingestion -->|"subscribes to topic"| node_broker
node_ingestion -->|"creates readings"| node_reading
node_reading -->|"stores documents"| node_mongodb
node_ingestion -->|"emits readings"| node_gateway
node_dashboard -->|"connects and listens"| node_gateway
node_gateway -->|"broadcasts sensor data"| node_dashboard
node_bootstrap -->|"renders"| node_dashboard
node_user -->|"views readings"| node_dashboard

click node_simulator "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/sensor-simulator/publisher.js"
click node_server "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/server.js"
click node_config "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/config.js"
click node_ingestion "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/mqttService.js"
click node_reading "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/models/SensorReading.js"
click node_gateway "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/websocket.js"
click node_bootstrap "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/frontend/src/main.jsx"
click node_dashboard "https://github.com/sakshichak/smart-sensor-dashboard/blob/main/frontend/src/App.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_simulator,node_user toneBlue
class node_server,node_config,node_ingestion,node_reading,node_mongodb toneAmber
class node_gateway,node_bootstrap,node_dashboard toneMint
class node_broker toneIndigo
```

## Components

### Sensor simulation

- [Sensor publisher](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/sensor-simulator/publisher.js): `sensor-simulator/publisher.js`

### Backend ingestion

- [Backend server](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/server.js): `backend/server.js`
- [Backend config](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/config.js): `backend/config.js`
- [MQTT ingestion](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/mqttService.js): `backend/mqttService.js`
- [Reading model](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/models/SensorReading.js): `backend/models/SensorReading.js`

### Realtime dashboard

- [Socket.IO gateway](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/backend/websocket.js): `backend/websocket.js`
- [React bootstrap](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Sensor dashboard](https://github.com/sakshichak/smart-sensor-dashboard/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### Other components

- **MQTT broker**
- **MongoDB**
- **Dashboard user**

## Connections

- Sensor publisher → MQTT broker: publishes readings (evidence: `sensor-simulator/publisher.js`)
- MQTT broker → MQTT ingestion: delivers MQTT messages (evidence: `README.md`)
- Backend server → Backend config: loads settings (evidence: `backend/server.js`)
- Backend server → MQTT ingestion: starts service (evidence: `backend/server.js`)
- Backend server → Socket.IO gateway: initializes gateway (evidence: `backend/server.js`)
- Backend server → MongoDB: connects (evidence: `backend/server.js`)
- MQTT ingestion → Backend config: reads broker settings (evidence: `backend/mqttService.js`)
- MQTT ingestion → MQTT broker: subscribes to topic (evidence: `backend/mqttService.js`)
- MQTT ingestion → Reading model: creates readings (evidence: `backend/mqttService.js`)
- Reading model → MongoDB: stores documents (evidence: `backend/models/SensorReading.js`)
- MQTT ingestion → Socket.IO gateway: emits readings (evidence: `backend/mqttService.js`)
- Sensor dashboard → Socket.IO gateway: connects and listens (evidence: `frontend/src/App.jsx`)
- Socket.IO gateway → Sensor dashboard: broadcasts sensor data (evidence: `README.md`)
- React bootstrap → Sensor dashboard: renders (evidence: `frontend/src/main.jsx`)
- Dashboard user → Sensor dashboard: views readings (evidence: `README.md`)
