# fernandodev0/audioduplo architecture

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

- Interactive diagram: https://gitdiagram.com/fernandodev0/audioduplo
- Repository: https://github.com/fernandodev0/audioduplo

## Overview

AudioDuplo is a Windows desktop app for routing each active audio-producing process to a selected output device, with saved choices reapplied as audio sessions appear. The main flow is the user selecting a route in the form, which persists the choice and invokes the audio service; periodic refresh enumerates active apps and outputs and reapplies saved routes through Windows AudioPolicyConfig. The README also documents route clearing, diagnostics, and a self-test. Relationships are limited to the supplied excerpts and README; no unsampled implementation is inferred.

Main entry points: [`MainForm.cs`](https://github.com/fernandodev0/audioduplo/blob/main/MainForm.cs) (Routing interface), [`AudioService.cs`](https://github.com/fernandodev0/audioduplo/blob/main/AudioService.cs) (Audio service), [`Interop/AudioPolicyConfig.cs`](https://github.com/fernandodev0/audioduplo/blob/main/Interop/AudioPolicyConfig.cs) (Windows policy API), [`Logger.cs`](https://github.com/fernandodev0/audioduplo/blob/main/Logger.cs) (Diagnostic log)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop UI"]
  node_program["App startup<br/>[Program.cs]"]
  node_form["Routing interface<br/>[MainForm.cs]"]
end

subgraph group_audio["Audio routing"]
  node_service["Audio service<br/>[AudioService.cs]"]
  node_policy["Windows policy API"]
  node_hstring["HSTRING interop<br/>[HStringHelper.cs]"]
end

subgraph group_state["Persistence and diagnostics"]
  node_settings[("Route settings<br/>[SettingsStore.cs]")]
  node_logger["Diagnostic log<br/>[Logger.cs]"]
end

node_user(("User"))
node_windows["Windows audio system"]

node_user -->|"launches"| node_program
node_program -->|"opens"| node_form
node_user -->|"selects route"| node_form
node_form -->|"queries and routes"| node_service
node_form -->|"reads and saves"| node_settings
node_form -->|"logs actions"| node_logger
node_service -->|"routes process"| node_policy
node_service -->|"enumerates audio"| node_windows
node_policy -->|"manages strings"| node_hstring
node_policy -->|"sets and reads routes"| node_windows
node_service -->|"logs support"| node_logger
node_policy -->|"logs API results"| node_logger

click node_program "https://github.com/fernandodev0/audioduplo/blob/main/Program.cs"
click node_form "https://github.com/fernandodev0/audioduplo/blob/main/MainForm.cs"
click node_service "https://github.com/fernandodev0/audioduplo/blob/main/AudioService.cs"
click node_policy "https://github.com/fernandodev0/audioduplo/blob/main/Interop/AudioPolicyConfig.cs"
click node_hstring "https://github.com/fernandodev0/audioduplo/blob/main/Interop/HStringHelper.cs"
click node_settings "https://github.com/fernandodev0/audioduplo/blob/main/SettingsStore.cs"
click node_logger "https://github.com/fernandodev0/audioduplo/blob/main/Logger.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_program,node_form,node_user toneBlue
class node_service,node_policy,node_hstring toneAmber
class node_settings,node_logger toneMint
class node_windows toneIndigo
```

## Components

### Desktop UI

- [App startup](https://github.com/fernandodev0/audioduplo/blob/main/Program.cs): `Program.cs`
- [Routing interface](https://github.com/fernandodev0/audioduplo/blob/main/MainForm.cs): `MainForm.cs`

### Audio routing

- [Audio service](https://github.com/fernandodev0/audioduplo/blob/main/AudioService.cs): `AudioService.cs`
- [Windows policy API](https://github.com/fernandodev0/audioduplo/blob/main/Interop/AudioPolicyConfig.cs): `Interop/AudioPolicyConfig.cs`
- [HSTRING interop](https://github.com/fernandodev0/audioduplo/blob/main/Interop/HStringHelper.cs): `Interop/HStringHelper.cs`

### Persistence and diagnostics

- [Route settings](https://github.com/fernandodev0/audioduplo/blob/main/SettingsStore.cs): `SettingsStore.cs`
- [Diagnostic log](https://github.com/fernandodev0/audioduplo/blob/main/Logger.cs): `Logger.cs`

### Other components

- **User**
- **Windows audio system**

## Connections

- User → App startup: launches (evidence: `README.md`)
- App startup → Routing interface: opens (evidence: `Program.cs`)
- User → Routing interface: selects route (evidence: `README.md`)
- Routing interface → Audio service: queries and routes (evidence: `MainForm.cs`)
- Routing interface → Route settings: reads and saves (evidence: `MainForm.cs`)
- Routing interface → Diagnostic log: logs actions (evidence: `MainForm.cs`)
- Audio service → Windows policy API: routes process (evidence: `AudioService.cs`)
- Audio service → Windows audio system: enumerates audio (evidence: `AudioService.cs`)
- Windows policy API → HSTRING interop: manages strings (evidence: `Interop/AudioPolicyConfig.cs`)
- Windows policy API → Windows audio system: sets and reads routes (evidence: `Interop/AudioPolicyConfig.cs`)
- Audio service → Diagnostic log: logs support (evidence: `AudioService.cs`)
- Windows policy API → Diagnostic log: logs API results (evidence: `Interop/AudioPolicyConfig.cs`)
