# hassan-darwish/smart-home-automation-system architecture

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

- Interactive diagram: https://gitdiagram.com/hassan-darwish/smart-home-automation-system
- Repository: https://github.com/hassan-darwish/smart-home-automation-system

## Overview

This C++ prototype provides a CLI for creating and controlling smart-home devices, organizing them into groups, and activating automations. The main workflow runs from the CLI controller through device creation or command execution to device state changes; automations also use sensors and the scheduler. The README documents additional device and command capabilities. Several implementation files were not sampled, so edges for those documented behaviors cite the README rather than implying their call details were inspected.

Main entry points: [`src/Controllers/SmartHomeController.cpp`](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Controllers/SmartHomeController.cpp) (CLI Controller), [`src/Automation/SecurityMode.cpp`](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Automation/SecurityMode.cpp) (Security Mode), [`src/Devices`](https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Devices) (Smart Devices), [`src/Devices/DeviceGroup.cpp`](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/DeviceGroup.cpp) (Device Groups)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Control and Creation"]
  node_app["Application Entry<br/>[main.cpp]"]
  node_controller["CLI Controller"]
  node_factory["Device Factory<br/>[DeviceFactory.cpp]"]
end

subgraph group_devices["Devices and Groups"]
  node_device["Smart Devices"]
  node_group["Device Groups<br/>[DeviceGroup.cpp]"]
  node_lights["Lights"]
  node_thermostats["Thermostats"]
  node_camera["Cameras<br/>[BaseCamera.cpp]"]
  node_lock["Door Lock<br/>[DoorLock.cpp]"]
  node_sensor["Motion Sensor<br/>[MotionSensor.cpp]"]
end

subgraph group_automation["Automation"]
  node_security["Security Mode<br/>[SecurityMode.cpp]"]
  node_energy["Energy Saving"]
  node_scheduler["Task Scheduler<br/>[Scheduler.cpp]"]
  node_logger[("Event Logger<br/>[Logger.cpp]")]
end

subgraph group_commands["Commands and Support"]
  node_commands["Device Commands"]
end

node_user(("CLI User"))

node_user -->|"starts"| node_app
node_app -->|"runs"| node_controller
node_user -->|"uses CLI"| node_controller
node_controller -->|"creates devices"| node_factory
node_factory -->|"creates instances"| node_device
node_controller -->|"controls devices"| node_commands
node_controller -->|"manages groups"| node_group
node_group -->|"controls members"| node_device
node_device -->|"includes"| node_lights
node_device -->|"includes"| node_thermostats
node_device -->|"includes"| node_camera
node_device -->|"includes"| node_lock
node_device -->|"includes"| node_sensor
node_controller -->|"activates"| node_security
node_controller -->|"activates"| node_energy
node_security -->|"checks devices"| node_group
node_security -->|"checks motion"| node_sensor
node_security -->|"checks lock"| node_lock
node_security -->|"starts recording"| node_camera
node_security -->|"executes recording"| node_commands
node_security -->|"logs events"| node_logger
node_energy -->|"schedules shutdown"| node_scheduler
node_energy -->|"turns off idle groups"| node_group
node_controller -->|"uses delayed tasks"| node_scheduler

click node_app "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/main.cpp"
click node_controller "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Controllers/SmartHomeController.cpp"
click node_factory "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Factory/DeviceFactory.cpp"
click node_device "https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Devices"
click node_group "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/DeviceGroup.cpp"
click node_lights "https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Devices/Lights"
click node_thermostats "https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Devices/Thermostats"
click node_camera "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/Cameras/BaseCamera.cpp"
click node_lock "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/DoorLock.cpp"
click node_sensor "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/MotionSensor.cpp"
click node_commands "https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Commands"
click node_security "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Automation/SecurityMode.cpp"
click node_energy "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Automation/EnergySavingMode.cpp"
click node_scheduler "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Controllers/Scheduler.cpp"
click node_logger "https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Utils/Logger.cpp"

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_app,node_controller,node_factory,node_user toneBlue
class node_device,node_group,node_lights,node_thermostats,node_camera,node_lock,node_sensor toneAmber
class node_security,node_energy,node_scheduler,node_logger toneMint
class node_commands toneRose
```

## Components

### Control and Creation

- [Application Entry](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/main.cpp): `main.cpp`
- [CLI Controller](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Controllers/SmartHomeController.cpp): `src/Controllers/SmartHomeController.cpp`
- [Device Factory](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Factory/DeviceFactory.cpp): `src/Factory/DeviceFactory.cpp`

### Devices and Groups

- [Smart Devices](https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Devices): `src/Devices`
- [Device Groups](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/DeviceGroup.cpp): `src/Devices/DeviceGroup.cpp`
- [Lights](https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Devices/Lights): `src/Devices/Lights`
- [Thermostats](https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Devices/Thermostats): `src/Devices/Thermostats`
- [Cameras](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/Cameras/BaseCamera.cpp): `src/Devices/Cameras/BaseCamera.cpp`
- [Door Lock](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/DoorLock.cpp): `src/Devices/DoorLock.cpp`
- [Motion Sensor](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Devices/MotionSensor.cpp): `src/Devices/MotionSensor.cpp`

### Automation

- [Security Mode](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Automation/SecurityMode.cpp): `src/Automation/SecurityMode.cpp`
- [Energy Saving](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Automation/EnergySavingMode.cpp): `src/Automation/EnergySavingMode.cpp`
- [Task Scheduler](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Controllers/Scheduler.cpp): `src/Controllers/Scheduler.cpp`
- [Event Logger](https://github.com/hassan-darwish/smart-home-automation-system/blob/main/src/Utils/Logger.cpp): `src/Utils/Logger.cpp`

### Commands and Support

- [Device Commands](https://github.com/hassan-darwish/smart-home-automation-system/tree/main/src/Commands): `src/Commands`

### Other components

- **CLI User**

## Connections

- CLI User → Application Entry: starts (evidence: `README.md`)
- Application Entry → CLI Controller: runs (evidence: `main.cpp`)
- CLI User → CLI Controller: uses CLI (evidence: `README.md`)
- CLI Controller → Device Factory: creates devices (evidence: `src/Controllers/SmartHomeController.cpp`)
- Device Factory → Smart Devices: creates instances (evidence: `README.md`)
- CLI Controller → Device Commands: controls devices (evidence: `README.md`)
- CLI Controller → Device Groups: manages groups (evidence: `README.md`)
- Device Groups → Smart Devices: controls members (evidence: `README.md`)
- Smart Devices → Lights: includes (evidence: `README.md`)
- Smart Devices → Thermostats: includes (evidence: `README.md`)
- Smart Devices → Cameras: includes (evidence: `README.md`)
- Smart Devices → Door Lock: includes (evidence: `README.md`)
- Smart Devices → Motion Sensor: includes (evidence: `README.md`)
- CLI Controller → Security Mode: activates (evidence: `README.md`)
- CLI Controller → Energy Saving: activates (evidence: `README.md`)
- Security Mode → Device Groups: checks devices (evidence: `src/Automation/SecurityMode.cpp`)
- Security Mode → Motion Sensor: checks motion (evidence: `src/Automation/SecurityMode.cpp`)
- Security Mode → Door Lock: checks lock (evidence: `src/Automation/SecurityMode.cpp`)
- Security Mode → Cameras: starts recording (evidence: `src/Automation/SecurityMode.cpp`)
- Security Mode → Device Commands: executes recording (evidence: `src/Automation/SecurityMode.cpp`)
- Security Mode → Event Logger: logs events (evidence: `src/Automation/SecurityMode.cpp`)
- Energy Saving → Task Scheduler: schedules shutdown (evidence: `README.md`)
- Energy Saving → Device Groups: turns off idle groups (evidence: `README.md`)
- CLI Controller → Task Scheduler: uses delayed tasks (evidence: `README.md`)
