# mihdan15/iphone-link architecture

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

- Interactive diagram: https://gitdiagram.com/mihdan15/iphone-link
- Repository: https://github.com/mihdan15/iphone-link

## Overview

iPhone Link runs locally on Windows: the iPhone sends AirPlay video to the receiver, while a browser-based phone view and palette provide display and controls. The web API routes input and phone actions to BLE HID, and recording/screenshot requests to media storage. OBS has a separate clean video view. The graph preserves setup, discovery, input mapping, and UI branches; unsampled subsystems are included only where the README or source index supports them, so some internal links are intentionally omitted.

Main entry points: [`src/Program.cs`](https://github.com/mihdan15/iphone-link/blob/main/src/Program.cs) (Application startup), [`src/WebServer.cs`](https://github.com/mihdan15/iphone-link/blob/main/src/WebServer.cs) (Local web server), [`src/InputEngine.cs`](https://github.com/mihdan15/iphone-link/blob/main/src/InputEngine.cs) (Input engine), [`src/BlePeripheral.cs`](https://github.com/mihdan15/iphone-link/blob/main/src/BlePeripheral.cs) (BLE HID peripheral)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_program["Application startup<br/>[Program.cs]"]
  node_webserver["Local web server<br/>[WebServer.cs]"]
end

subgraph group_airplay["AirPlay and video"]
  node_airplayhost["AirPlay host<br/>[AirPlayHost.cs]"]
  node_uxplay["uxplay receiver"]
  node_discovery["AirPlay discovery"]
  node_relay["Video relay<br/>[VideoRelay.cs]"]
end

subgraph group_control["Bluetooth control"]
  node_ble["BLE HID peripheral<br/>[BlePeripheral.cs]"]
  node_input["Input engine<br/>[InputEngine.cs]"]
  node_hidmap["HID report mapping<br/>[HidMap.cs]"]
  node_keymap["Keyboard mapping<br/>[KeyMap.cs]"]
  node_phoneactions["Phone actions<br/>[PhoneActions.cs]"]
  node_assistant["Connection assistant"]
end

subgraph group_interfaces["User interfaces"]
  node_shell["Desktop windows<br/>[Shell.cs]"]
  node_phoneui["Phone view<br/>[app.js]"]
  node_palette["Floating palette<br/>[palette.js]"]
  node_obs["OBS video view<br/>[obs.js]"]
end

subgraph group_support["Media and support"]
  node_media["Capture and recording<br/>[MediaFiles.cs]"]
  node_storage[("Local data files")]
  node_paths["Application paths<br/>[AppPaths.cs]"]
  node_logger["Logging<br/>[Logger.cs]"]
  node_winrt["Windows Runtime bridge<br/>[WinRt.cs]"]
  node_power["Power handling<br/>[Power.cs]"]
end

node_iphone(("iPhone"))

node_program -->|"starts"| node_ble
node_program -->|"starts"| node_webserver
node_program -->|"starts"| node_relay
node_program -->|"creates"| node_airplayhost
node_program -->|"creates"| node_assistant
node_program -->|"creates"| node_phoneactions
node_program -->|"creates"| node_media
node_program -->|"opens"| node_shell
node_shell -->|"hosts"| node_phoneui
node_iphone -->|"sends AirPlay"| node_uxplay
node_uxplay -->|"connects receiver"| node_airplayhost
node_uxplay -->|"sends RTP"| node_relay
node_airplayhost -.->|"advertises receiver"| node_discovery
node_webserver -.->|"serves interface"| node_phoneui
node_phoneui -->|"calls API"| node_webserver
node_palette -.->|"calls API"| node_webserver
node_webserver -->|"registers viewers"| node_relay
node_relay -->|"streams video"| node_obs
node_webserver -->|"routes controls"| node_input
node_input -->|"delivers HID"| node_ble
node_input -->|"uses reports"| node_hidmap
node_input -->|"uses key mapping"| node_keymap
node_ble -->|"registers reports"| node_hidmap
node_webserver -->|"routes actions"| node_phoneactions
node_phoneactions -->|"sends keystrokes"| node_input
node_webserver -->|"starts connection"| node_assistant
node_assistant -->|"opens Control Center"| node_phoneactions
node_assistant -->|"types navigation"| node_input
node_assistant -->|"reads PIN and name"| node_airplayhost
node_webserver -->|"routes captures"| node_media
node_media -->|"writes recordings"| node_storage
node_airplayhost -->|"stores pairing data"| node_storage
node_program -->|"resolves data paths"| node_paths
node_program -->|"creates logger"| node_logger
node_ble -->|"uses platform bridge"| node_winrt
node_ble -->|"uses power support"| node_power

click node_program "https://github.com/mihdan15/iphone-link/blob/main/src/Program.cs"
click node_shell "https://github.com/mihdan15/iphone-link/blob/main/src/Shell.cs"
click node_webserver "https://github.com/mihdan15/iphone-link/blob/main/src/WebServer.cs"
click node_phoneui "https://github.com/mihdan15/iphone-link/blob/main/web/app.js"
click node_palette "https://github.com/mihdan15/iphone-link/blob/main/web/palette.js"
click node_obs "https://github.com/mihdan15/iphone-link/blob/main/web/obs.js"
click node_airplayhost "https://github.com/mihdan15/iphone-link/blob/main/src/AirPlayHost.cs"
click node_discovery "https://github.com/mihdan15/iphone-link/blob/main/src/AirPlayDiscovery.cs"
click node_relay "https://github.com/mihdan15/iphone-link/blob/main/src/VideoRelay.cs"
click node_ble "https://github.com/mihdan15/iphone-link/blob/main/src/BlePeripheral.cs"
click node_input "https://github.com/mihdan15/iphone-link/blob/main/src/InputEngine.cs"
click node_hidmap "https://github.com/mihdan15/iphone-link/blob/main/src/HidMap.cs"
click node_keymap "https://github.com/mihdan15/iphone-link/blob/main/src/KeyMap.cs"
click node_phoneactions "https://github.com/mihdan15/iphone-link/blob/main/src/PhoneActions.cs"
click node_assistant "https://github.com/mihdan15/iphone-link/blob/main/src/ConnectAssistant.cs"
click node_media "https://github.com/mihdan15/iphone-link/blob/main/src/MediaFiles.cs"
click node_paths "https://github.com/mihdan15/iphone-link/blob/main/src/AppPaths.cs"
click node_logger "https://github.com/mihdan15/iphone-link/blob/main/src/Logger.cs"
click node_winrt "https://github.com/mihdan15/iphone-link/blob/main/src/WinRt.cs"
click node_power "https://github.com/mihdan15/iphone-link/blob/main/src/Power.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_webserver toneBlue
class node_airplayhost,node_uxplay,node_discovery,node_relay toneAmber
class node_ble,node_input,node_hidmap,node_keymap,node_phoneactions,node_assistant toneMint
class node_shell,node_phoneui,node_palette,node_obs toneRose
class node_media,node_storage,node_paths,node_logger,node_winrt,node_power,node_iphone toneIndigo
```

## Components

### Application runtime

- [Application startup](https://github.com/mihdan15/iphone-link/blob/main/src/Program.cs): `src/Program.cs`
- [Local web server](https://github.com/mihdan15/iphone-link/blob/main/src/WebServer.cs): `src/WebServer.cs`

### AirPlay and video

- [AirPlay host](https://github.com/mihdan15/iphone-link/blob/main/src/AirPlayHost.cs): `src/AirPlayHost.cs`
- **uxplay receiver**
- [AirPlay discovery](https://github.com/mihdan15/iphone-link/blob/main/src/AirPlayDiscovery.cs): `src/AirPlayDiscovery.cs`
- [Video relay](https://github.com/mihdan15/iphone-link/blob/main/src/VideoRelay.cs): `src/VideoRelay.cs`

### Bluetooth control

- [BLE HID peripheral](https://github.com/mihdan15/iphone-link/blob/main/src/BlePeripheral.cs): `src/BlePeripheral.cs`
- [Input engine](https://github.com/mihdan15/iphone-link/blob/main/src/InputEngine.cs): `src/InputEngine.cs`
- [HID report mapping](https://github.com/mihdan15/iphone-link/blob/main/src/HidMap.cs): `src/HidMap.cs`
- [Keyboard mapping](https://github.com/mihdan15/iphone-link/blob/main/src/KeyMap.cs): `src/KeyMap.cs`
- [Phone actions](https://github.com/mihdan15/iphone-link/blob/main/src/PhoneActions.cs): `src/PhoneActions.cs`
- [Connection assistant](https://github.com/mihdan15/iphone-link/blob/main/src/ConnectAssistant.cs): `src/ConnectAssistant.cs`

### User interfaces

- [Desktop windows](https://github.com/mihdan15/iphone-link/blob/main/src/Shell.cs): `src/Shell.cs`
- [Phone view](https://github.com/mihdan15/iphone-link/blob/main/web/app.js): `web/app.js`
- [Floating palette](https://github.com/mihdan15/iphone-link/blob/main/web/palette.js): `web/palette.js`
- [OBS video view](https://github.com/mihdan15/iphone-link/blob/main/web/obs.js): `web/obs.js`

### Media and support

- [Capture and recording](https://github.com/mihdan15/iphone-link/blob/main/src/MediaFiles.cs): `src/MediaFiles.cs`
- **Local data files**
- [Application paths](https://github.com/mihdan15/iphone-link/blob/main/src/AppPaths.cs): `src/AppPaths.cs`
- [Logging](https://github.com/mihdan15/iphone-link/blob/main/src/Logger.cs): `src/Logger.cs`
- [Windows Runtime bridge](https://github.com/mihdan15/iphone-link/blob/main/src/WinRt.cs): `src/WinRt.cs`
- [Power handling](https://github.com/mihdan15/iphone-link/blob/main/src/Power.cs): `src/Power.cs`

### Other components

- **iPhone**

## Connections

- Application startup → BLE HID peripheral: starts (evidence: `src/Program.cs`)
- Application startup → Local web server: starts (evidence: `src/Program.cs`)
- Application startup → Video relay: starts (evidence: `src/Program.cs`)
- Application startup → AirPlay host: creates (evidence: `src/Program.cs`)
- Application startup → Connection assistant: creates (evidence: `src/Program.cs`)
- Application startup → Phone actions: creates (evidence: `src/Program.cs`)
- Application startup → Capture and recording: creates (evidence: `src/Program.cs`)
- Application startup → Desktop windows: opens (evidence: `src/Program.cs`)
- Desktop windows → Phone view: hosts (evidence: `src/Shell.cs`)
- iPhone → uxplay receiver: sends AirPlay (evidence: `README.md`)
- uxplay receiver → AirPlay host: connects receiver (evidence: `src/AirPlayHost.cs`)
- uxplay receiver → Video relay: sends RTP (evidence: `README.md`)
- AirPlay host → AirPlay discovery: advertises receiver
- Local web server → Phone view: serves interface
- Phone view → Local web server: calls API (evidence: `README.md`)
- Floating palette → Local web server: calls API
- Local web server → Video relay: registers viewers (evidence: `src/WebServer.cs`)
- Video relay → OBS video view: streams video (evidence: `README.md`)
- Local web server → Input engine: routes controls (evidence: `src/WebServer.cs`)
- Input engine → BLE HID peripheral: delivers HID (evidence: `src/InputEngine.cs`)
- Input engine → HID report mapping: uses reports (evidence: `src/InputEngine.cs`)
- Input engine → Keyboard mapping: uses key mapping (evidence: `src/InputEngine.cs`)
- BLE HID peripheral → HID report mapping: registers reports (evidence: `src/BlePeripheral.cs`)
- Local web server → Phone actions: routes actions (evidence: `src/WebServer.cs`)
- Phone actions → Input engine: sends keystrokes (evidence: `src/PhoneActions.cs`)
- Local web server → Connection assistant: starts connection (evidence: `src/WebServer.cs`)
- Connection assistant → Phone actions: opens Control Center (evidence: `src/ConnectAssistant.cs`)
- Connection assistant → Input engine: types navigation (evidence: `src/ConnectAssistant.cs`)
- Connection assistant → AirPlay host: reads PIN and name (evidence: `src/ConnectAssistant.cs`)
- Local web server → Capture and recording: routes captures (evidence: `src/WebServer.cs`)
- Capture and recording → Local data files: writes recordings (evidence: `src/MediaFiles.cs`)
- AirPlay host → Local data files: stores pairing data (evidence: `src/AirPlayHost.cs`)
- Application startup → Application paths: resolves data paths (evidence: `src/Program.cs`)
- Application startup → Logging: creates logger (evidence: `src/Program.cs`)
- BLE HID peripheral → Windows Runtime bridge: uses platform bridge (evidence: `src/BlePeripheral.cs`)
- BLE HID peripheral → Power handling: uses power support (evidence: `src/BlePeripheral.cs`)
