# owie2711/home-assistant-desktop-app-2 architecture

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

- Interactive diagram: https://gitdiagram.com/owie2711/home-assistant-desktop-app-2
- Repository: https://github.com/owie2711/home-assistant-desktop-app-2

## Overview

Home Assistant Desktop is a native Windows shell for the Home Assistant dashboard. On launch it loads settings, then either guides first-run server setup or initializes WebView2 against the active server; users can navigate, switch servers, and manage preferences. Settings and server profiles persist locally, while separate services handle tray access, window behavior, and Windows startup. The graph preserves README-documented capabilities, but unsampled implementation details are not treated as verified call paths.

Main entry points: [`App.xaml.cs`](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/App.xaml.cs) (Application startup), [`Services/SettingsService.cs`](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/SettingsService.cs) (Settings persistence), [`Services/WebViewService.cs`](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/WebViewService.cs) (WebView2 lifecycle), [`ViewModels/SettingsViewModel.cs`](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/ViewModels/SettingsViewModel.cs) (Settings view model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_app["Application startup<br/>[App.xaml.cs]"]
  node_mainwindow["Main window<br/>[MainWindow.xaml.cs]"]
  node_mainvm["Main view model<br/>[MainViewModel.cs]"]
  node_singleinstance["Single instance guard"]
  node_logger["File logging<br/>[FileLogger.cs]"]
end

subgraph group_dashboard["Dashboard access"]
  node_webview["WebView2 lifecycle<br/>[WebViewService.cs]"]
end

subgraph group_configuration["Configuration"]
  node_settingswindow["Settings window"]
  node_settingsvm["Settings view model"]
  node_servermanager["Server profiles<br/>[ServerManager.cs]"]
  node_profile["Server profile<br/>[ServerProfile.cs]"]
  node_settingsservice["Settings persistence<br/>[SettingsService.cs]"]
  node_appsettings["Application settings<br/>[AppSettings.cs]"]
end

subgraph group_desktop["Windows integration"]
  node_windowservice["Window behavior<br/>[WindowService.cs]"]
  node_tray["System tray<br/>[TrayService.cs]"]
  node_startupservice["Windows startup<br/>[StartupService.cs]"]
end

node_user(("Desktop user"))
node_ha["Home Assistant server"]
node_registry[("Windows Registry")]

node_user -->|"opens"| node_mainwindow
node_app -->|"guards launch"| node_singleinstance
node_app -->|"loads settings"| node_settingsservice
node_app -->|"resolves service"| node_servermanager
node_app -->|"resolves service"| node_webview
node_app -->|"resolves service"| node_windowservice
node_app -->|"resolves service"| node_tray
node_app -->|"syncs startup"| node_startupservice
node_app -->|"configures provider"| node_logger
node_app -->|"creates window"| node_mainwindow
node_mainwindow -->|"binds view model"| node_mainvm
node_mainwindow -->|"attaches view"| node_webview
node_mainwindow -->|"attaches window"| node_windowservice
node_mainwindow -->|"opens settings"| node_settingswindow
node_settingswindow -->|"uses view model"| node_settingsvm
node_mainvm -->|"initializes and switches"| node_webview
node_mainvm -->|"selects active profile"| node_servermanager
node_mainvm -->|"controls fullscreen"| node_windowservice
node_mainvm -->|"refreshes menu"| node_tray
node_mainvm -->|"requests settings"| node_settingsvm
node_webview -->|"navigates and probes"| node_ha
node_webview -->|"gets active profile"| node_servermanager
node_webview -->|"reads and saves zoom"| node_settingsservice
node_settingsvm -->|"manages profiles"| node_servermanager
node_settingsvm -->|"updates preferences"| node_settingsservice
node_settingsvm -->|"sets auto-start"| node_startupservice
node_settingsvm -->|"sets fullscreen"| node_windowservice
node_settingsvm -->|"tests connection"| node_ha
node_servermanager -->|"updates server list"| node_settingsservice
node_servermanager -->|"manages profiles"| node_profile
node_settingsservice -->|"serializes settings"| node_appsettings
node_settingsservice -->|"contains active profile"| node_appsettings
node_tray -->|"reads server list"| node_settingsservice
node_tray -->|"requests open or settings"| node_mainwindow
node_windowservice -->|"reads and saves window state"| node_settingsservice
node_startupservice -->|"reads and writes"| node_registry
node_user -->|"uses tray menu"| node_tray
node_user -->|"configures servers"| node_settingsvm
node_user -->|"toggles fullscreen"| node_windowservice
node_user -->|"enables auto-start"| node_startupservice
node_settingsservice -->|"persists locally"| node_appsettings
node_webview -->|"renders dashboard"| node_ha
node_webview -->|"isolates browser data"| node_servermanager

click node_app "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/App.xaml.cs"
click node_mainwindow "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Views/MainWindow.xaml.cs"
click node_mainvm "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/ViewModels/MainViewModel.cs"
click node_settingswindow "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Views/SettingsWindow.xaml.cs"
click node_settingsvm "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/ViewModels/SettingsViewModel.cs"
click node_webview "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/WebViewService.cs"
click node_servermanager "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/ServerManager.cs"
click node_profile "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Models/ServerProfile.cs"
click node_settingsservice "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/SettingsService.cs"
click node_appsettings "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Models/AppSettings.cs"
click node_windowservice "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/WindowService.cs"
click node_tray "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/TrayService.cs"
click node_startupservice "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/StartupService.cs"
click node_singleinstance "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/SingleInstanceService.cs"
click node_logger "https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/FileLogger.cs"

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_mainwindow,node_mainvm,node_singleinstance,node_logger,node_user toneBlue
class node_webview,node_registry toneAmber
class node_settingswindow,node_settingsvm,node_servermanager,node_profile,node_settingsservice,node_appsettings,node_ha toneMint
class node_windowservice,node_tray,node_startupservice toneRose
```

## Components

### Application runtime

- [Application startup](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/App.xaml.cs): `App.xaml.cs`
- [Main window](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Views/MainWindow.xaml.cs): `Views/MainWindow.xaml.cs`
- [Main view model](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/ViewModels/MainViewModel.cs): `ViewModels/MainViewModel.cs`
- [Single instance guard](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/SingleInstanceService.cs): `Services/SingleInstanceService.cs`
- [File logging](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/FileLogger.cs): `Services/FileLogger.cs`

### Dashboard access

- [WebView2 lifecycle](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/WebViewService.cs): `Services/WebViewService.cs`

### Configuration

- [Settings window](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Views/SettingsWindow.xaml.cs): `Views/SettingsWindow.xaml.cs`
- [Settings view model](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/ViewModels/SettingsViewModel.cs): `ViewModels/SettingsViewModel.cs`
- [Server profiles](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/ServerManager.cs): `Services/ServerManager.cs`
- [Server profile](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Models/ServerProfile.cs): `Models/ServerProfile.cs`
- [Settings persistence](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/SettingsService.cs): `Services/SettingsService.cs`
- [Application settings](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Models/AppSettings.cs): `Models/AppSettings.cs`

### Windows integration

- [Window behavior](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/WindowService.cs): `Services/WindowService.cs`
- [System tray](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/TrayService.cs): `Services/TrayService.cs`
- [Windows startup](https://github.com/owie2711/home-assistant-desktop-app-2/blob/main/Services/StartupService.cs): `Services/StartupService.cs`

### Other components

- **Desktop user**
- **Home Assistant server**
- **Windows Registry**

## Connections

- Desktop user → Main window: opens (evidence: `README.md`)
- Application startup → Single instance guard: guards launch (evidence: `App.xaml.cs`)
- Application startup → Settings persistence: loads settings (evidence: `App.xaml.cs`)
- Application startup → Server profiles: resolves service (evidence: `App.xaml.cs`)
- Application startup → WebView2 lifecycle: resolves service (evidence: `App.xaml.cs`)
- Application startup → Window behavior: resolves service (evidence: `App.xaml.cs`)
- Application startup → System tray: resolves service (evidence: `App.xaml.cs`)
- Application startup → Windows startup: syncs startup (evidence: `App.xaml.cs`)
- Application startup → File logging: configures provider (evidence: `App.xaml.cs`)
- Application startup → Main window: creates window (evidence: `App.xaml.cs`)
- Main window → Main view model: binds view model (evidence: `Views/MainWindow.xaml.cs`)
- Main window → WebView2 lifecycle: attaches view (evidence: `Views/MainWindow.xaml.cs`)
- Main window → Window behavior: attaches window (evidence: `Views/MainWindow.xaml.cs`)
- Main window → Settings window: opens settings (evidence: `Views/MainWindow.xaml.cs`)
- Settings window → Settings view model: uses view model (evidence: `Views/SettingsWindow.xaml.cs`)
- Main view model → WebView2 lifecycle: initializes and switches (evidence: `ViewModels/MainViewModel.cs`)
- Main view model → Server profiles: selects active profile (evidence: `ViewModels/MainViewModel.cs`)
- Main view model → Window behavior: controls fullscreen (evidence: `ViewModels/MainViewModel.cs`)
- Main view model → System tray: refreshes menu (evidence: `ViewModels/MainViewModel.cs`)
- Main view model → Settings view model: requests settings (evidence: `Views/MainWindow.xaml.cs`)
- WebView2 lifecycle → Home Assistant server: navigates and probes (evidence: `Services/WebViewService.cs`)
- WebView2 lifecycle → Server profiles: gets active profile (evidence: `Services/WebViewService.cs`)
- WebView2 lifecycle → Settings persistence: reads and saves zoom (evidence: `Services/WebViewService.cs`)
- Settings view model → Server profiles: manages profiles (evidence: `ViewModels/SettingsViewModel.cs`)
- Settings view model → Settings persistence: updates preferences (evidence: `ViewModels/SettingsViewModel.cs`)
- Settings view model → Windows startup: sets auto-start (evidence: `ViewModels/SettingsViewModel.cs`)
- Settings view model → Window behavior: sets fullscreen (evidence: `ViewModels/SettingsViewModel.cs`)
- Settings view model → Home Assistant server: tests connection (evidence: `ViewModels/SettingsViewModel.cs`)
- Server profiles → Settings persistence: updates server list (evidence: `Services/ServerManager.cs`)
- Server profiles → Server profile: manages profiles (evidence: `Services/ServerManager.cs`)
- Settings persistence → Application settings: serializes settings (evidence: `Services/SettingsService.cs`)
- Settings persistence → Application settings: contains active profile (evidence: `Models/AppSettings.cs`)
- System tray → Settings persistence: reads server list (evidence: `Services/TrayService.cs`)
- System tray → Main window: requests open or settings (evidence: `Views/MainWindow.xaml.cs`)
- Window behavior → Settings persistence: reads and saves window state (evidence: `Services/WindowService.cs`)
- Windows startup → Windows Registry: reads and writes (evidence: `Services/StartupService.cs`)
- Desktop user → System tray: uses tray menu (evidence: `README.md`)
- Desktop user → Settings view model: configures servers (evidence: `README.md`)
- Desktop user → Window behavior: toggles fullscreen (evidence: `README.md`)
- Desktop user → Windows startup: enables auto-start (evidence: `README.md`)
- Settings persistence → Application settings: persists locally (evidence: `README.md`)
- WebView2 lifecycle → Home Assistant server: renders dashboard (evidence: `README.md`)
- WebView2 lifecycle → Server profiles: isolates browser data (evidence: `README.md`)
