# ruilima/homedeck architecture

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

- Interactive diagram: https://gitdiagram.com/ruilima/homedeck
- Repository: https://github.com/ruilima/homedeck

## Overview

HomeDeck turns YAML-defined pages and buttons into a live Stream Deck-style Home Assistant controller. Its main loop connects to a physical deck and Home Assistant, renders the current page, and dispatches button interactions; configuration also supports presets, templates, state-based appearance, navigation, sleep behavior, and layered icons. A separate FastAPI server exposes service and configuration-management endpoints. The graph includes all indexed core modules; some internal wiring is omitted where the excerpts establish imports but not calls.

Main entry points: [`src/homedeck/homedeck.py`](https://github.com/ruilima/homedeck/blob/main/src/homedeck/homedeck.py) (Deck controller), [`src/homedeck/dataclasses.py`](https://github.com/ruilima/homedeck/blob/main/src/homedeck/dataclasses.py) (Config models), [`src/homedeck/elements.py`](https://github.com/ruilima/homedeck/blob/main/src/homedeck/elements.py) (Page and button elements), [`src/homedeck/configuration.py`](https://github.com/ruilima/homedeck/blob/main/src/homedeck/configuration.py) (Configuration loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Deck runtime"]
  node_api["Management API<br/>[server.py]"]
  node_entry["Deck entrypoint<br/>[deck.py]"]
  node_controller["Deck controller<br/>[homedeck.py]"]
  node_events["Event bus<br/>[event_bus.py]"]
end

subgraph group_config["Configuration and pages"]
  node_configuration["Configuration loader<br/>[configuration.py]"]
  node_schema["Configuration schema"]
  node_domain["Config models<br/>[dataclasses.py]"]
  node_enums["Runtime enums<br/>[enums.py]"]
  node_elements["Page and button elements<br/>[elements.py]"]
end

subgraph group_render["Rendering"]
  node_templates["Template renderer<br/>[template.py]"]
  node_icons["Icon renderer<br/>[icons.py]"]
  node_utilities["Style utilities<br/>[utils.py]"]
end

subgraph group_integrations["External integrations"]
  node_deck["Physical deck"]
  node_ha["Home Assistant"]
  node_ha_client["HA WebSocket client<br/>[home_assistant.py]"]
end

node_operator(("Deck operator"))
node_admin(("Service administrator"))

node_operator -->|"presses buttons"| node_deck
node_admin -->|"manages service"| node_api
node_api -->|"starts process"| node_entry
node_entry -->|"creates controller"| node_controller
node_controller -->|"loads configuration"| node_configuration
node_configuration -->|"validates against"| node_schema
node_configuration -->|"builds models"| node_domain
node_configuration -->|"creates pages"| node_elements
node_domain -->|"uses values"| node_enums
node_domain -->|"uses templates"| node_templates
node_domain -->|"uses helpers"| node_utilities
node_elements -->|"renders content"| node_templates
node_elements -->|"builds icons"| node_icons
node_elements -->|"uses button models"| node_domain
node_controller -->|"updates pages"| node_elements
node_controller -->|"controls device"| node_deck
node_deck -.->|"sends interactions"| node_controller
node_controller -->|"connects and reacts"| node_ha_client
node_ha_client -->|"exchanges WebSocket messages"| node_ha
node_controller -.->|"uses event bus"| node_events
node_api -->|"serves schema"| node_schema

click node_api "https://github.com/ruilima/homedeck/blob/main/server.py"
click node_entry "https://github.com/ruilima/homedeck/blob/main/deck.py"
click node_controller "https://github.com/ruilima/homedeck/blob/main/src/homedeck/homedeck.py"
click node_events "https://github.com/ruilima/homedeck/blob/main/src/homedeck/event_bus.py"
click node_configuration "https://github.com/ruilima/homedeck/blob/main/src/homedeck/configuration.py"
click node_schema "https://github.com/ruilima/homedeck/blob/main/src/homedeck/yaml/configuration.schema.yml"
click node_domain "https://github.com/ruilima/homedeck/blob/main/src/homedeck/dataclasses.py"
click node_enums "https://github.com/ruilima/homedeck/blob/main/src/homedeck/enums.py"
click node_elements "https://github.com/ruilima/homedeck/blob/main/src/homedeck/elements.py"
click node_templates "https://github.com/ruilima/homedeck/blob/main/src/homedeck/template.py"
click node_icons "https://github.com/ruilima/homedeck/blob/main/src/homedeck/icons.py"
click node_utilities "https://github.com/ruilima/homedeck/blob/main/src/homedeck/utils.py"
click node_ha_client "https://github.com/ruilima/homedeck/blob/main/src/homedeck/home_assistant.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_api,node_entry,node_controller,node_events toneBlue
class node_configuration,node_schema,node_domain,node_enums,node_elements toneAmber
class node_templates,node_icons,node_utilities toneMint
class node_deck,node_ha,node_ha_client toneRose
class node_operator,node_admin toneIndigo
```

## Components

### Deck runtime

- [Management API](https://github.com/ruilima/homedeck/blob/main/server.py): `server.py`
- [Deck entrypoint](https://github.com/ruilima/homedeck/blob/main/deck.py): `deck.py`
- [Deck controller](https://github.com/ruilima/homedeck/blob/main/src/homedeck/homedeck.py): `src/homedeck/homedeck.py`
- [Event bus](https://github.com/ruilima/homedeck/blob/main/src/homedeck/event_bus.py): `src/homedeck/event_bus.py`

### Configuration and pages

- [Configuration loader](https://github.com/ruilima/homedeck/blob/main/src/homedeck/configuration.py): `src/homedeck/configuration.py`
- [Configuration schema](https://github.com/ruilima/homedeck/blob/main/src/homedeck/yaml/configuration.schema.yml): `src/homedeck/yaml/configuration.schema.yml`
- [Config models](https://github.com/ruilima/homedeck/blob/main/src/homedeck/dataclasses.py): `src/homedeck/dataclasses.py`
- [Runtime enums](https://github.com/ruilima/homedeck/blob/main/src/homedeck/enums.py): `src/homedeck/enums.py`
- [Page and button elements](https://github.com/ruilima/homedeck/blob/main/src/homedeck/elements.py): `src/homedeck/elements.py`

### Rendering

- [Template renderer](https://github.com/ruilima/homedeck/blob/main/src/homedeck/template.py): `src/homedeck/template.py`
- [Icon renderer](https://github.com/ruilima/homedeck/blob/main/src/homedeck/icons.py): `src/homedeck/icons.py`
- [Style utilities](https://github.com/ruilima/homedeck/blob/main/src/homedeck/utils.py): `src/homedeck/utils.py`

### External integrations

- **Physical deck**
- **Home Assistant**
- [HA WebSocket client](https://github.com/ruilima/homedeck/blob/main/src/homedeck/home_assistant.py): `src/homedeck/home_assistant.py`

### Other components

- **Deck operator**
- **Service administrator**

## Connections

- Deck operator → Physical deck: presses buttons (evidence: `README.md`)
- Service administrator → Management API: manages service (evidence: `server.py`)
- Management API → Deck entrypoint: starts process (evidence: `server.py`)
- Deck entrypoint → Deck controller: creates controller (evidence: `deck.py`)
- Deck controller → Configuration loader: loads configuration (evidence: `src/homedeck/homedeck.py`)
- Configuration loader → Configuration schema: validates against (evidence: `src/homedeck/configuration.py`)
- Configuration loader → Config models: builds models (evidence: `src/homedeck/configuration.py`)
- Configuration loader → Page and button elements: creates pages (evidence: `src/homedeck/configuration.py`)
- Config models → Runtime enums: uses values (evidence: `src/homedeck/dataclasses.py`)
- Config models → Template renderer: uses templates (evidence: `src/homedeck/dataclasses.py`)
- Config models → Style utilities: uses helpers (evidence: `src/homedeck/dataclasses.py`)
- Page and button elements → Template renderer: renders content (evidence: `src/homedeck/elements.py`)
- Page and button elements → Icon renderer: builds icons (evidence: `src/homedeck/elements.py`)
- Page and button elements → Config models: uses button models (evidence: `src/homedeck/elements.py`)
- Deck controller → Page and button elements: updates pages (evidence: `src/homedeck/homedeck.py`)
- Deck controller → Physical deck: controls device (evidence: `src/homedeck/homedeck.py`)
- Physical deck → Deck controller: sends interactions
- Deck controller → HA WebSocket client: connects and reacts (evidence: `src/homedeck/homedeck.py`)
- HA WebSocket client → Home Assistant: exchanges WebSocket messages (evidence: `src/homedeck/home_assistant.py`)
- Deck controller → Event bus: uses event bus (evidence: `src/homedeck/homedeck.py`)
- Management API → Configuration schema: serves schema (evidence: `server.py`)
