# hachikovn/audioroute architecture

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

- Interactive diagram: https://gitdiagram.com/hachikovn/audioroute
- Repository: https://github.com/hachikovn/audioroute

## Overview

xAudioRoute is a Windows desktop audio router. Users scan active sessions, connect app or captured-browser-tab cards to one or more output devices, adjust volume and synchronization, and retain executable-based routes and sync presets. The UI coordinates scanning, routing, mirroring, Chrome capture, persistence, tray operation, and optional update checks. The README documents capabilities whose wiring is not shown in the sampled excerpts; those are represented only where their owning module or directory is supported, without asserting unverified call paths.

Main entry points: [`src/xAudioRoute/MainWindow.xaml.cs`](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/MainWindow.xaml.cs) (Router UI), [`src/xAudioRoute/Services/AudioScanner.cs`](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioScanner.cs) (Session scanner), [`src/xAudioRoute/Services/AudioMirrorService.cs`](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioMirrorService.cs) (PCM mirroring), [`src/xAudioRoute/Services/ChromeTabAudioService.cs`](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/ChromeTabAudioService.cs) (Tab audio bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop router"]
  node_window["Router UI<br/>[MainWindow.xaml.cs]"]
  node_models["Audio models<br/>[AudioSnapshots.cs]"]
end

subgraph group_audio["Audio runtime"]
  node_scanner["Session scanner<br/>[AudioScanner.cs]"]
  node_routing["Per-app routing"]
  node_mirror["PCM mirroring"]
  node_adaptive["Adaptive PCM"]
  node_sync["Output synchronization"]
  node_volume["Device volume"]
end

subgraph group_browser["Browser capture"]
  node_chrome["Tab audio bridge"]
  node_worker["Audio bridge worker"]
  node_serviceworker["Extension controller<br/>[service-worker.js]"]
  node_offscreen["Offscreen capture<br/>[offscreen.js]"]
end

subgraph group_state["Preferences"]
  node_routes[("Route rules<br/>[RouteStore.cs]")]
  node_presets[("Sync presets")]
end

subgraph group_operations["App operations"]
  node_tray["Tray controls<br/>[TrayIconService.cs]"]
  node_startup["Startup settings<br/>[StartupService.cs]"]
  node_updates["Update checker<br/>[UpdateService.cs]"]
end

node_user(("User"))
node_release["GitHub Releases"]
node_windows["Windows audio"]
node_browseruser(("Browser user"))
node_chromeapi["Chrome APIs"]

node_user -->|"operates"| node_window
node_window -->|"requests scan"| node_scanner
node_scanner -->|"enumerates sessions"| node_windows
node_scanner -->|"returns snapshot"| node_window
node_window -->|"uses snapshots"| node_models
node_window -->|"sets routes"| node_routing
node_routing -->|"sets app endpoint"| node_windows
node_window -->|"manages extra outputs"| node_mirror
node_mirror -->|"feeds PCM"| node_adaptive
node_mirror -->|"synchronizes outputs"| node_sync
node_window -->|"adjusts devices"| node_volume
node_volume -->|"controls volume"| node_windows
node_browseruser -->|"toggles capture"| node_serviceworker
node_serviceworker -->|"captures tab"| node_chromeapi
node_serviceworker -->|"sends commands"| node_offscreen
node_offscreen -->|"starts bridge"| node_worker
node_worker -->|"streams PCM"| node_chrome
node_chrome -->|"provides tab sources"| node_window
node_chrome -->|"buffers tab PCM"| node_adaptive
node_window -->|"loads and saves"| node_routes
node_window -->|"loads and saves"| node_presets
node_window -->|"provides window actions"| node_tray
node_tray -->|"invokes actions"| node_window
node_window -->|"configures startup"| node_startup
node_window -->|"checks for updates"| node_updates
node_updates -.->|"fetches release and installer"| node_release
node_updates -->|"returns verified installer"| node_window

click node_window "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/MainWindow.xaml.cs"
click node_models "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Models/AudioSnapshots.cs"
click node_scanner "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioScanner.cs"
click node_routing "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioRoutingService.cs"
click node_mirror "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioMirrorService.cs"
click node_adaptive "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AdaptivePcmWaveProvider.cs"
click node_sync "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioOutputSynchronizer.cs"
click node_volume "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioVolumeService.cs"
click node_chrome "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/ChromeTabAudioService.cs"
click node_worker "https://github.com/hachikovn/audioroute/blob/main/extension/chrome/audio-bridge-worker.js"
click node_serviceworker "https://github.com/hachikovn/audioroute/blob/main/extension/chrome/service-worker.js"
click node_offscreen "https://github.com/hachikovn/audioroute/blob/main/extension/chrome/offscreen.js"
click node_routes "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/RouteStore.cs"
click node_presets "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/SynchronizationPresetStore.cs"
click node_tray "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/TrayIconService.cs"
click node_startup "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/StartupService.cs"
click node_updates "https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/UpdateService.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_window,node_models,node_user,node_browseruser toneBlue
class node_scanner,node_routing,node_mirror,node_adaptive,node_sync,node_volume toneAmber
class node_chrome,node_worker,node_serviceworker,node_offscreen,node_chromeapi toneMint
class node_routes,node_presets toneRose
class node_tray,node_startup,node_updates,node_release,node_windows toneIndigo
```

## Components

### Desktop router

- [Router UI](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/MainWindow.xaml.cs): `src/xAudioRoute/MainWindow.xaml.cs`
- [Audio models](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Models/AudioSnapshots.cs): `src/xAudioRoute/Models/AudioSnapshots.cs`

### Audio runtime

- [Session scanner](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioScanner.cs): `src/xAudioRoute/Services/AudioScanner.cs`
- [Per-app routing](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioRoutingService.cs): `src/xAudioRoute/Services/AudioRoutingService.cs`
- [PCM mirroring](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioMirrorService.cs): `src/xAudioRoute/Services/AudioMirrorService.cs`
- [Adaptive PCM](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AdaptivePcmWaveProvider.cs): `src/xAudioRoute/Services/AdaptivePcmWaveProvider.cs`
- [Output synchronization](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioOutputSynchronizer.cs): `src/xAudioRoute/Services/AudioOutputSynchronizer.cs`
- [Device volume](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/AudioVolumeService.cs): `src/xAudioRoute/Services/AudioVolumeService.cs`

### Browser capture

- [Tab audio bridge](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/ChromeTabAudioService.cs): `src/xAudioRoute/Services/ChromeTabAudioService.cs`
- [Audio bridge worker](https://github.com/hachikovn/audioroute/blob/main/extension/chrome/audio-bridge-worker.js): `extension/chrome/audio-bridge-worker.js`
- [Extension controller](https://github.com/hachikovn/audioroute/blob/main/extension/chrome/service-worker.js): `extension/chrome/service-worker.js`
- [Offscreen capture](https://github.com/hachikovn/audioroute/blob/main/extension/chrome/offscreen.js): `extension/chrome/offscreen.js`

### Preferences

- [Route rules](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/RouteStore.cs): `src/xAudioRoute/Services/RouteStore.cs`
- [Sync presets](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/SynchronizationPresetStore.cs): `src/xAudioRoute/Services/SynchronizationPresetStore.cs`

### App operations

- [Tray controls](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/TrayIconService.cs): `src/xAudioRoute/Services/TrayIconService.cs`
- [Startup settings](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/StartupService.cs): `src/xAudioRoute/Services/StartupService.cs`
- [Update checker](https://github.com/hachikovn/audioroute/blob/main/src/xAudioRoute/Services/UpdateService.cs): `src/xAudioRoute/Services/UpdateService.cs`

### Other components

- **User**
- **GitHub Releases**
- **Windows audio**
- **Browser user**
- **Chrome APIs**

## Connections

- User → Router UI: operates
- Router UI → Session scanner: requests scan
- Session scanner → Windows audio: enumerates sessions
- Session scanner → Router UI: returns snapshot
- Router UI → Audio models: uses snapshots
- Router UI → Per-app routing: sets routes
- Per-app routing → Windows audio: sets app endpoint
- Router UI → PCM mirroring: manages extra outputs
- PCM mirroring → Adaptive PCM: feeds PCM
- PCM mirroring → Output synchronization: synchronizes outputs
- Router UI → Device volume: adjusts devices
- Device volume → Windows audio: controls volume
- Browser user → Extension controller: toggles capture
- Extension controller → Chrome APIs: captures tab
- Extension controller → Offscreen capture: sends commands
- Offscreen capture → Audio bridge worker: starts bridge
- Audio bridge worker → Tab audio bridge: streams PCM
- Tab audio bridge → Router UI: provides tab sources
- Tab audio bridge → Adaptive PCM: buffers tab PCM
- Router UI → Route rules: loads and saves
- Router UI → Sync presets: loads and saves
- Router UI → Tray controls: provides window actions
- Tray controls → Router UI: invokes actions
- Router UI → Startup settings: configures startup
- Router UI → Update checker: checks for updates
- Update checker → GitHub Releases: fetches release and installer
- Update checker → Router UI: returns verified installer
