# divyanshu0902/duoaudio architecture

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

- Interactive diagram: https://gitdiagram.com/divyanshu0902/duoaudio
- Repository: https://github.com/divyanshu0902/duoaudio

## Overview

DuoAudio is a Windows desktop app for routing system audio to two selected playback devices, with independent volume controls and speaker-mute restoration. Users select devices and start sharing in the renderer; Electron IPC passes requests to a main-process service, which supervises an isolated audio runner. That runner handles capture and dual output, while native endpoint automation manages Windows mute and default-device state. The README documents the overall capabilities; several runtime internals were not excerpted, so uncertain links are omitted.

Main entry points: [`src/audio_runner.js`](https://github.com/divyanshu0902/duoaudio/blob/main/src/audio_runner.js) (Audio Runner), [`src/main/ipc/handlers.js`](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/ipc/handlers.js) (IPC Handlers), [`src/main/audio-service.js`](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/audio-service.js) (Audio Supervisor), [`src/renderer/src/pages/Home.jsx`](https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/pages/Home.jsx) (Sharing Controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Desktop Interface"]
  node_app["App Shell<br/>[App.jsx]"]
  node_home["Sharing Controls<br/>[Home.jsx]"]
  node_devicecard["Device Controls<br/>[DeviceCard.jsx]"]
  node_settings["Settings View<br/>[Settings.jsx]"]
end

subgraph group_shell["Electron Services"]
  node_preload["Renderer Bridge<br/>[preload.js]"]
  node_main["Main Process<br/>[main.js]"]
  node_ipc["IPC Handlers<br/>[handlers.js]"]
  node_contracts["IPC Contracts<br/>[ipc-contracts.js]"]
  node_lifecycle["Lifecycle Supervisor<br/>[lifecycle.js]"]
  node_tray["System Tray<br/>[tray.js]"]
  node_devices["Device Service<br/>[device-service.js]"]
  node_worker["Enumeration Worker"]
  node_audio_service["Audio Supervisor<br/>[audio-service.js]"]
end

subgraph group_audio["Audio Runtime"]
  node_runner["Audio Runner<br/>[audio_runner.js]"]
  node_capture["System Capture<br/>[system_capture.js]"]
  node_converter["PCM Converter<br/>[pcm_converter.js]"]
  node_stream["Output Stream<br/>[output_stream.js]"]
  node_buffer[("Audio Buffer<br/>[audio_buffer.js]")]
  node_single["Single Output<br/>[single_output.js]"]
  node_telemetry["Audio Telemetry<br/>[telemetry.js]"]
end

subgraph group_windows["Windows Integration"]
  node_mute["Endpoint Mute Manager<br/>[endpoint_mute.js]"]
  node_native["Endpoint Helper"]
end

node_user(("Listener"))
node_windows_audio(("Windows Audio"))
node_outputs(("Playback Devices"))

node_user -->|"selects and starts"| node_home
node_app -->|"renders"| node_home
node_app -->|"renders"| node_settings
node_home -->|"renders"| node_devicecard
node_home -.->|"requests via IPC"| node_preload
node_preload -.->|"bridges requests"| node_ipc
node_main -->|"registers"| node_ipc
node_main -->|"creates"| node_tray
node_main -->|"coordinates"| node_lifecycle
node_ipc -->|"validates with"| node_contracts
node_ipc -->|"queries"| node_devices
node_ipc -->|"starts and stops"| node_audio_service
node_devices -->|"spawns"| node_worker
node_audio_service -->|"supervises"| node_runner
node_audio_service -->|"validates devices"| node_devices
node_audio_service -->|"manages endpoint state"| node_mute
node_runner -->|"uses"| node_converter
node_runner -->|"manages outputs"| node_stream
node_runner -->|"records"| node_telemetry
node_stream -->|"queues audio in"| node_buffer
node_single -->|"uses"| node_buffer
node_windows_audio -.->|"provides loopback audio"| node_capture
node_runner -.->|"captures system audio"| node_capture
node_outputs -.->|"receives independent streams"| node_stream
node_mute -->|"invokes helper"| node_native
node_native -.->|"controls endpoints"| node_windows_audio

click node_app "https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/App.jsx"
click node_home "https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/pages/Home.jsx"
click node_devicecard "https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/components/DeviceCard.jsx"
click node_settings "https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/pages/Settings.jsx"
click node_preload "https://github.com/divyanshu0902/duoaudio/blob/main/src/preload/preload.js"
click node_main "https://github.com/divyanshu0902/duoaudio/blob/main/src/main/main.js"
click node_ipc "https://github.com/divyanshu0902/duoaudio/blob/main/src/main/ipc/handlers.js"
click node_contracts "https://github.com/divyanshu0902/duoaudio/blob/main/src/shared/ipc-contracts.js"
click node_lifecycle "https://github.com/divyanshu0902/duoaudio/blob/main/src/main/lifecycle.js"
click node_tray "https://github.com/divyanshu0902/duoaudio/blob/main/src/main/tray.js"
click node_devices "https://github.com/divyanshu0902/duoaudio/blob/main/src/main/device-service.js"
click node_worker "https://github.com/divyanshu0902/duoaudio/blob/main/src/main/enumerate-worker.js"
click node_audio_service "https://github.com/divyanshu0902/duoaudio/blob/main/src/main/audio-service.js"
click node_runner "https://github.com/divyanshu0902/duoaudio/blob/main/src/audio_runner.js"
click node_capture "https://github.com/divyanshu0902/duoaudio/blob/main/src/system_capture.js"
click node_converter "https://github.com/divyanshu0902/duoaudio/blob/main/src/pcm_converter.js"
click node_stream "https://github.com/divyanshu0902/duoaudio/blob/main/src/output_stream.js"
click node_buffer "https://github.com/divyanshu0902/duoaudio/blob/main/src/audio_buffer.js"
click node_single "https://github.com/divyanshu0902/duoaudio/blob/main/src/single_output.js"
click node_telemetry "https://github.com/divyanshu0902/duoaudio/blob/main/src/telemetry.js"
click node_mute "https://github.com/divyanshu0902/duoaudio/blob/main/src/endpoint_mute.js"
click node_native "https://github.com/divyanshu0902/duoaudio/blob/main/src/native/duoaudio_endpoint.cpp"

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_home,node_devicecard,node_settings toneBlue
class node_preload,node_main,node_ipc,node_contracts,node_lifecycle,node_tray,node_devices,node_worker,node_audio_service toneAmber
class node_runner,node_capture,node_converter,node_stream,node_buffer,node_single,node_telemetry toneMint
class node_mute,node_native toneRose
class node_user,node_windows_audio,node_outputs toneIndigo
```

## Components

### Desktop Interface

- [App Shell](https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/App.jsx): `src/renderer/src/App.jsx`
- [Sharing Controls](https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/pages/Home.jsx): `src/renderer/src/pages/Home.jsx`
- [Device Controls](https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/components/DeviceCard.jsx): `src/renderer/src/components/DeviceCard.jsx`
- [Settings View](https://github.com/divyanshu0902/duoaudio/blob/main/src/renderer/src/pages/Settings.jsx): `src/renderer/src/pages/Settings.jsx`

### Electron Services

- [Renderer Bridge](https://github.com/divyanshu0902/duoaudio/blob/main/src/preload/preload.js): `src/preload/preload.js`
- [Main Process](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/main.js): `src/main/main.js`
- [IPC Handlers](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/ipc/handlers.js): `src/main/ipc/handlers.js`
- [IPC Contracts](https://github.com/divyanshu0902/duoaudio/blob/main/src/shared/ipc-contracts.js): `src/shared/ipc-contracts.js`
- [Lifecycle Supervisor](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/lifecycle.js): `src/main/lifecycle.js`
- [System Tray](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/tray.js): `src/main/tray.js`
- [Device Service](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/device-service.js): `src/main/device-service.js`
- [Enumeration Worker](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/enumerate-worker.js): `src/main/enumerate-worker.js`
- [Audio Supervisor](https://github.com/divyanshu0902/duoaudio/blob/main/src/main/audio-service.js): `src/main/audio-service.js`

### Audio Runtime

- [Audio Runner](https://github.com/divyanshu0902/duoaudio/blob/main/src/audio_runner.js): `src/audio_runner.js`
- [System Capture](https://github.com/divyanshu0902/duoaudio/blob/main/src/system_capture.js): `src/system_capture.js`
- [PCM Converter](https://github.com/divyanshu0902/duoaudio/blob/main/src/pcm_converter.js): `src/pcm_converter.js`
- [Output Stream](https://github.com/divyanshu0902/duoaudio/blob/main/src/output_stream.js): `src/output_stream.js`
- [Audio Buffer](https://github.com/divyanshu0902/duoaudio/blob/main/src/audio_buffer.js): `src/audio_buffer.js`
- [Single Output](https://github.com/divyanshu0902/duoaudio/blob/main/src/single_output.js): `src/single_output.js`
- [Audio Telemetry](https://github.com/divyanshu0902/duoaudio/blob/main/src/telemetry.js): `src/telemetry.js`

### Windows Integration

- [Endpoint Mute Manager](https://github.com/divyanshu0902/duoaudio/blob/main/src/endpoint_mute.js): `src/endpoint_mute.js`
- [Endpoint Helper](https://github.com/divyanshu0902/duoaudio/blob/main/src/native/duoaudio_endpoint.cpp): `src/native/duoaudio_endpoint.cpp`

### Other components

- **Listener**
- **Windows Audio**
- **Playback Devices**

## Connections

- Listener → Sharing Controls: selects and starts
- App Shell → Sharing Controls: renders (evidence: `src/renderer/src/App.jsx`)
- App Shell → Settings View: renders (evidence: `src/renderer/src/App.jsx`)
- Sharing Controls → Device Controls: renders (evidence: `src/renderer/src/pages/Home.jsx`)
- Sharing Controls → Renderer Bridge: requests via IPC
- Renderer Bridge → IPC Handlers: bridges requests
- Main Process → IPC Handlers: registers (evidence: `src/main/main.js`)
- Main Process → System Tray: creates (evidence: `src/main/main.js`)
- Main Process → Lifecycle Supervisor: coordinates (evidence: `src/main/main.js`)
- IPC Handlers → IPC Contracts: validates with (evidence: `src/main/ipc/handlers.js`)
- IPC Handlers → Device Service: queries (evidence: `src/main/ipc/handlers.js`)
- IPC Handlers → Audio Supervisor: starts and stops (evidence: `src/main/ipc/handlers.js`)
- Device Service → Enumeration Worker: spawns (evidence: `src/main/device-service.js`)
- Audio Supervisor → Audio Runner: supervises (evidence: `src/main/audio-service.js`)
- Audio Supervisor → Device Service: validates devices (evidence: `src/main/audio-service.js`)
- Audio Supervisor → Endpoint Mute Manager: manages endpoint state (evidence: `src/main/audio-service.js`)
- Audio Runner → PCM Converter: uses (evidence: `src/audio_runner.js`)
- Audio Runner → Output Stream: manages outputs (evidence: `src/audio_runner.js`)
- Audio Runner → Audio Telemetry: records (evidence: `src/audio_runner.js`)
- Output Stream → Audio Buffer: queues audio in (evidence: `src/output_stream.js`)
- Single Output → Audio Buffer: uses (evidence: `src/single_output.js`)
- Windows Audio → System Capture: provides loopback audio
- Audio Runner → System Capture: captures system audio
- Playback Devices → Output Stream: receives independent streams
- Endpoint Mute Manager → Endpoint Helper: invokes helper (evidence: `src/endpoint_mute.js`)
- Endpoint Helper → Windows Audio: controls endpoints
