# keshavbhatt/red architecture

> Architecture diagram of the GitHub repository keshavbhatt/red, 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/keshavbhatt/red
- Repository: https://github.com/keshavbhatt/red

## Overview

Red is a native Qt desktop client for YouTube, with Desktop, Music and TV modes. The main workflow starts at launch or a user command, opens the selected YouTube experience in the embedded web view, and adds blocking and playback integrations around it. A separate download workflow provisions its engine, accepts video or playlist choices, and manages queued work. Settings and theme support both workflows; platform adapters provide desktop controls and notifications. The README documents several capabilities whose implementation was not sampled, so those branches are included with README evidence rather than implying source inspection.

Main entry points: [`src/web/script_bundle.cpp`](https://github.com/keshavbhatt/red/blob/master/src/web/script_bundle.cpp) (Injected Features), [`src/ui/main_window.cpp`](https://github.com/keshavbhatt/red/blob/master/src/ui/main_window.cpp) (Main Window), [`src/app/application.cpp`](https://github.com/keshavbhatt/red/blob/master/src/app/application.cpp) (Application), [`src/web/web_view.cpp`](https://github.com/keshavbhatt/red/blob/master/src/web/web_view.cpp) (Embedded Web View)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_launch["Launch and CLI<br/>[main.cpp]"]
  node_application["Application<br/>[application.cpp]"]
  node_instance["Single Instance"]
  node_settings["Settings<br/>[settings.cpp]"]
  node_theme["Theme Service<br/>[theme_service.cpp]"]
  node_window["Main Window<br/>[main_window.cpp]"]
end

subgraph group_web["YouTube Experience"]
  node_webview["Embedded Web View<br/>[web_view.cpp]"]
  node_profile["Web Profile<br/>[web_profile.cpp]"]
  node_interceptor["Request Blocking"]
  node_injected["Injected Features<br/>[script_bundle.cpp]"]
  node_sponsor["SponsorBlock Client"]
  node_dislikes["Dislikes Client"]
end

subgraph group_downloads["Downloads"]
  node_download_ui["Download UI"]
  node_queue["Download Queue<br/>[download_queue.cpp]"]
  node_runner["Download Runner"]
  node_engine["Engine Provisioning<br/>[engine_manager.cpp]"]
  node_probe["Media Probe<br/>[media_probe.cpp]"]
  node_cookies["Cookie Reuse"]
end

subgraph group_integrations["Desktop Services"]
  node_media["Media Controls"]
  node_tray["Tray Controls"]
  node_platform["Platform Adapters"]
  node_license["Account and License"]
end

node_user(("User"))
node_youtube(("YouTube"))
node_external(("External Services"))
node_desktop(("Desktop Environment"))

node_user -->|"starts or commands"| node_launch
node_launch -->|"creates"| node_application
node_application -->|"coordinates"| node_instance
node_application -->|"owns"| node_settings
node_application -->|"owns"| node_theme
node_launch -->|"starts mode"| node_window
node_user -->|"uses"| node_window
node_window -->|"hosts"| node_webview
node_webview -.->|"uses"| node_profile
node_profile -.->|"filters requests"| node_interceptor
node_webview -.->|"runs features"| node_injected
node_injected -->|"enhances playback"| node_youtube
node_interceptor -->|"filters network traffic"| node_youtube
node_injected -.->|"uses segments"| node_sponsor
node_injected -.->|"fetches counts"| node_dislikes
node_settings -->|"configures modes"| node_window
node_settings -->|"configures features"| node_injected
node_theme -->|"provides theme"| node_window
node_user -->|"requests download"| node_download_ui
node_download_ui -->|"queues work"| node_queue
node_queue -.->|"dispatches jobs"| node_runner
node_runner -.->|"uses engine"| node_engine
node_runner -.->|"probes media"| node_probe
node_runner -->|"reuses sign-in"| node_cookies
node_engine -->|"fetches components"| node_external
node_download_ui -->|"reports progress"| node_desktop
node_webview -->|"provides playback state"| node_media
node_media -->|"publishes media controls"| node_desktop
node_media -.->|"requests OS services"| node_platform
node_tray -->|"controls playback"| node_media
node_tray -->|"shows tray controls"| node_desktop
node_license -.->|"checks license"| node_external

click node_launch "https://github.com/keshavbhatt/red/blob/master/src/main.cpp"
click node_application "https://github.com/keshavbhatt/red/blob/master/src/app/application.cpp"
click node_instance "https://github.com/keshavbhatt/red/blob/master/src/app/single_instance.cpp"
click node_settings "https://github.com/keshavbhatt/red/blob/master/src/core/settings/settings.cpp"
click node_theme "https://github.com/keshavbhatt/red/blob/master/src/core/theme/theme_service.cpp"
click node_window "https://github.com/keshavbhatt/red/blob/master/src/ui/main_window.cpp"
click node_webview "https://github.com/keshavbhatt/red/blob/master/src/web/web_view.cpp"
click node_profile "https://github.com/keshavbhatt/red/blob/master/src/web/web_profile.cpp"
click node_interceptor "https://github.com/keshavbhatt/red/blob/master/src/web/request_interceptor.cpp"
click node_injected "https://github.com/keshavbhatt/red/blob/master/src/web/script_bundle.cpp"
click node_sponsor "https://github.com/keshavbhatt/red/blob/master/src/services/sponsorblock_client.cpp"
click node_dislikes "https://github.com/keshavbhatt/red/blob/master/src/services/dislikes_client.cpp"
click node_download_ui "https://github.com/keshavbhatt/red/blob/master/src/ui/download_dialog.cpp"
click node_queue "https://github.com/keshavbhatt/red/blob/master/src/core/downloads/download_queue.cpp"
click node_runner "https://github.com/keshavbhatt/red/blob/master/src/core/downloads/download_runner.cpp"
click node_engine "https://github.com/keshavbhatt/red/blob/master/src/services/engine_manager.cpp"
click node_probe "https://github.com/keshavbhatt/red/blob/master/src/services/media_probe.cpp"
click node_cookies "https://github.com/keshavbhatt/red/blob/master/src/services/netscape_cookies.cpp"
click node_media "https://github.com/keshavbhatt/red/blob/master/src/ui/media_controller.cpp"
click node_tray "https://github.com/keshavbhatt/red/blob/master/src/ui/tray_controller.cpp"
click node_platform "https://github.com/keshavbhatt/red/blob/master/src/platform/notifier_factory.cpp"
click node_license "https://github.com/keshavbhatt/red/blob/master/src/modules/AccountAndLicense/AccountLicenseManager.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_launch,node_application,node_instance,node_settings,node_theme,node_window,node_user toneBlue
class node_webview,node_profile,node_interceptor,node_injected,node_sponsor,node_dislikes toneAmber
class node_download_ui,node_queue,node_runner,node_engine,node_probe,node_cookies toneMint
class node_media,node_tray,node_platform,node_license toneRose
class node_youtube,node_external,node_desktop toneIndigo
```

## Components

### Application

- [Launch and CLI](https://github.com/keshavbhatt/red/blob/master/src/main.cpp): `src/main.cpp`
- [Application](https://github.com/keshavbhatt/red/blob/master/src/app/application.cpp): `src/app/application.cpp`
- [Single Instance](https://github.com/keshavbhatt/red/blob/master/src/app/single_instance.cpp): `src/app/single_instance.cpp`
- [Settings](https://github.com/keshavbhatt/red/blob/master/src/core/settings/settings.cpp): `src/core/settings/settings.cpp`
- [Theme Service](https://github.com/keshavbhatt/red/blob/master/src/core/theme/theme_service.cpp): `src/core/theme/theme_service.cpp`
- [Main Window](https://github.com/keshavbhatt/red/blob/master/src/ui/main_window.cpp): `src/ui/main_window.cpp`

### YouTube Experience

- [Embedded Web View](https://github.com/keshavbhatt/red/blob/master/src/web/web_view.cpp): `src/web/web_view.cpp`
- [Web Profile](https://github.com/keshavbhatt/red/blob/master/src/web/web_profile.cpp): `src/web/web_profile.cpp`
- [Request Blocking](https://github.com/keshavbhatt/red/blob/master/src/web/request_interceptor.cpp): `src/web/request_interceptor.cpp`
- [Injected Features](https://github.com/keshavbhatt/red/blob/master/src/web/script_bundle.cpp): `src/web/script_bundle.cpp`
- [SponsorBlock Client](https://github.com/keshavbhatt/red/blob/master/src/services/sponsorblock_client.cpp): `src/services/sponsorblock_client.cpp`
- [Dislikes Client](https://github.com/keshavbhatt/red/blob/master/src/services/dislikes_client.cpp): `src/services/dislikes_client.cpp`

### Downloads

- [Download UI](https://github.com/keshavbhatt/red/blob/master/src/ui/download_dialog.cpp): `src/ui/download_dialog.cpp`
- [Download Queue](https://github.com/keshavbhatt/red/blob/master/src/core/downloads/download_queue.cpp): `src/core/downloads/download_queue.cpp`
- [Download Runner](https://github.com/keshavbhatt/red/blob/master/src/core/downloads/download_runner.cpp): `src/core/downloads/download_runner.cpp`
- [Engine Provisioning](https://github.com/keshavbhatt/red/blob/master/src/services/engine_manager.cpp): `src/services/engine_manager.cpp`
- [Media Probe](https://github.com/keshavbhatt/red/blob/master/src/services/media_probe.cpp): `src/services/media_probe.cpp`
- [Cookie Reuse](https://github.com/keshavbhatt/red/blob/master/src/services/netscape_cookies.cpp): `src/services/netscape_cookies.cpp`

### Desktop Services

- [Media Controls](https://github.com/keshavbhatt/red/blob/master/src/ui/media_controller.cpp): `src/ui/media_controller.cpp`
- [Tray Controls](https://github.com/keshavbhatt/red/blob/master/src/ui/tray_controller.cpp): `src/ui/tray_controller.cpp`
- [Platform Adapters](https://github.com/keshavbhatt/red/blob/master/src/platform/notifier_factory.cpp): `src/platform/notifier_factory.cpp`
- [Account and License](https://github.com/keshavbhatt/red/blob/master/src/modules/AccountAndLicense/AccountLicenseManager.cpp): `src/modules/AccountAndLicense/AccountLicenseManager.cpp`

### Other components

- **User**
- **YouTube**
- **External Services**
- **Desktop Environment**

## Connections

- User → Launch and CLI: starts or commands (evidence: `README.md`)
- Launch and CLI → Application: creates (evidence: `src/main.cpp`)
- Application → Single Instance: coordinates (evidence: `src/app/application.cpp`)
- Application → Settings: owns (evidence: `src/app/application.cpp`)
- Application → Theme Service: owns (evidence: `src/app/application.cpp`)
- Launch and CLI → Main Window: starts mode (evidence: `src/main.cpp`)
- User → Main Window: uses (evidence: `README.md`)
- Main Window → Embedded Web View: hosts (evidence: `README.md`)
- Embedded Web View → Web Profile: uses
- Web Profile → Request Blocking: filters requests
- Embedded Web View → Injected Features: runs features
- Injected Features → YouTube: enhances playback (evidence: `README.md`)
- Request Blocking → YouTube: filters network traffic (evidence: `README.md`)
- Injected Features → SponsorBlock Client: uses segments
- Injected Features → Dislikes Client: fetches counts
- Settings → Main Window: configures modes (evidence: `README.md`)
- Settings → Injected Features: configures features (evidence: `README.md`)
- Theme Service → Main Window: provides theme
- User → Download UI: requests download (evidence: `README.md`)
- Download UI → Download Queue: queues work (evidence: `README.md`)
- Download Queue → Download Runner: dispatches jobs
- Download Runner → Engine Provisioning: uses engine
- Download Runner → Media Probe: probes media
- Download Runner → Cookie Reuse: reuses sign-in (evidence: `README.md`)
- Engine Provisioning → External Services: fetches components (evidence: `src/services/engine_manager.cpp`)
- Download UI → Desktop Environment: reports progress (evidence: `README.md`)
- Embedded Web View → Media Controls: provides playback state (evidence: `README.md`)
- Media Controls → Desktop Environment: publishes media controls (evidence: `README.md`)
- Media Controls → Platform Adapters: requests OS services
- Tray Controls → Media Controls: controls playback (evidence: `README.md`)
- Tray Controls → Desktop Environment: shows tray controls (evidence: `README.md`)
- Account and License → External Services: checks license
