# ashishkaus04/smart-home-automation architecture

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

- Interactive diagram: https://gitdiagram.com/ashishkaus04/smart-home-automation
- Repository: https://github.com/ashishkaus04/smart-home-automation

## Overview

This repository is a smart-home system with a Flutter mobile app, MQTT-connected home devices, and optional web and Node.js interfaces. The main documented workflow is users monitoring and controlling home functions in the app, with MQTT carrying sensor updates and control messages between the app, broker, and devices. The optional backend adds HTTP and WebSocket interfaces and a mock energy-prediction endpoint. The tree omits the app’s Dart sources and firmware, so app internals and device-level wiring are represented only where documented; the simulator’s HTTP target is not shown as connected to an implemented route.

Main entry points: [`backend/server.js`](https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/server.js) (API server), [`mobile_app_flutter/smart_home_app`](https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app) (Home screens), [`hardware`](https://github.com/ashishkaus04/smart-home-automation/tree/main/hardware) (Home devices), [`frontend/src/App.js`](https://github.com/ashishkaus04/smart-home-automation/blob/main/frontend/src/App.js) (Web dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_flutter["Flutter app"]
  node_mobile_features["Home screens"]
end

subgraph group_home["Home automation"]
  node_mqtt["MQTT broker"]
  node_devices["Home devices"]
  node_sensors["Sensor readings<br/>[sensor_reader.py]"]
  node_actuators["Device control"]
  node_security["Security system"]
  node_automation["Automation rules"]
end

subgraph group_backend["Optional backend"]
  node_backend_server["API server<br/>[server.js]"]
  node_device_routes["Device routes<br/>[devices.js]"]
  node_device_model["Device model<br/>[Device.js]"]
  node_state[("Device state<br/>[server.js]")]
  node_web["Web dashboard<br/>[App.js]"]
end

subgraph group_energy["Energy intelligence"]
  node_energy_ui["Energy views"]
  node_energy_model["LSTM training<br/>[train_model.py]"]
  node_prediction_api["Prediction endpoint<br/>[server.js]"]
end

node_resident(("Resident"))

node_resident -->|"uses"| node_flutter
node_flutter -->|"navigates"| node_mobile_features
node_mobile_features -->|"publishes and subscribes"| node_mqtt
node_mqtt -->|"routes messages"| node_devices
node_devices -->|"sends readings"| node_mqtt
node_devices -->|"collects data"| node_sensors
node_mqtt -->|"delivers commands"| node_actuators
node_mobile_features -->|"monitors and controls"| node_security
node_mobile_features -->|"configures rules"| node_automation
node_backend_server -->|"subscribes and publishes"| node_mqtt
node_mqtt -->|"delivers messages"| node_backend_server
node_backend_server -->|"updates"| node_state
node_backend_server -->|"routes API requests"| node_device_routes
node_backend_server -.-> node_device_model
node_backend_server -.->|"streams device updates"| node_web
node_web -.->|"uses API and sockets"| node_backend_server
node_flutter -->|"shows"| node_energy_ui
node_energy_model -.-> node_prediction_api
node_backend_server -->|"serves mock predictions"| node_prediction_api
node_prediction_api -.->|"returns prediction data"| node_web

click node_flutter "https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app"
click node_mobile_features "https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app"
click node_devices "https://github.com/ashishkaus04/smart-home-automation/tree/main/hardware"
click node_sensors "https://github.com/ashishkaus04/smart-home-automation/blob/main/hardware/raspberry_pi/sensor_reader.py"
click node_actuators "https://github.com/ashishkaus04/smart-home-automation/tree/main/hardware"
click node_security "https://github.com/ashishkaus04/smart-home-automation/tree/main/hardware"
click node_automation "https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app"
click node_backend_server "https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/server.js"
click node_device_routes "https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/routes/devices.js"
click node_device_model "https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/models/Device.js"
click node_state "https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/server.js"
click node_web "https://github.com/ashishkaus04/smart-home-automation/blob/main/frontend/src/App.js"
click node_energy_ui "https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app"
click node_energy_model "https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/ml/train_model.py"
click node_prediction_api "https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/server.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_flutter,node_mobile_features toneBlue
class node_mqtt,node_devices,node_sensors,node_actuators,node_security,node_automation toneAmber
class node_backend_server,node_device_routes,node_device_model,node_state,node_web toneMint
class node_energy_ui,node_energy_model,node_prediction_api toneRose
class node_resident toneIndigo
```

## Components

### Mobile app

- [Flutter app](https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app): `mobile_app_flutter/smart_home_app`
- [Home screens](https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app): `mobile_app_flutter/smart_home_app`

### Home automation

- **MQTT broker**
- [Home devices](https://github.com/ashishkaus04/smart-home-automation/tree/main/hardware): `hardware`
- [Sensor readings](https://github.com/ashishkaus04/smart-home-automation/blob/main/hardware/raspberry_pi/sensor_reader.py): `hardware/raspberry_pi/sensor_reader.py`
- [Device control](https://github.com/ashishkaus04/smart-home-automation/tree/main/hardware): `hardware`
- [Security system](https://github.com/ashishkaus04/smart-home-automation/tree/main/hardware): `hardware`
- [Automation rules](https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app): `mobile_app_flutter/smart_home_app`

### Optional backend

- [API server](https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/server.js): `backend/server.js`
- [Device routes](https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/routes/devices.js): `backend/routes/devices.js`
- [Device model](https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/models/Device.js): `backend/models/Device.js`
- [Device state](https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/server.js): `backend/server.js`
- [Web dashboard](https://github.com/ashishkaus04/smart-home-automation/blob/main/frontend/src/App.js): `frontend/src/App.js`

### Energy intelligence

- [Energy views](https://github.com/ashishkaus04/smart-home-automation/tree/main/mobile_app_flutter/smart_home_app): `mobile_app_flutter/smart_home_app`
- [LSTM training](https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/ml/train_model.py): `backend/ml/train_model.py`
- [Prediction endpoint](https://github.com/ashishkaus04/smart-home-automation/blob/main/backend/server.js): `backend/server.js`

### Other components

- **Resident**

## Connections

- Resident → Flutter app: uses
- Flutter app → Home screens: navigates
- Home screens → MQTT broker: publishes and subscribes
- MQTT broker → Home devices: routes messages
- Home devices → MQTT broker: sends readings
- Home devices → Sensor readings: collects data
- MQTT broker → Device control: delivers commands
- Home screens → Security system: monitors and controls
- Home screens → Automation rules: configures rules
- API server → MQTT broker: subscribes and publishes
- MQTT broker → API server: delivers messages
- API server → Device state: updates
- API server → Device routes: routes API requests
- API server → Device model
- API server → Web dashboard: streams device updates
- Web dashboard → API server: uses API and sockets
- Flutter app → Energy views: shows
- LSTM training → Prediction endpoint
- API server → Prediction endpoint: serves mock predictions
- Prediction endpoint → Web dashboard: returns prediction data
