# chkzl/ddtv architecture

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

- Interactive diagram: https://gitdiagram.com/chkzl/ddtv
- Repository: https://github.com/chkzl/ddtv

## Overview

DDTV is a Bilibili live-stream companion: users configure followed rooms and account access, then the Core monitors live status, records streams and chat events, and exposes status and controls through Server or Desktop. The README documents automatic recording, event capture, post-processing, REST/WebSocket access, and desktop playback. Sampled source supports several Core initialization and dependency links; some feature-level wiring is documented but its implementation was not sampled.

Main entry points: [`Core/RuntimeObject/RoomInfo.cs`](https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/RoomInfo.cs) (Room monitoring), [`Core/Init.cs`](https://github.com/chkzl/ddtv/blob/master/Core/Init.cs) (Core startup), [`Server/Program.cs`](https://github.com/chkzl/ddtv/blob/master/Server/Program.cs) (Server host), [`Desktop/MainWindow.xaml.cs`](https://github.com/chkzl/ddtv/blob/master/Desktop/MainWindow.xaml.cs) (Desktop interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core runtime"]
  node_init["Core startup<br/>[Init.cs]"]
  node_config["Settings and rooms<br/>[Config.cs]"]
  node_account["Account session<br/>[Account.cs]"]
  node_login["QR login<br/>[ByQRCode.cs]"]
  node_room["Room monitoring<br/>[RoomInfo.cs]"]
  node_chat["Live event capture"]
  node_record["Stream recording<br/>[HLS.cs]"]
  node_heartbeat["Watch heartbeat"]
  node_postprocess["Merge and transcode<br/>[Transcode.cs]"]
  node_updates["Update checks<br/>[ProgramUpdates.cs]"]
  node_operation["Operation events<br/>[OperationQueue.cs]"]
end

subgraph group_server["Server access"]
  node_api["REST API"]
  node_auth["API authentication"]
  node_websocket["WebSocket push"]
  node_serverstart["Server host<br/>[Program.cs]"]
end

subgraph group_desktop["Desktop experience"]
  node_desktopui["Desktop interface<br/>[MainWindow.xaml.cs]"]
  node_roomdata["Room dashboard data<br/>[RetrieveData.cs]"]
  node_playback["Live playback"]
end

subgraph group_client["Client shell"]
  node_client["Embedded UI shell<br/>[MainWindow.xaml.cs]"]
end

node_user(("Operator"))

node_user -.->|"configures rooms"| node_config
node_init -->|"initializes"| node_config
node_init -->|"checks login"| node_account
node_init -->|"starts checks"| node_updates
node_account -->|"supports QR login"| node_login
node_room -->|"starts listener"| node_chat
node_room -->|"manages recording"| node_record
node_heartbeat -->|"checks live status"| node_room
node_user -.->|"monitors followed rooms"| node_room
node_chat -.->|"records chat timeline"| node_record
node_record -.->|"merges and transcodes"| node_postprocess
node_serverstart -->|"hosts endpoints"| node_api
node_serverstart -->|"configures push"| node_websocket
node_api -.->|"uses authentication"| node_auth
node_user -.->|"uses REST API"| node_api
node_user -.->|"receives updates"| node_websocket
node_desktopui -.->|"displays room data"| node_roomdata
node_desktopui -.->|"opens playback"| node_playback
node_user -.->|"uses desktop GUI"| node_desktopui
node_client -->|"embeds web UI"| node_serverstart

click node_init "https://github.com/chkzl/ddtv/blob/master/Core/Init.cs"
click node_config "https://github.com/chkzl/ddtv/blob/master/Core/Config.cs"
click node_account "https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/Account.cs"
click node_login "https://github.com/chkzl/ddtv/blob/master/Core/Account/Kernel/ByQRCode.cs"
click node_room "https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/RoomInfo.cs"
click node_chat "https://github.com/chkzl/ddtv/blob/master/Core/LiveChat/LiveChatListener.cs"
click node_record "https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/Download/HLS.cs"
click node_heartbeat "https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/WatchHeartbeatManager.cs"
click node_postprocess "https://github.com/chkzl/ddtv/blob/master/Core/Tools/Transcode.cs"
click node_updates "https://github.com/chkzl/ddtv/blob/master/Core/Tools/ProgramUpdates.cs"
click node_operation "https://github.com/chkzl/ddtv/blob/master/Core/LogModule/OperationQueue.cs"
click node_api "https://github.com/chkzl/ddtv/tree/master/Server/WebAppServices/Api"
click node_auth "https://github.com/chkzl/ddtv/blob/master/Server/WebAppServices/Api/InterfaceAuthentication.cs"
click node_websocket "https://github.com/chkzl/ddtv/blob/master/Server/WebAppServices/Middleware/WebSocketControl.cs"
click node_serverstart "https://github.com/chkzl/ddtv/blob/master/Server/Program.cs"
click node_desktopui "https://github.com/chkzl/ddtv/blob/master/Desktop/MainWindow.xaml.cs"
click node_roomdata "https://github.com/chkzl/ddtv/blob/master/Desktop/DataSource/RetrieveData.cs"
click node_playback "https://github.com/chkzl/ddtv/blob/master/Desktop/Views/Windows/VlcPlayWindow.xaml.cs"
click node_client "https://github.com/chkzl/ddtv/blob/master/Client/MainWindow.xaml.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_init,node_config,node_account,node_login,node_room,node_chat,node_record,node_heartbeat,node_postprocess,node_updates,node_operation toneBlue
class node_api,node_auth,node_websocket,node_serverstart toneAmber
class node_desktopui,node_roomdata,node_playback toneMint
class node_client toneRose
class node_user toneIndigo
```

## Components

### Core runtime

- [Core startup](https://github.com/chkzl/ddtv/blob/master/Core/Init.cs): `Core/Init.cs`
- [Settings and rooms](https://github.com/chkzl/ddtv/blob/master/Core/Config.cs): `Core/Config.cs`
- [Account session](https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/Account.cs): `Core/RuntimeObject/Account.cs`
- [QR login](https://github.com/chkzl/ddtv/blob/master/Core/Account/Kernel/ByQRCode.cs): `Core/Account/Kernel/ByQRCode.cs`
- [Room monitoring](https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/RoomInfo.cs): `Core/RuntimeObject/RoomInfo.cs`
- [Live event capture](https://github.com/chkzl/ddtv/blob/master/Core/LiveChat/LiveChatListener.cs): `Core/LiveChat/LiveChatListener.cs`
- [Stream recording](https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/Download/HLS.cs): `Core/RuntimeObject/Download/HLS.cs`
- [Watch heartbeat](https://github.com/chkzl/ddtv/blob/master/Core/RuntimeObject/WatchHeartbeatManager.cs): `Core/RuntimeObject/WatchHeartbeatManager.cs`
- [Merge and transcode](https://github.com/chkzl/ddtv/blob/master/Core/Tools/Transcode.cs): `Core/Tools/Transcode.cs`
- [Update checks](https://github.com/chkzl/ddtv/blob/master/Core/Tools/ProgramUpdates.cs): `Core/Tools/ProgramUpdates.cs`
- [Operation events](https://github.com/chkzl/ddtv/blob/master/Core/LogModule/OperationQueue.cs): `Core/LogModule/OperationQueue.cs`

### Server access

- [REST API](https://github.com/chkzl/ddtv/tree/master/Server/WebAppServices/Api): `Server/WebAppServices/Api`
- [API authentication](https://github.com/chkzl/ddtv/blob/master/Server/WebAppServices/Api/InterfaceAuthentication.cs): `Server/WebAppServices/Api/InterfaceAuthentication.cs`
- [WebSocket push](https://github.com/chkzl/ddtv/blob/master/Server/WebAppServices/Middleware/WebSocketControl.cs): `Server/WebAppServices/Middleware/WebSocketControl.cs`
- [Server host](https://github.com/chkzl/ddtv/blob/master/Server/Program.cs): `Server/Program.cs`

### Desktop experience

- [Desktop interface](https://github.com/chkzl/ddtv/blob/master/Desktop/MainWindow.xaml.cs): `Desktop/MainWindow.xaml.cs`
- [Room dashboard data](https://github.com/chkzl/ddtv/blob/master/Desktop/DataSource/RetrieveData.cs): `Desktop/DataSource/RetrieveData.cs`
- [Live playback](https://github.com/chkzl/ddtv/blob/master/Desktop/Views/Windows/VlcPlayWindow.xaml.cs): `Desktop/Views/Windows/VlcPlayWindow.xaml.cs`

### Client shell

- [Embedded UI shell](https://github.com/chkzl/ddtv/blob/master/Client/MainWindow.xaml.cs): `Client/MainWindow.xaml.cs`

### Other components

- **Operator**

## Connections

- Operator → Settings and rooms: configures rooms
- Core startup → Settings and rooms: initializes (evidence: `Core/Init.cs`)
- Core startup → Account session: checks login (evidence: `Core/Init.cs`)
- Core startup → Update checks: starts checks (evidence: `Core/Init.cs`)
- Account session → QR login: supports QR login (evidence: `Core/RuntimeObject/Account.cs`)
- Room monitoring → Live event capture: starts listener (evidence: `Core/RuntimeObject/RoomInfo.cs`)
- Room monitoring → Stream recording: manages recording (evidence: `Core/RuntimeObject/RoomInfo.cs`)
- Watch heartbeat → Room monitoring: checks live status (evidence: `Core/RuntimeObject/WatchHeartbeatManager.cs`)
- Operator → Room monitoring: monitors followed rooms
- Live event capture → Stream recording: records chat timeline
- Stream recording → Merge and transcode: merges and transcodes
- Server host → REST API: hosts endpoints (evidence: `Server/Program.cs`)
- Server host → WebSocket push: configures push (evidence: `Server/Program.cs`)
- REST API → API authentication: uses authentication
- Operator → REST API: uses REST API
- Operator → WebSocket push: receives updates
- Desktop interface → Room dashboard data: displays room data
- Desktop interface → Live playback: opens playback
- Operator → Desktop interface: uses desktop GUI
- Embedded UI shell → Server host: embeds web UI
