# brepublic/hypervstatustray architecture

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

- Interactive diagram: https://gitdiagram.com/brepublic/hypervstatustray
- Repository: https://github.com/brepublic/hypervstatustray

## Overview

HyperVStatusTray is a Windows system-tray monitor and controller for up to two Hyper-V VMs or WSL distributions. The user configures targets, then the tray polls and combines broker observations with user-session WSL observations, tracks status, and displays it in the tray. Hyper-V queries and power operations run through a secured Windows-service broker; WSL actions remain in the user session. The README documents the major menu, startup-policy, language, and SSH capabilities. Some subsystem links are based on README statements or the source index because their implementation was not excerpted.

Main entry points: [`src/UI/TrayApplicationContext.cs`](https://github.com/brepublic/hypervstatustray/blob/main/src/UI/TrayApplicationContext.cs) (Tray UI and menu), [`broker/PipeBrokerServer.cs`](https://github.com/brepublic/hypervstatustray/blob/main/broker/PipeBrokerServer.cs) (Pipe broker server), [`broker/BrokerEngine.cs`](https://github.com/brepublic/hypervstatustray/blob/main/broker/BrokerEngine.cs) (Broker command engine), [`shared/Services/ConfigService.cs`](https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/ConfigService.cs) (Configuration service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tray["Tray application"]
  node_trayapp["Tray UI and menu"]
  node_state["VM state tracker<br/>[VmStateTracker.cs]"]
  node_icons["Status icon factory<br/>[IconFactory.cs]"]
  node_policyui["Startup policy dialog"]
  node_brokerclient["Broker client<br/>[BrokerClient.cs]"]
  node_wslclient["WSL client<br/>[WslClient.cs]"]
  node_startup["Session startup<br/>[StartupManager.cs]"]
  node_trayentry["Tray entry point<br/>[Program.cs]"]
end

subgraph group_broker["Hyper-V broker"]
  node_servicehost["Windows service host"]
  node_pipeserver["Pipe broker server"]
  node_engine["Broker command engine<br/>[BrokerEngine.cs]"]
  node_hypervclient["Hyper-V operations<br/>[HyperVClient.cs]"]
  node_brokerentry["Broker entry point<br/>[Program.cs]"]
end

subgraph group_shared["Shared services and models"]
  node_configservice["Configuration service<br/>[ConfigService.cs]"]
  node_appconfig["Target configuration<br/>[AppConfig.cs]"]
  node_protocol["Pipe message protocol<br/>[BrokerProtocol.cs]"]
  node_messages["Broker messages<br/>[BrokerMessages.cs]"]
  node_paths["Application paths<br/>[AppPaths.cs]"]
  node_security["Broker security options"]
  node_logger["Logging<br/>[Logger.cs]"]
  node_localization["Localization<br/>[AppText.cs]"]
  node_startupmodel["VM startup policy<br/>[VmStartupPolicy.cs]"]
  node_sshconfig["SSH shell configuration<br/>[SshShellConfig.cs]"]
end

subgraph group_integrations["External systems"]
  node_hyperv["Hyper-V management"]
  node_wsl["WSL distributions"]
  node_vmconnect["VM console"]
  node_ssh["SSH executable"]
end

node_user(("Windows user"))

node_user -->|"uses"| node_trayapp
node_trayentry -->|"starts"| node_trayapp
node_trayapp -->|"updates"| node_state
node_trayapp -->|"renders with"| node_icons
node_trayapp -->|"requests status and actions"| node_brokerclient
node_trayapp -->|"requests WSL operations"| node_wslclient
node_trayapp -->|"opens"| node_policyui
node_trayapp -->|"uses"| node_startup
node_trayapp -->|"loads configuration"| node_configservice
node_trayapp -->|"launches console"| node_vmconnect
node_trayapp -->|"launches configured shell"| node_ssh
node_trayapp -->|"reads SSH settings"| node_sshconfig
node_wslclient -->|"queries and controls"| node_wsl
node_brokerclient -->|"exchanges messages"| node_protocol
node_protocol -->|"serializes"| node_messages
node_servicehost -->|"hosts"| node_pipeserver
node_brokerentry -->|"starts service"| node_servicehost
node_brokerentry -->|"starts server"| node_pipeserver
node_brokerclient -->|"sends pipe requests"| node_pipeserver
node_pipeserver -->|"reads and writes messages"| node_protocol
node_pipeserver -->|"authorizes clients"| node_security
node_pipeserver -->|"dispatches requests"| node_engine
node_engine -->|"queries and acts"| node_hypervclient
node_hypervclient -->|"uses WMI"| node_hyperv
node_engine -->|"loads and reloads"| node_configservice
node_configservice -->|"deserializes and validates"| node_appconfig
node_configservice -->|"gets configuration paths"| node_paths
node_engine -->|"reads and sets policy"| node_startupmodel
node_trayentry -->|"loads configuration"| node_configservice
node_engine -->|"logs operations"| node_logger
node_servicehost -->|"logs service activity"| node_logger
node_trayapp -->|"logs tray activity"| node_logger
node_appconfig -->|"validates localized values"| node_localization

click node_trayapp "https://github.com/brepublic/hypervstatustray/blob/main/src/UI/TrayApplicationContext.cs"
click node_state "https://github.com/brepublic/hypervstatustray/blob/main/src/State/VmStateTracker.cs"
click node_icons "https://github.com/brepublic/hypervstatustray/blob/main/src/UI/IconFactory.cs"
click node_policyui "https://github.com/brepublic/hypervstatustray/blob/main/src/UI/VmStartupPolicyDialog.cs"
click node_brokerclient "https://github.com/brepublic/hypervstatustray/blob/main/src/Services/BrokerClient.cs"
click node_wslclient "https://github.com/brepublic/hypervstatustray/blob/main/src/Services/WslClient.cs"
click node_startup "https://github.com/brepublic/hypervstatustray/blob/main/src/Services/StartupManager.cs"
click node_trayentry "https://github.com/brepublic/hypervstatustray/blob/main/src/Program.cs"
click node_servicehost "https://github.com/brepublic/hypervstatustray/blob/main/broker/WindowsServiceHost.cs"
click node_pipeserver "https://github.com/brepublic/hypervstatustray/blob/main/broker/PipeBrokerServer.cs"
click node_engine "https://github.com/brepublic/hypervstatustray/blob/main/broker/BrokerEngine.cs"
click node_hypervclient "https://github.com/brepublic/hypervstatustray/blob/main/broker/Services/HyperVClient.cs"
click node_brokerentry "https://github.com/brepublic/hypervstatustray/blob/main/broker/Program.cs"
click node_configservice "https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/ConfigService.cs"
click node_appconfig "https://github.com/brepublic/hypervstatustray/blob/main/shared/Models/AppConfig.cs"
click node_protocol "https://github.com/brepublic/hypervstatustray/blob/main/shared/Protocol/BrokerProtocol.cs"
click node_messages "https://github.com/brepublic/hypervstatustray/blob/main/shared/Protocol/BrokerMessages.cs"
click node_paths "https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/AppPaths.cs"
click node_security "https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/BrokerSecurityOptions.cs"
click node_logger "https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/Logger.cs"
click node_localization "https://github.com/brepublic/hypervstatustray/blob/main/shared/Localization/AppText.cs"
click node_startupmodel "https://github.com/brepublic/hypervstatustray/blob/main/shared/Models/VmStartupPolicy.cs"
click node_sshconfig "https://github.com/brepublic/hypervstatustray/blob/main/shared/Models/SshShellConfig.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_trayapp,node_state,node_icons,node_policyui,node_brokerclient,node_wslclient,node_startup,node_trayentry,node_user toneBlue
class node_servicehost,node_pipeserver,node_engine,node_hypervclient,node_brokerentry toneAmber
class node_configservice,node_appconfig,node_protocol,node_messages,node_paths,node_security,node_logger,node_localization,node_startupmodel,node_sshconfig toneMint
class node_hyperv,node_wsl,node_vmconnect,node_ssh toneRose
```

## Components

### Tray application

- [Tray UI and menu](https://github.com/brepublic/hypervstatustray/blob/main/src/UI/TrayApplicationContext.cs): `src/UI/TrayApplicationContext.cs`
- [VM state tracker](https://github.com/brepublic/hypervstatustray/blob/main/src/State/VmStateTracker.cs): `src/State/VmStateTracker.cs`
- [Status icon factory](https://github.com/brepublic/hypervstatustray/blob/main/src/UI/IconFactory.cs): `src/UI/IconFactory.cs`
- [Startup policy dialog](https://github.com/brepublic/hypervstatustray/blob/main/src/UI/VmStartupPolicyDialog.cs): `src/UI/VmStartupPolicyDialog.cs`
- [Broker client](https://github.com/brepublic/hypervstatustray/blob/main/src/Services/BrokerClient.cs): `src/Services/BrokerClient.cs`
- [WSL client](https://github.com/brepublic/hypervstatustray/blob/main/src/Services/WslClient.cs): `src/Services/WslClient.cs`
- [Session startup](https://github.com/brepublic/hypervstatustray/blob/main/src/Services/StartupManager.cs): `src/Services/StartupManager.cs`
- [Tray entry point](https://github.com/brepublic/hypervstatustray/blob/main/src/Program.cs): `src/Program.cs`

### Hyper-V broker

- [Windows service host](https://github.com/brepublic/hypervstatustray/blob/main/broker/WindowsServiceHost.cs): `broker/WindowsServiceHost.cs`
- [Pipe broker server](https://github.com/brepublic/hypervstatustray/blob/main/broker/PipeBrokerServer.cs): `broker/PipeBrokerServer.cs`
- [Broker command engine](https://github.com/brepublic/hypervstatustray/blob/main/broker/BrokerEngine.cs): `broker/BrokerEngine.cs`
- [Hyper-V operations](https://github.com/brepublic/hypervstatustray/blob/main/broker/Services/HyperVClient.cs): `broker/Services/HyperVClient.cs`
- [Broker entry point](https://github.com/brepublic/hypervstatustray/blob/main/broker/Program.cs): `broker/Program.cs`

### Shared services and models

- [Configuration service](https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/ConfigService.cs): `shared/Services/ConfigService.cs`
- [Target configuration](https://github.com/brepublic/hypervstatustray/blob/main/shared/Models/AppConfig.cs): `shared/Models/AppConfig.cs`
- [Pipe message protocol](https://github.com/brepublic/hypervstatustray/blob/main/shared/Protocol/BrokerProtocol.cs): `shared/Protocol/BrokerProtocol.cs`
- [Broker messages](https://github.com/brepublic/hypervstatustray/blob/main/shared/Protocol/BrokerMessages.cs): `shared/Protocol/BrokerMessages.cs`
- [Application paths](https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/AppPaths.cs): `shared/Services/AppPaths.cs`
- [Broker security options](https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/BrokerSecurityOptions.cs): `shared/Services/BrokerSecurityOptions.cs`
- [Logging](https://github.com/brepublic/hypervstatustray/blob/main/shared/Services/Logger.cs): `shared/Services/Logger.cs`
- [Localization](https://github.com/brepublic/hypervstatustray/blob/main/shared/Localization/AppText.cs): `shared/Localization/AppText.cs`
- [VM startup policy](https://github.com/brepublic/hypervstatustray/blob/main/shared/Models/VmStartupPolicy.cs): `shared/Models/VmStartupPolicy.cs`
- [SSH shell configuration](https://github.com/brepublic/hypervstatustray/blob/main/shared/Models/SshShellConfig.cs): `shared/Models/SshShellConfig.cs`

### External systems

- **Hyper-V management**
- **WSL distributions**
- **VM console**
- **SSH executable**

### Other components

- **Windows user**

## Connections

- Windows user → Tray UI and menu: uses (evidence: `README.md`)
- Tray entry point → Tray UI and menu: starts (evidence: `src/Program.cs`)
- Tray UI and menu → VM state tracker: updates (evidence: `src/UI/TrayApplicationContext.cs`)
- Tray UI and menu → Status icon factory: renders with (evidence: `src/UI/TrayApplicationContext.cs`)
- Tray UI and menu → Broker client: requests status and actions (evidence: `src/UI/TrayApplicationContext.cs`)
- Tray UI and menu → WSL client: requests WSL operations (evidence: `src/UI/TrayApplicationContext.cs`)
- Tray UI and menu → Startup policy dialog: opens (evidence: `src/UI/TrayApplicationContext.cs`)
- Tray UI and menu → Session startup: uses (evidence: `src/UI/TrayApplicationContext.cs`)
- Tray UI and menu → Configuration service: loads configuration (evidence: `src/UI/TrayApplicationContext.cs`)
- Tray UI and menu → VM console: launches console (evidence: `README.md`)
- Tray UI and menu → SSH executable: launches configured shell (evidence: `README.md`)
- Tray UI and menu → SSH shell configuration: reads SSH settings (evidence: `src/UI/TrayApplicationContext.cs`)
- WSL client → WSL distributions: queries and controls (evidence: `README.md`)
- Broker client → Pipe message protocol: exchanges messages (evidence: `src/Services/BrokerClient.cs`)
- Pipe message protocol → Broker messages: serializes (evidence: `shared/Protocol/BrokerProtocol.cs`)
- Windows service host → Pipe broker server: hosts (evidence: `broker/WindowsServiceHost.cs`)
- Broker entry point → Windows service host: starts service (evidence: `broker/Program.cs`)
- Broker entry point → Pipe broker server: starts server (evidence: `broker/Program.cs`)
- Broker client → Pipe broker server: sends pipe requests (evidence: `README.md`)
- Pipe broker server → Pipe message protocol: reads and writes messages (evidence: `broker/PipeBrokerServer.cs`)
- Pipe broker server → Broker security options: authorizes clients (evidence: `broker/PipeBrokerServer.cs`)
- Pipe broker server → Broker command engine: dispatches requests (evidence: `broker/PipeBrokerServer.cs`)
- Broker command engine → Hyper-V operations: queries and acts (evidence: `broker/BrokerEngine.cs`)
- Hyper-V operations → Hyper-V management: uses WMI (evidence: `README.md`)
- Broker command engine → Configuration service: loads and reloads (evidence: `broker/BrokerEngine.cs`)
- Configuration service → Target configuration: deserializes and validates (evidence: `shared/Services/ConfigService.cs`)
- Configuration service → Application paths: gets configuration paths (evidence: `shared/Services/ConfigService.cs`)
- Broker command engine → VM startup policy: reads and sets policy (evidence: `broker/BrokerEngine.cs`)
- Tray entry point → Configuration service: loads configuration (evidence: `src/Program.cs`)
- Broker command engine → Logging: logs operations (evidence: `broker/BrokerEngine.cs`)
- Windows service host → Logging: logs service activity (evidence: `broker/WindowsServiceHost.cs`)
- Tray UI and menu → Logging: logs tray activity (evidence: `src/UI/TrayApplicationContext.cs`)
- Target configuration → Localization: validates localized values (evidence: `shared/Models/AppConfig.cs`)
