# telesphoreo/anchor architecture

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

- Interactive diagram: https://gitdiagram.com/telesphoreo/anchor
- Repository: https://github.com/telesphoreo/anchor

## Overview

Anchor is a cross-platform tray application that turns supported Anker Solix stations into a software UPS. Users configure and scan for a station, connect over Bluetooth, and monitor AC input and battery; sustained low battery while on battery power starts a cancellable countdown and ultimately a graceful shutdown. The graph includes the BLE protocol and platform transports, plus tray settings, status, update, and platform shutdown capabilities documented or indexed in the supplied evidence. Unsampled modules are represented only where the tree or README supports them; dashed edges mark unverified runtime wiring.

Main entry points: [`src/AnchorTray/TrayAppContext.cs`](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/TrayAppContext.cs) (Tray coordinator), [`src/AnchorTray/UpsMonitor.cs`](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/UpsMonitor.cs) (UPS monitor), [`src/AnchorTray/SettingsWindow.cs`](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/SettingsWindow.cs) (Settings and scan UI), [`src/SolixBle/SolixDeviceFactory.cs`](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixDeviceFactory.cs) (Device factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Tray application"]
  node_program["Application startup<br/>[Program.cs]"]
  node_config["Configuration<br/>[AppConfig.cs]"]
  node_tray["Tray coordinator<br/>[TrayAppContext.cs]"]
  node_settings["Settings and scan UI<br/>[SettingsWindow.cs]"]
  node_status["Status UI<br/>[StatusWindow.cs]"]
  node_countdown["Countdown UI<br/>[CountdownWindow.cs]"]
  node_updates["Update checker<br/>[Updater.cs]"]
  node_logger[("File log<br/>[FileLog.cs]")]
end

subgraph group_ble["Solix Bluetooth"]
  node_scanner["BLE scanner<br/>[SolixScanner.cs]"]
  node_found["Discovered station"]
  node_factory["Device factory"]
  node_models["Station model drivers"]
  node_device["Solix device session<br/>[SolixBleDevice.cs]"]
  node_negotiation["Session negotiation"]
  node_frames["Protocol frames<br/>[SolixFrame.cs]"]
  node_gatt["GATT link<br/>[IGattLink.cs]"]
  node_linuxble["Linux BlueZ transport"]
  node_windowsble["Windows BLE transport"]
end

subgraph group_policy["Shutdown policy"]
  node_monitor["UPS monitor<br/>[UpsMonitor.cs]"]
  node_engine["Policy state machine<br/>[PolicyEngine.cs]"]
end

subgraph group_platform["Platform services"]
  node_shutdown["Graceful shutdown"]
  node_notifier["Notifications"]
  node_startup["Login registration"]
end

node_user(("User"))
node_station{{"Solix power station"}}
node_os{{"Host operating system"}}

node_user -->|"configures"| node_settings
node_program -->|"loads"| node_config
node_program -->|"starts"| node_tray
node_program -.->|"registers login"| node_startup
node_settings -.->|"saves settings"| node_config
node_settings -->|"scans"| node_scanner
node_scanner -->|"returns results"| node_found
node_found -.->|"selects model"| node_factory
node_monitor -->|"creates device"| node_factory
node_factory -->|"selects driver"| node_models
node_factory -->|"creates generic"| node_device
node_monitor -->|"scans devices"| node_scanner
node_device -->|"connects through"| node_gatt
node_device -->|"negotiates session"| node_negotiation
node_negotiation -->|"builds packets"| node_frames
node_linuxble -->|"implements"| node_gatt
node_windowsble -->|"implements"| node_gatt
node_linuxble -.->|"exchanges BLE"| node_station
node_windowsble -.->|"exchanges BLE"| node_station
node_monitor -->|"reads telemetry"| node_device
node_monitor -->|"updates policy"| node_engine
node_engine -.->|"triggers countdown"| node_countdown
node_tray -->|"starts monitoring"| node_monitor
node_tray -->|"opens settings"| node_settings
node_tray -->|"updates status"| node_status
node_tray -.->|"shows countdown"| node_countdown
node_tray -->|"checks updates"| node_updates
node_tray -->|"requests shutdown"| node_shutdown
node_shutdown -->|"shuts down gracefully"| node_os
node_tray -->|"notifies user"| node_notifier
node_tray -.->|"writes events"| node_logger
node_monitor -->|"logs decisions"| node_logger

click node_program "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/Program.cs"
click node_config "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/AppConfig.cs"
click node_tray "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/TrayAppContext.cs"
click node_settings "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/SettingsWindow.cs"
click node_status "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/StatusWindow.cs"
click node_countdown "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/CountdownWindow.cs"
click node_updates "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/Updater.cs"
click node_logger "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/FileLog.cs"
click node_monitor "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/UpsMonitor.cs"
click node_engine "https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/PolicyEngine.cs"
click node_shutdown "https://github.com/telesphoreo/anchor/tree/master/src/AnchorTray/Platform"
click node_notifier "https://github.com/telesphoreo/anchor/tree/master/src/AnchorTray/Platform"
click node_startup "https://github.com/telesphoreo/anchor/tree/master/src/AnchorTray/Platform"
click node_scanner "https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixScanner.cs"
click node_found "https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/DiscoveredDevice.cs"
click node_factory "https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixDeviceFactory.cs"
click node_models "https://github.com/telesphoreo/anchor/tree/master/src/SolixBle/Devices"
click node_device "https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixBleDevice.cs"
click node_negotiation "https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/NegotiatedSession.cs"
click node_frames "https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixFrame.cs"
click node_gatt "https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/IGattLink.cs"
click node_linuxble "https://github.com/telesphoreo/anchor/tree/master/src/SolixBle/Platform/Linux"
click node_windowsble "https://github.com/telesphoreo/anchor/tree/master/src/SolixBle/Platform/Windows"

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_program,node_config,node_tray,node_settings,node_status,node_countdown,node_updates,node_logger,node_user toneBlue
class node_scanner,node_found,node_factory,node_models,node_device,node_negotiation,node_frames,node_gatt,node_linuxble,node_windowsble toneAmber
class node_monitor,node_engine toneMint
class node_shutdown,node_notifier,node_startup toneRose
class node_station,node_os toneIndigo
```

## Components

### Tray application

- [Application startup](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/Program.cs): `src/AnchorTray/Program.cs`
- [Configuration](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/AppConfig.cs): `src/AnchorTray/AppConfig.cs`
- [Tray coordinator](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/TrayAppContext.cs): `src/AnchorTray/TrayAppContext.cs`
- [Settings and scan UI](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/SettingsWindow.cs): `src/AnchorTray/SettingsWindow.cs`
- [Status UI](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/StatusWindow.cs): `src/AnchorTray/StatusWindow.cs`
- [Countdown UI](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/CountdownWindow.cs): `src/AnchorTray/CountdownWindow.cs`
- [Update checker](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/Updater.cs): `src/AnchorTray/Updater.cs`
- [File log](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/FileLog.cs): `src/AnchorTray/FileLog.cs`

### Solix Bluetooth

- [BLE scanner](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixScanner.cs): `src/SolixBle/SolixScanner.cs`
- [Discovered station](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/DiscoveredDevice.cs): `src/SolixBle/DiscoveredDevice.cs`
- [Device factory](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixDeviceFactory.cs): `src/SolixBle/SolixDeviceFactory.cs`
- [Station model drivers](https://github.com/telesphoreo/anchor/tree/master/src/SolixBle/Devices): `src/SolixBle/Devices`
- [Solix device session](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixBleDevice.cs): `src/SolixBle/SolixBleDevice.cs`
- [Session negotiation](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/NegotiatedSession.cs): `src/SolixBle/NegotiatedSession.cs`
- [Protocol frames](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/SolixFrame.cs): `src/SolixBle/SolixFrame.cs`
- [GATT link](https://github.com/telesphoreo/anchor/blob/master/src/SolixBle/IGattLink.cs): `src/SolixBle/IGattLink.cs`
- [Linux BlueZ transport](https://github.com/telesphoreo/anchor/tree/master/src/SolixBle/Platform/Linux): `src/SolixBle/Platform/Linux`
- [Windows BLE transport](https://github.com/telesphoreo/anchor/tree/master/src/SolixBle/Platform/Windows): `src/SolixBle/Platform/Windows`

### Shutdown policy

- [UPS monitor](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/UpsMonitor.cs): `src/AnchorTray/UpsMonitor.cs`
- [Policy state machine](https://github.com/telesphoreo/anchor/blob/master/src/AnchorTray/PolicyEngine.cs): `src/AnchorTray/PolicyEngine.cs`

### Platform services

- [Graceful shutdown](https://github.com/telesphoreo/anchor/tree/master/src/AnchorTray/Platform): `src/AnchorTray/Platform`
- [Notifications](https://github.com/telesphoreo/anchor/tree/master/src/AnchorTray/Platform): `src/AnchorTray/Platform`
- [Login registration](https://github.com/telesphoreo/anchor/tree/master/src/AnchorTray/Platform): `src/AnchorTray/Platform`

### Other components

- **User**
- **Solix power station**
- **Host operating system**

## Connections

- User → Settings and scan UI: configures (evidence: `README.md`)
- Application startup → Configuration: loads (evidence: `src/AnchorTray/Program.cs`)
- Application startup → Tray coordinator: starts (evidence: `src/AnchorTray/Program.cs`)
- Application startup → Login registration: registers login
- Settings and scan UI → Configuration: saves settings (evidence: `README.md`)
- Settings and scan UI → BLE scanner: scans (evidence: `src/AnchorTray/SettingsWindow.cs`)
- BLE scanner → Discovered station: returns results (evidence: `src/SolixBle/SolixScanner.cs`)
- Discovered station → Device factory: selects model (evidence: `README.md`)
- UPS monitor → Device factory: creates device (evidence: `src/AnchorTray/UpsMonitor.cs`)
- Device factory → Station model drivers: selects driver (evidence: `src/SolixBle/SolixDeviceFactory.cs`)
- Device factory → Solix device session: creates generic (evidence: `src/SolixBle/SolixDeviceFactory.cs`)
- UPS monitor → BLE scanner: scans devices (evidence: `src/AnchorTray/UpsMonitor.cs`)
- Solix device session → GATT link: connects through (evidence: `src/SolixBle/SolixBleDevice.cs`)
- Solix device session → Session negotiation: negotiates session (evidence: `src/SolixBle/SolixBleDevice.cs`)
- Session negotiation → Protocol frames: builds packets (evidence: `src/SolixBle/NegotiatedSession.cs`)
- Linux BlueZ transport → GATT link: implements (evidence: `src/SolixBle/Platform/Linux/BlueZGattLink.cs`)
- Windows BLE transport → GATT link: implements (evidence: `src/SolixBle/Platform/Windows/WinRtGattLink.cs`)
- Linux BlueZ transport → Solix power station: exchanges BLE (evidence: `README.md`)
- Windows BLE transport → Solix power station: exchanges BLE (evidence: `README.md`)
- UPS monitor → Solix device session: reads telemetry (evidence: `src/AnchorTray/UpsMonitor.cs`)
- UPS monitor → Policy state machine: updates policy (evidence: `src/AnchorTray/UpsMonitor.cs`)
- Policy state machine → Countdown UI: triggers countdown (evidence: `README.md`)
- Tray coordinator → UPS monitor: starts monitoring (evidence: `src/AnchorTray/TrayAppContext.cs`)
- Tray coordinator → Settings and scan UI: opens settings (evidence: `src/AnchorTray/TrayAppContext.cs`)
- Tray coordinator → Status UI: updates status (evidence: `src/AnchorTray/TrayAppContext.cs`)
- Tray coordinator → Countdown UI: shows countdown (evidence: `src/AnchorTray/TrayAppContext.cs`)
- Tray coordinator → Update checker: checks updates (evidence: `src/AnchorTray/TrayAppContext.cs`)
- Tray coordinator → Graceful shutdown: requests shutdown (evidence: `src/AnchorTray/TrayAppContext.cs`)
- Graceful shutdown → Host operating system: shuts down gracefully (evidence: `README.md`)
- Tray coordinator → Notifications: notifies user (evidence: `src/AnchorTray/TrayAppContext.cs`)
- Tray coordinator → File log: writes events (evidence: `src/AnchorTray/TrayAppContext.cs`)
- UPS monitor → File log: logs decisions (evidence: `src/AnchorTray/UpsMonitor.cs`)
