# graemef/home-automation architecture

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

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

## Overview

##### Main Components Identification

The project is structured as a monorepo with several key packages that should be represented as main components:

a. Core Components:
- deep-heating (main add-on package)
- deep-heating-rx (reactive programming core)
- deep-heating-state (state management)
- deep-heating-types (type definitions)
- deep-heating-home-assistant (Home Assistant integration)
- deep-heating-web (frontend interface)
- deep-heating-socketio (real-time communication)

**Top Layer (User Interface):**
- deep-heating-web (Svelte-based frontend)

**Middle Layer (Communication):**
- deep-heating-socketio (WebSocket server)
- Home Assistant Integration Layer

**Core Layer:**
- deep-heating-rx (Reactive Core)
- deep-heating-state (State Management)

**Bottom Layer (External Systems):**
- Home Assistant
- TRVs (Thermostatic Radiator Valves)
- Temperature Sensors

##### Component Relationships

- Frontend → SocketIO → Core (user interactions)
- Core → Home Assistant Integration → Home Assistant (control flow)
- Home Assistant → Sensors/TRVs (physical device control)
- Core → State Management (data flow)

##### Technical Details

Annotations showing:
- TypeScript/JavaScript as the primary language
- Svelte for frontend
- Socket.IO for real-time communication
- RxJS for reactive programming
- Home Assistant Add-on architecture

a. High-level system architecture
b. Detailed component interaction
d. Deployment view

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#fff'
  }
}}%%

flowchart TB
    subgraph Frontend["Frontend Layer"]
        WebUI["Deep Heating Web UI"]:::frontend
        StateStores["Frontend State Stores"]:::frontend
    end

    subgraph Communication["Communication Layer"]
        SocketIO["Socket.IO Server"]:::communication
        HAIntegration["Home Assistant Integration"]:::communication
    end

    subgraph Core["Core Layer"]
        ReactiveCore["Reactive Core (RxJS)"]:::core
        StateManagement["State Management"]:::core
        TypeDefs["Type Definitions"]:::types
        
        subgraph StreamManagement["Stream Management"]
            RoomMgmt["Room Management"]:::core
            TRVControl["TRV Control"]:::core
            SensorMgmt["Sensor Management"]:::core
        end
        
        subgraph Types["Type Definitions"]
            HATypes["Home Assistant Types"]:::types
            HeatingActions["Heating Actions"]:::types
            ScheduleMgmt["Schedule Management"]:::types
        end
    end

    subgraph External["External Systems"]
        HomeAssistant["Home Assistant"]:::external
        TRVs["TRVs"]:::external
        Sensors["Temperature Sensors"]:::external
        Climate["Climate Control"]:::external
    end

    %% Relationships
    WebUI --> StateStores
    WebUI --> SocketIO
    SocketIO --> ReactiveCore
    ReactiveCore --> StateManagement
    ReactiveCore --> StreamManagement
    StreamManagement --> HAIntegration
    HAIntegration --> HomeAssistant
    HomeAssistant --> TRVs
    HomeAssistant --> Sensors
    HomeAssistant --> Climate
    TypeDefs --> ReactiveCore
    Types --> HAIntegration

    %% Click Events
    click WebUI "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-web/src/lib/components/"
    click StateStores "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-web/src/lib/stores/"
    click SocketIO "https://github.com/GraemeF/home-automation/blob/main/packages/deep-heating-socketio/src/app/socket-server.ts"
    click ReactiveCore "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-rx/src/lib/streams/"
    click StateManagement "https://github.com/GraemeF/home-automation/blob/main/packages/deep-heating-state/src/lib/deep-heating-state.ts"
    click TypeDefs "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-types/src/lib/"
    click RoomMgmt "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-rx/src/lib/streams/rooms/"
    click TRVControl "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-rx/src/lib/streams/trvs/"
    click SensorMgmt "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-home-assistant/src/lib/sensor/"
    click HAIntegration "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-home-assistant/src/lib/"
    click HATypes "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-types/src/lib/home-assistant/"
    click HeatingActions "https://github.com/GraemeF/home-automation/blob/main/packages/deep-heating-types/src/lib/heatingActions.ts"
    click ScheduleMgmt "https://github.com/GraemeF/home-automation/blob/main/packages/deep-heating-types/src/lib/weekSchedule.ts"
    click Climate "https://github.com/GraemeF/home-automation/tree/main/packages/deep-heating-home-assistant/src/lib/climate/"

    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef communication fill:#4CAF50,stroke:#2E7D32,color:white
    classDef core fill:#FFC107,stroke:#FFA000,color:black
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef types fill:#9C27B0,stroke:#7B1FA2,color:white

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Components"]:::frontend
        Communication_L["Communication Layer"]:::communication
        Core_L["Core Components"]:::core
        External_L["External Systems"]:::external
        Types_L["Type Definitions"]:::types
    end
```
