# maxherax/smart-home-thesis architecture

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

- Interactive diagram: https://gitdiagram.com/maxherax/smart-home-thesis
- Repository: https://github.com/maxherax/smart-home-thesis

## Overview

This repository is a smart-home thesis project that develops zone and activity prediction models and connects predictions to Home Assistant through MQTT. The live workflow accepts event sequences at the FastAPI service, prepares features, runs the relevant model, and publishes the prediction; Home Assistant automations can react to those messages. Separate paths support replaying test windows or manually sending demo predictions. Notebooks, datasets, model artifacts, and chart scripts support model development and evaluation. The README is minimal, and source evidence is limited, so uncertain preprocessing, training, and Home Assistant wiring is not expanded.

Main entry points: [`data`](https://github.com/maxherax/smart-home-thesis/tree/main/data) (Datasets), [`shared/api/app.py`](https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py) (Prediction API), [`shared/api/mosquitto.conf`](https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/mosquitto.conf) (MQTT Broker), [`models/lstm_model_v4.keras`](https://github.com/maxherax/smart-home-thesis/blob/main/models/lstm_model_v4.keras) (Zone LSTM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_modeling["Data and Models"]
  node_preprocessing["Data Preparation"]
  node_preprocessing_notebook["Preprocessing Notebook"]
  node_model_notebook["Model Experiments"]
  node_device_notebooks["Device Models"]
  node_datasets[("Datasets")]
  node_zone_model["Zone LSTM"]
  node_activity_model["Activity Model"]
end

subgraph group_runtime["Prediction Runtime"]
  node_api["Prediction API<br/>[app.py]"]
  node_zone_features["Zone Features<br/>[app.py]"]
  node_activity_features["Activity Features<br/>[app.py]"]
  node_zone_encoder["Zone Encoder<br/>[app.py]"]
  node_simulator["Live Simulator<br/>[simulator_live.py]"]
  node_manual_publisher["Manual Publisher<br/>[send_prediction.py]"]
end

subgraph group_messaging["MQTT Integration"]
  node_broker["MQTT Broker<br/>[mosquitto.conf]"]
end

subgraph group_homeassistant["Home Assistant"]
  node_ha["Home Assistant<br/>[configuration.yaml]"]
  node_automations["Automations<br/>[automations.yaml]"]
  node_dashboard["Dashboard<br/>[dashboard.yaml]"]
end

subgraph group_evaluation["Model Evaluation"]
  node_evaluation["Model Evaluation<br/>[run_activity_v2.py]"]
  node_zone_charts["Zone Charts<br/>[final_charts.py]"]
  node_activity_charts["Activity Charts<br/>[activity_charts.py]"]
end

node_researcher(("Researcher"))
node_event_client(("Event Client"))
node_manual_demo(("Demo Operator"))

node_researcher -->|"explores data"| node_preprocessing_notebook
node_datasets -->|"reads events"| node_preprocessing_notebook
node_preprocessing_notebook -->|"develops preparation"| node_preprocessing
node_datasets -->|"provides data"| node_model_notebook
node_model_notebook -->|"develops model"| node_zone_model
node_device_notebooks -->|"develops model"| node_activity_model
node_event_client -->|"sends events"| node_api
node_api -->|"prepares zone input"| node_zone_features
node_api -->|"prepares activity input"| node_activity_features
node_api -->|"encodes sensors"| node_zone_encoder
node_zone_features -->|"predicts zone"| node_zone_model
node_activity_features -->|"predicts activity"| node_activity_model
node_api -->|"publishes predictions"| node_broker
node_simulator -->|"predicts zone"| node_zone_model
node_simulator -->|"publishes replay"| node_broker
node_manual_demo -->|"chooses prediction"| node_manual_publisher
node_manual_publisher -->|"publishes demo"| node_broker
node_broker -->|"delivers messages"| node_ha
node_ha -->|"dispatches automations"| node_automations
node_ha -->|"serves dashboard"| node_dashboard
node_researcher -->|"checks activity model"| node_evaluation
node_datasets -->|"supplies test data"| node_evaluation
node_evaluation -->|"evaluates"| node_activity_model
node_researcher -->|"generates reports"| node_zone_charts
node_datasets -->|"supplies test data"| node_zone_charts
node_zone_charts -->|"evaluates"| node_zone_model
node_researcher -->|"generates reports"| node_activity_charts
node_datasets -->|"supplies test data"| node_activity_charts
node_activity_charts -->|"evaluates"| node_activity_model

click node_preprocessing "https://github.com/maxherax/smart-home-thesis/tree/main/maksim/preprocessing"
click node_preprocessing_notebook "https://github.com/maxherax/smart-home-thesis/blob/main/maksim/02_preprocessing.ipynb"
click node_model_notebook "https://github.com/maxherax/smart-home-thesis/tree/main/maksim/notebooks"
click node_device_notebooks "https://github.com/maxherax/smart-home-thesis/blob/main/maksim/notebooks/11_devices_model.ipynb"
click node_datasets "https://github.com/maxherax/smart-home-thesis/tree/main/data"
click node_zone_model "https://github.com/maxherax/smart-home-thesis/blob/main/models/lstm_model_v4.keras"
click node_activity_model "https://github.com/maxherax/smart-home-thesis/blob/main/models/activity_model.keras"
click node_api "https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py"
click node_zone_features "https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py"
click node_activity_features "https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py"
click node_zone_encoder "https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py"
click node_simulator "https://github.com/maxherax/smart-home-thesis/blob/main/simulator_live.py"
click node_manual_publisher "https://github.com/maxherax/smart-home-thesis/blob/main/send_prediction.py"
click node_broker "https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/mosquitto.conf"
click node_ha "https://github.com/maxherax/smart-home-thesis/blob/main/andrey/home-assistant/configuration.yaml"
click node_automations "https://github.com/maxherax/smart-home-thesis/blob/main/andrey/home-assistant/automations.yaml"
click node_dashboard "https://github.com/maxherax/smart-home-thesis/blob/main/andrey/home-assistant/dashboard.yaml"
click node_evaluation "https://github.com/maxherax/smart-home-thesis/blob/main/run_activity_v2.py"
click node_zone_charts "https://github.com/maxherax/smart-home-thesis/blob/main/final_charts.py"
click node_activity_charts "https://github.com/maxherax/smart-home-thesis/blob/main/activity_charts.py"

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_preprocessing,node_preprocessing_notebook,node_model_notebook,node_device_notebooks,node_datasets,node_zone_model,node_activity_model,node_event_client toneBlue
class node_api,node_zone_features,node_activity_features,node_zone_encoder,node_simulator,node_manual_publisher toneAmber
class node_broker toneMint
class node_ha,node_automations,node_dashboard toneRose
class node_evaluation,node_zone_charts,node_activity_charts,node_researcher,node_manual_demo toneIndigo
```

## Components

### Data and Models

- [Data Preparation](https://github.com/maxherax/smart-home-thesis/tree/main/maksim/preprocessing): `maksim/preprocessing`
- [Preprocessing Notebook](https://github.com/maxherax/smart-home-thesis/blob/main/maksim/02_preprocessing.ipynb): `maksim/02_preprocessing.ipynb`
- [Model Experiments](https://github.com/maxherax/smart-home-thesis/tree/main/maksim/notebooks): `maksim/notebooks`
- [Device Models](https://github.com/maxherax/smart-home-thesis/blob/main/maksim/notebooks/11_devices_model.ipynb): `maksim/notebooks/11_devices_model.ipynb`
- [Datasets](https://github.com/maxherax/smart-home-thesis/tree/main/data): `data`
- [Zone LSTM](https://github.com/maxherax/smart-home-thesis/blob/main/models/lstm_model_v4.keras): `models/lstm_model_v4.keras`
- [Activity Model](https://github.com/maxherax/smart-home-thesis/blob/main/models/activity_model.keras): `models/activity_model.keras`

### Prediction Runtime

- [Prediction API](https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py): `shared/api/app.py`
- [Zone Features](https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py): `shared/api/app.py`
- [Activity Features](https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py): `shared/api/app.py`
- [Zone Encoder](https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/app.py): `shared/api/app.py`
- [Live Simulator](https://github.com/maxherax/smart-home-thesis/blob/main/simulator_live.py): `simulator_live.py`
- [Manual Publisher](https://github.com/maxherax/smart-home-thesis/blob/main/send_prediction.py): `send_prediction.py`

### MQTT Integration

- [MQTT Broker](https://github.com/maxherax/smart-home-thesis/blob/main/shared/api/mosquitto.conf): `shared/api/mosquitto.conf`

### Home Assistant

- [Home Assistant](https://github.com/maxherax/smart-home-thesis/blob/main/andrey/home-assistant/configuration.yaml): `andrey/home-assistant/configuration.yaml`
- [Automations](https://github.com/maxherax/smart-home-thesis/blob/main/andrey/home-assistant/automations.yaml): `andrey/home-assistant/automations.yaml`
- [Dashboard](https://github.com/maxherax/smart-home-thesis/blob/main/andrey/home-assistant/dashboard.yaml): `andrey/home-assistant/dashboard.yaml`

### Model Evaluation

- [Model Evaluation](https://github.com/maxherax/smart-home-thesis/blob/main/run_activity_v2.py): `run_activity_v2.py`
- [Zone Charts](https://github.com/maxherax/smart-home-thesis/blob/main/final_charts.py): `final_charts.py`
- [Activity Charts](https://github.com/maxherax/smart-home-thesis/blob/main/activity_charts.py): `activity_charts.py`

### Other components

- **Researcher**
- **Event Client**
- **Demo Operator**

## Connections

- Researcher → Preprocessing Notebook: explores data
- Datasets → Preprocessing Notebook: reads events
- Preprocessing Notebook → Data Preparation: develops preparation
- Datasets → Model Experiments: provides data
- Model Experiments → Zone LSTM: develops model
- Device Models → Activity Model: develops model
- Event Client → Prediction API: sends events
- Prediction API → Zone Features: prepares zone input
- Prediction API → Activity Features: prepares activity input
- Prediction API → Zone Encoder: encodes sensors
- Zone Features → Zone LSTM: predicts zone
- Activity Features → Activity Model: predicts activity
- Prediction API → MQTT Broker: publishes predictions
- Live Simulator → Zone LSTM: predicts zone
- Live Simulator → MQTT Broker: publishes replay
- Demo Operator → Manual Publisher: chooses prediction
- Manual Publisher → MQTT Broker: publishes demo
- MQTT Broker → Home Assistant: delivers messages
- Home Assistant → Automations: dispatches automations
- Home Assistant → Dashboard: serves dashboard
- Researcher → Model Evaluation: checks activity model
- Datasets → Model Evaluation: supplies test data
- Model Evaluation → Activity Model: evaluates
- Researcher → Zone Charts: generates reports
- Datasets → Zone Charts: supplies test data
- Zone Charts → Zone LSTM: evaluates
- Researcher → Activity Charts: generates reports
- Datasets → Activity Charts: supplies test data
- Activity Charts → Activity Model: evaluates
