# zarazhangrui/youtube-digest architecture

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

- Interactive diagram: https://gitdiagram.com/zarazhangrui/youtube-digest
- Repository: https://github.com/zarazhangrui/youtube-digest

## Overview

YouTube Digest is a Chrome side-panel study tool for YouTube videos. The main workflow is: open a video, retrieve its native captions, then read/search or translate the transcript, generate an AI overview, and save timestamped notes or explanations. The graph also shows settings, local persistence, and page-level controls. Relationships are included where the excerpts or README support them; unsampled implementation details are not inferred.

Main entry points: [`sidepanel.js`](https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js) (Side panel), [`background.js`](https://github.com/zarazhangrui/youtube-digest/blob/main/background.js) (Background worker), [`content.js`](https://github.com/zarazhangrui/youtube-digest/blob/main/content.js) (Video page controls), [`options.js`](https://github.com/zarazhangrui/youtube-digest/blob/main/options.js) (Settings page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Study experience"]
  node_sidepanel["Side panel<br/>[sidepanel.js]"]
  node_transcript["Transcript and search<br/>[sidepanel.js]"]
  node_translation["Translation views<br/>[sidepanel.js]"]
  node_overview["AI overview<br/>[sidepanel.js]"]
  node_notes["Timestamped notes<br/>[sidepanel.js]"]
  node_page_controls["Video page controls<br/>[content.js]"]
end

subgraph group_services["Extension services"]
  node_worker["Background worker<br/>[background.js]"]
  node_transcript_fetch["Caption retrieval<br/>[background.js]"]
  node_ai_features["AI requests<br/>[background.js]"]
  node_local_data[("Local extension data")]
end

subgraph group_configuration["Settings and prompts"]
  node_settings_ui["Settings page<br/>[options.js]"]
  node_settings_model["Settings helpers<br/>[settings.js]"]
  node_prompt_text["Prompt text"]
end

subgraph group_integrations["External systems"]
  node_supadata["Supadata API"]
  node_deepseek["DeepSeek API"]
end

node_learner(("Learner"))
node_youtube["YouTube video"]

node_learner -->|"opens and uses"| node_sidepanel
node_youtube -->|"provides video context"| node_page_controls
node_page_controls -->|"requests actions"| node_worker
node_worker -->|"requests video info"| node_page_controls
node_sidepanel -->|"sends actions"| node_worker
node_worker -->|"handles retrieval"| node_transcript_fetch
node_transcript_fetch -->|"fetches captions"| node_supadata
node_transcript -->|"renders results"| node_sidepanel
node_sidepanel -->|"requests translation"| node_translation
node_sidepanel -->|"requests analysis"| node_overview
node_sidepanel -->|"manages notes"| node_notes
node_worker -->|"handles AI actions"| node_ai_features
node_ai_features -->|"sends AI requests"| node_deepseek
node_ai_features -->|"loads prompt sections"| node_prompt_text
node_transcript_fetch -->|"reads and writes cache"| node_local_data
node_notes -->|"stores notes"| node_local_data
node_settings_ui -->|"uses settings helpers"| node_settings_model
node_settings_ui -->|"saves settings"| node_local_data
node_worker -->|"normalizes settings"| node_settings_model
node_transcript -->|"seeks timestamps"| node_youtube

click node_sidepanel "https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js"
click node_transcript "https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js"
click node_translation "https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js"
click node_overview "https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js"
click node_notes "https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js"
click node_page_controls "https://github.com/zarazhangrui/youtube-digest/blob/main/content.js"
click node_worker "https://github.com/zarazhangrui/youtube-digest/blob/main/background.js"
click node_transcript_fetch "https://github.com/zarazhangrui/youtube-digest/blob/main/background.js"
click node_ai_features "https://github.com/zarazhangrui/youtube-digest/blob/main/background.js"
click node_settings_ui "https://github.com/zarazhangrui/youtube-digest/blob/main/options.js"
click node_settings_model "https://github.com/zarazhangrui/youtube-digest/blob/main/settings.js"
click node_prompt_text "https://github.com/zarazhangrui/youtube-digest/tree/main/prompts"

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_sidepanel,node_transcript,node_translation,node_overview,node_notes,node_page_controls toneBlue
class node_worker,node_transcript_fetch,node_ai_features,node_local_data toneAmber
class node_settings_ui,node_settings_model,node_prompt_text toneMint
class node_supadata,node_deepseek toneRose
class node_learner,node_youtube toneIndigo
```

## Components

### Study experience

- [Side panel](https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js): `sidepanel.js`
- [Transcript and search](https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js): `sidepanel.js`
- [Translation views](https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js): `sidepanel.js`
- [AI overview](https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js): `sidepanel.js`
- [Timestamped notes](https://github.com/zarazhangrui/youtube-digest/blob/main/sidepanel.js): `sidepanel.js`
- [Video page controls](https://github.com/zarazhangrui/youtube-digest/blob/main/content.js): `content.js`

### Extension services

- [Background worker](https://github.com/zarazhangrui/youtube-digest/blob/main/background.js): `background.js`
- [Caption retrieval](https://github.com/zarazhangrui/youtube-digest/blob/main/background.js): `background.js`
- [AI requests](https://github.com/zarazhangrui/youtube-digest/blob/main/background.js): `background.js`
- **Local extension data**

### Settings and prompts

- [Settings page](https://github.com/zarazhangrui/youtube-digest/blob/main/options.js): `options.js`
- [Settings helpers](https://github.com/zarazhangrui/youtube-digest/blob/main/settings.js): `settings.js`
- [Prompt text](https://github.com/zarazhangrui/youtube-digest/tree/main/prompts): `prompts`

### External systems

- **Supadata API**
- **DeepSeek API**

### Other components

- **Learner**
- **YouTube video**

## Connections

- Learner → Side panel: opens and uses (evidence: `README.md`)
- YouTube video → Video page controls: provides video context (evidence: `README.md`)
- Video page controls → Background worker: requests actions (evidence: `content.js`)
- Background worker → Video page controls: requests video info (evidence: `background.js`)
- Side panel → Background worker: sends actions (evidence: `sidepanel.js`)
- Background worker → Caption retrieval: handles retrieval (evidence: `background.js`)
- Caption retrieval → Supadata API: fetches captions (evidence: `background.js`)
- Transcript and search → Side panel: renders results (evidence: `README.md`)
- Side panel → Translation views: requests translation (evidence: `sidepanel.js`)
- Side panel → AI overview: requests analysis (evidence: `sidepanel.js`)
- Side panel → Timestamped notes: manages notes (evidence: `README.md`)
- Background worker → AI requests: handles AI actions (evidence: `background.js`)
- AI requests → DeepSeek API: sends AI requests (evidence: `README.md`)
- AI requests → Prompt text: loads prompt sections (evidence: `background.js`)
- Caption retrieval → Local extension data: reads and writes cache
- Timestamped notes → Local extension data: stores notes
- Settings page → Settings helpers: uses settings helpers (evidence: `options.js`)
- Settings page → Local extension data: saves settings (evidence: `options.js`)
- Background worker → Settings helpers: normalizes settings (evidence: `background.js`)
- Transcript and search → YouTube video: seeks timestamps (evidence: `README.md`)
