# rohil72/genai-mirco-project-sem-6 architecture

> Architecture diagram of the GitHub repository rohil72/genai-mirco-project-sem-6, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohil72/genai-mirco-project-sem-6
- Repository: https://github.com/rohil72/genai-mirco-project-sem-6

## Overview

smart-home-llm is a single-machine prototype for synthesizing smart-home event logs, fine-tuning a LoRA-adapted language model to identify routines, predicting routines from logs, and replaying logs in a visual home simulation. Its main user workflow is the CLI in main.py, which dispatches individual stages and a generate-to-evaluate pipeline; prediction and simulation are separate actions. The graph preserves those domain stages and their documented data flow. Some module wiring is based on README descriptions because the corresponding source excerpts were incomplete or unavailable.

Main entry points: [`main.py`](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/main.py) (Command dispatcher), [`data/generator/generate_data.py`](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/generator/generate_data.py) (Log generation), [`training/format_data.py`](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/training/format_data.py) (Training formatter), [`inference/predict.py`](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/inference/predict.py) (Log prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["Log generation"]
  node_generator["Log generation<br/>[generate_data.py]"]
  node_patterns["Routine patterns<br/>[patterns.py]"]
  node_noise["Event noise<br/>[noise.py]"]
  node_routine_config["Routine templates<br/>[routines.yaml]"]
  node_device_config["Device definitions<br/>[devices.yaml]"]
  node_raw_logs["Raw event logs"]
end

subgraph group_training["Fine-tuning"]
  node_formatter["Training formatter<br/>[format_data.py]"]
  node_processed_logs["Train and validation<br/>[train.jsonl]"]
  node_validation_logs["Validation data<br/>[val.jsonl]"]
  node_train_config["Training settings<br/>[training.yaml]"]
  node_trainer["QLoRA training<br/>[train_lora.py]"]
  node_evaluator["Model evaluation<br/>[evaluate.py]"]
end

subgraph group_inference["Routine prediction"]
  node_predictor["Log prediction<br/>[predict.py]"]
  node_extractor["Routine extraction"]
end

subgraph group_simulation["Home simulation"]
  node_simulator["Log replay<br/>[simulator.py]"]
  node_visualizer["Pygame display<br/>[visualize.py]"]
  node_grid["House renderer<br/>[grid.py]"]
  node_layout["House layout<br/>[house_layout.py]"]
end

node_user(("CLI user"))
node_cli["Command dispatcher<br/>[main.py]"]

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches generate"| node_generator
node_cli -->|"dispatches format"| node_formatter
node_cli -->|"dispatches train"| node_trainer
node_cli -->|"dispatches evaluate"| node_evaluator
node_cli -->|"dispatches predict"| node_predictor
node_cli -->|"dispatches simulate"| node_visualizer
node_generator -->|"generates patterns"| node_patterns
node_patterns -->|"reads templates"| node_routine_config
node_patterns -->|"reads devices"| node_device_config
node_generator -->|"applies noise"| node_noise
node_generator -->|"writes events"| node_raw_logs
node_formatter -->|"reads events"| node_raw_logs
node_formatter -->|"writes training data"| node_processed_logs
node_formatter -->|"writes validation data"| node_validation_logs
node_trainer -->|"loads training data"| node_processed_logs
node_trainer -->|"reads settings"| node_train_config
node_evaluator -->|"loads validation data"| node_validation_logs
node_evaluator -->|"reads settings"| node_train_config
node_predictor -->|"reads log input"| node_raw_logs
node_predictor -->|"reads settings"| node_train_config
node_predictor -->|"parses model output"| node_extractor
node_visualizer -->|"starts replay"| node_simulator
node_visualizer -->|"loads layout"| node_layout
node_visualizer -->|"renders display"| node_grid
node_simulator -->|"replays events"| node_raw_logs
node_grid -->|"draws layout"| node_layout
node_layout -->|"loads devices"| node_device_config

click node_cli "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/main.py"
click node_generator "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/generator/generate_data.py"
click node_patterns "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/generator/patterns.py"
click node_noise "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/generator/noise.py"
click node_routine_config "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/config/routines.yaml"
click node_device_config "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/config/devices.yaml"
click node_raw_logs "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/raw/synthetic_logs.jsonl"
click node_formatter "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/training/format_data.py"
click node_processed_logs "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/processed/train.jsonl"
click node_validation_logs "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/processed/val.jsonl"
click node_train_config "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/config/training.yaml"
click node_trainer "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/training/train_lora.py"
click node_evaluator "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/training/evaluate.py"
click node_predictor "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/inference/predict.py"
click node_extractor "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/inference/routine_extractor.py"
click node_simulator "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/simulator.py"
click node_visualizer "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/visualize.py"
click node_grid "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/grid.py"
click node_layout "https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/house_layout.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_generator,node_patterns,node_noise,node_routine_config,node_device_config,node_raw_logs,node_user toneBlue
class node_formatter,node_processed_logs,node_validation_logs,node_train_config,node_trainer,node_evaluator toneAmber
class node_predictor,node_extractor toneMint
class node_simulator,node_visualizer,node_grid,node_layout toneRose
class node_cli toneTeal
```

## Components

### Log generation

- [Log generation](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/generator/generate_data.py): `data/generator/generate_data.py`
- [Routine patterns](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/generator/patterns.py): `data/generator/patterns.py`
- [Event noise](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/generator/noise.py): `data/generator/noise.py`
- [Routine templates](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/config/routines.yaml): `config/routines.yaml`
- [Device definitions](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/config/devices.yaml): `config/devices.yaml`
- [Raw event logs](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/raw/synthetic_logs.jsonl): `data/raw/synthetic_logs.jsonl`

### Fine-tuning

- [Training formatter](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/training/format_data.py): `training/format_data.py`
- [Train and validation](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/processed/train.jsonl): `data/processed/train.jsonl`
- [Validation data](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/data/processed/val.jsonl): `data/processed/val.jsonl`
- [Training settings](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/config/training.yaml): `config/training.yaml`
- [QLoRA training](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/training/train_lora.py): `training/train_lora.py`
- [Model evaluation](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/training/evaluate.py): `training/evaluate.py`

### Routine prediction

- [Log prediction](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/inference/predict.py): `inference/predict.py`
- [Routine extraction](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/inference/routine_extractor.py): `inference/routine_extractor.py`

### Home simulation

- [Log replay](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/simulator.py): `simulation/simulator.py`
- [Pygame display](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/visualize.py): `simulation/visualize.py`
- [House renderer](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/grid.py): `simulation/grid.py`
- [House layout](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/simulation/house_layout.py): `simulation/house_layout.py`

### Other components

- **CLI user**
- [Command dispatcher](https://github.com/rohil72/genai-mirco-project-sem-6/blob/main/main.py): `main.py`

## Connections

- CLI user → Command dispatcher: runs commands
- Command dispatcher → Log generation: dispatches generate
- Command dispatcher → Training formatter: dispatches format
- Command dispatcher → QLoRA training: dispatches train
- Command dispatcher → Model evaluation: dispatches evaluate
- Command dispatcher → Log prediction: dispatches predict
- Command dispatcher → Pygame display: dispatches simulate
- Log generation → Routine patterns: generates patterns
- Routine patterns → Routine templates: reads templates
- Routine patterns → Device definitions: reads devices
- Log generation → Event noise: applies noise
- Log generation → Raw event logs: writes events
- Training formatter → Raw event logs: reads events
- Training formatter → Train and validation: writes training data
- Training formatter → Validation data: writes validation data
- QLoRA training → Train and validation: loads training data
- QLoRA training → Training settings: reads settings
- Model evaluation → Validation data: loads validation data
- Model evaluation → Training settings: reads settings
- Log prediction → Raw event logs: reads log input
- Log prediction → Training settings: reads settings
- Log prediction → Routine extraction: parses model output
- Pygame display → Log replay: starts replay
- Pygame display → House layout: loads layout
- Pygame display → House renderer: renders display
- Log replay → Raw event logs: replays events
- House renderer → House layout: draws layout
- House layout → Device definitions: loads devices
