# omarroth/doubletake architecture

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

- Interactive diagram: https://gitdiagram.com/omarroth/doubletake
- Repository: https://github.com/omarroth/doubletake

## Overview

doubletake is a cross-platform AirPlay sender for desktop mirroring and media playback. The interactive CLI discovers or accepts a receiver, pairs and negotiates a session, captures screen/audio or reads a media source, then streams it; the daemon adds multi-receiver control and shared capture. The graph preserves the documented capture, audio, adaptive-quality, and daemon capabilities. Evidence is limited to the supplied README and excerpts; links based only on README-level behavior cite README.md, and unsampled internals are not mapped more narrowly.

Main entry points: [`cmd/doubletake/main.go`](https://github.com/omarroth/doubletake/blob/main/cmd/doubletake/main.go) (Sender CLI), [`internal/daemon/daemon.go`](https://github.com/omarroth/doubletake/blob/main/internal/daemon/daemon.go) (Session coordinator), [`internal/airplay/client.go`](https://github.com/omarroth/doubletake/blob/main/internal/airplay/client.go) (AirPlay client), [`internal/airplay/capture.go`](https://github.com/omarroth/doubletake/blob/main/internal/airplay/capture.go) (Desktop capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_user["CLI workflow"]
  node_cli["Sender CLI<br/>[main.go]"]
  node_search["Receiver search<br/>[device_search.go]"]
end

subgraph group_control["Receiver control"]
  node_discovery["AirPlay discovery<br/>[discovery.go]"]
  node_client["AirPlay client<br/>[client.go]"]
  node_pairing["Pairing and credentials<br/>[pairing.go]"]
  node_mirror["Mirroring session<br/>[mirror.go]"]
end

subgraph group_media["Capture and media"]
  node_capture["Desktop capture<br/>[capture.go]"]
  node_broadcast["Capture broadcast"]
  node_pipeline["GStreamer pipeline"]
  node_audio["Audio capture and encoding<br/>[audio.go]"]
  node_rate["Video rate control"]
end

subgraph group_daemon["Multi-receiver daemon"]
  node_daemoncli["Daemon commands<br/>[cli.go]"]
  node_daemonclient["Daemon socket client<br/>[client.go]"]
  node_daemon["Session coordinator<br/>[daemon.go]"]
end

node_operator(("User"))
node_receiver(("AirPlay receiver"))

node_operator -->|"runs"| node_cli
node_cli -->|"selects receiver"| node_search
node_search -->|"browses"| node_discovery
node_cli -->|"connects"| node_client
node_client -->|"negotiates session"| node_receiver
node_cli -->|"pairs and verifies"| node_pairing
node_pairing -->|"authenticates"| node_receiver
node_cli -->|"starts capture"| node_capture
node_capture -->|"produces frames"| node_broadcast
node_broadcast -.->|"streams video"| node_mirror
node_cli -->|"captures audio"| node_audio
node_audio -->|"streams audio"| node_receiver
node_cli -->|"plays media source"| node_pipeline
node_pipeline -.->|"streams encoded media"| node_receiver
node_rate -->|"adapts video quality"| node_receiver
node_operator -->|"controls sessions"| node_daemoncli
node_daemoncli -->|"sends commands"| node_daemonclient
node_daemonclient -->|"sends socket request"| node_daemon
node_daemon -.->|"discovers receivers"| node_discovery
node_daemon -.->|"manages sessions"| node_client
node_daemon -->|"shares capture"| node_capture
node_daemon -->|"serves streams"| node_receiver

click node_cli "https://github.com/omarroth/doubletake/blob/main/cmd/doubletake/main.go"
click node_search "https://github.com/omarroth/doubletake/blob/main/cmd/doubletake/device_search.go"
click node_discovery "https://github.com/omarroth/doubletake/blob/main/internal/airplay/discovery.go"
click node_client "https://github.com/omarroth/doubletake/blob/main/internal/airplay/client.go"
click node_pairing "https://github.com/omarroth/doubletake/blob/main/internal/airplay/pairing.go"
click node_mirror "https://github.com/omarroth/doubletake/blob/main/internal/airplay/mirror.go"
click node_capture "https://github.com/omarroth/doubletake/blob/main/internal/airplay/capture.go"
click node_broadcast "https://github.com/omarroth/doubletake/blob/main/internal/airplay/capture_broadcast.go"
click node_pipeline "https://github.com/omarroth/doubletake/blob/main/internal/airplay/capture_pipeline_linked.go"
click node_audio "https://github.com/omarroth/doubletake/blob/main/internal/airplay/audio.go"
click node_rate "https://github.com/omarroth/doubletake/blob/main/internal/airplay/video_rate_control.go"
click node_daemoncli "https://github.com/omarroth/doubletake/blob/main/internal/daemon/daemoncli/cli.go"
click node_daemonclient "https://github.com/omarroth/doubletake/blob/main/internal/daemon/daemonclient/client.go"
click node_daemon "https://github.com/omarroth/doubletake/blob/main/internal/daemon/daemon.go"

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_cli,node_search,node_operator toneBlue
class node_discovery,node_client,node_pairing,node_mirror toneAmber
class node_capture,node_broadcast,node_pipeline,node_audio,node_rate toneMint
class node_daemoncli,node_daemonclient,node_daemon toneRose
class node_receiver toneIndigo
```

## Components

### CLI workflow

- [Sender CLI](https://github.com/omarroth/doubletake/blob/main/cmd/doubletake/main.go): `cmd/doubletake/main.go`
- [Receiver search](https://github.com/omarroth/doubletake/blob/main/cmd/doubletake/device_search.go): `cmd/doubletake/device_search.go`

### Receiver control

- [AirPlay discovery](https://github.com/omarroth/doubletake/blob/main/internal/airplay/discovery.go): `internal/airplay/discovery.go`
- [AirPlay client](https://github.com/omarroth/doubletake/blob/main/internal/airplay/client.go): `internal/airplay/client.go`
- [Pairing and credentials](https://github.com/omarroth/doubletake/blob/main/internal/airplay/pairing.go): `internal/airplay/pairing.go`
- [Mirroring session](https://github.com/omarroth/doubletake/blob/main/internal/airplay/mirror.go): `internal/airplay/mirror.go`

### Capture and media

- [Desktop capture](https://github.com/omarroth/doubletake/blob/main/internal/airplay/capture.go): `internal/airplay/capture.go`
- [Capture broadcast](https://github.com/omarroth/doubletake/blob/main/internal/airplay/capture_broadcast.go): `internal/airplay/capture_broadcast.go`
- [GStreamer pipeline](https://github.com/omarroth/doubletake/blob/main/internal/airplay/capture_pipeline_linked.go): `internal/airplay/capture_pipeline_linked.go`
- [Audio capture and encoding](https://github.com/omarroth/doubletake/blob/main/internal/airplay/audio.go): `internal/airplay/audio.go`
- [Video rate control](https://github.com/omarroth/doubletake/blob/main/internal/airplay/video_rate_control.go): `internal/airplay/video_rate_control.go`

### Multi-receiver daemon

- [Daemon commands](https://github.com/omarroth/doubletake/blob/main/internal/daemon/daemoncli/cli.go): `internal/daemon/daemoncli/cli.go`
- [Daemon socket client](https://github.com/omarroth/doubletake/blob/main/internal/daemon/daemonclient/client.go): `internal/daemon/daemonclient/client.go`
- [Session coordinator](https://github.com/omarroth/doubletake/blob/main/internal/daemon/daemon.go): `internal/daemon/daemon.go`

### Other components

- **User**
- **AirPlay receiver**

## Connections

- User → Sender CLI: runs (evidence: `README.md`)
- Sender CLI → Receiver search: selects receiver (evidence: `README.md`)
- Receiver search → AirPlay discovery: browses (evidence: `cmd/doubletake/device_search.go`)
- Sender CLI → AirPlay client: connects (evidence: `cmd/doubletake/main.go`)
- AirPlay client → AirPlay receiver: negotiates session (evidence: `README.md`)
- Sender CLI → Pairing and credentials: pairs and verifies (evidence: `cmd/doubletake/main.go`)
- Pairing and credentials → AirPlay receiver: authenticates (evidence: `README.md`)
- Sender CLI → Desktop capture: starts capture (evidence: `cmd/doubletake/main.go`)
- Desktop capture → Capture broadcast: produces frames (evidence: `README.md`)
- Capture broadcast → Mirroring session: streams video
- Sender CLI → Audio capture and encoding: captures audio (evidence: `README.md`)
- Audio capture and encoding → AirPlay receiver: streams audio (evidence: `README.md`)
- Sender CLI → GStreamer pipeline: plays media source (evidence: `README.md`)
- GStreamer pipeline → AirPlay receiver: streams encoded media
- Video rate control → AirPlay receiver: adapts video quality (evidence: `README.md`)
- User → Daemon commands: controls sessions (evidence: `README.md`)
- Daemon commands → Daemon socket client: sends commands (evidence: `internal/daemon/daemoncli/cli.go`)
- Daemon socket client → Session coordinator: sends socket request (evidence: `internal/daemon/daemonclient/client.go`)
- Session coordinator → AirPlay discovery: discovers receivers
- Session coordinator → AirPlay client: manages sessions
- Session coordinator → Desktop capture: shares capture (evidence: `internal/daemon/daemon.go`)
- Session coordinator → AirPlay receiver: serves streams (evidence: `README.md`)
