# gwangil/youtube_agent architecture

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

- Interactive diagram: https://gitdiagram.com/gwangil/youtube_agent
- Repository: https://github.com/gwangil/youtube_agent

## Overview

YouTube Agent collects channel videos, obtains transcripts through captions or STT, indexes content for RAG search, and provides administration, cost controls, monitoring, and data-integrity support. The README documents the end-to-end processing stages; excerpts additionally show collector-to-extractor/database/job behavior and the agent API-to-RAG relationship. Several worker and integration internals were not excerpted, so those links are documented flows rather than claims about specific calls.

Main entry points: [`services/data-collector/app.py`](https://github.com/gwangil/youtube_agent/blob/main/services/data-collector/app.py) (Channel collector), [`services/data-processor/stt_worker.py`](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/stt_worker.py) (STT processing), [`shared/models/database.py`](https://github.com/gwangil/youtube_agent/blob/main/shared/models/database.py) (Content metadata), [`services/data-processor/vectorize_worker.py`](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/vectorize_worker.py) (Vectorization worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection and transcripts"]
  node_collector["Channel collector<br/>[app.py]"]
  node_extractor["Video extractor"]
  node_contentdb[("Content metadata<br/>[database.py]")]
  node_jobqueue["Processing jobs<br/>[database.py]"]
  node_stt["STT processing<br/>[stt_worker.py]"]
  node_sttcore["Whisper processor<br/>[stt_processor.py]"]
  node_cost["STT cost controls"]
  node_transcript[("Transcript records<br/>[database.py]")]
end

subgraph group_indexing["Processing and indexing"]
  node_vectorizer["Vectorization worker"]
  node_embeddings["Embedding utilities<br/>[embeddings.py]"]
  node_qdrant[("Vector search store")]
end

subgraph group_experience["Search and management"]
  node_costapi["Cost approvals API<br/>[stt_cost_api.py]"]
  node_agentapi["RAG API<br/>[app.py]"]
  node_rag["RAG workflow<br/>[rag_agent.py]"]
  node_admin["Admin dashboard<br/>[app.py]"]
end

subgraph group_operations["Operations and integrity"]
  node_integrity["Integrity manager"]
  node_transactions["Transactional recovery"]
  node_quality["Quality dashboard"]
  node_monitoring["Processing monitoring<br/>[monitoring_api.py]"]
  node_processorapp["Processor service<br/>[app.py]"]
end

node_youtube(("YouTube"))
node_user(("Questioner"))

node_youtube -->|"provides channel content"| node_collector
node_collector -->|"gets video metadata"| node_extractor
node_extractor -->|"retrieves videos and captions"| node_youtube
node_collector -->|"stores content"| node_contentdb
node_collector -->|"queues transcript jobs"| node_jobqueue
node_jobqueue -->|"dispatches work"| node_stt
node_stt -.->|"processes audio"| node_sttcore
node_stt -->|"checks and records cost"| node_cost
node_costapi -->|"manages approvals"| node_cost
node_stt -->|"writes transcript"| node_transcript
node_transcript -->|"supplies text for indexing"| node_vectorizer
node_vectorizer -.->|"creates vectors"| node_embeddings
node_vectorizer -->|"stores vectors"| node_qdrant
node_user -->|"submits query"| node_agentapi
node_agentapi -->|"routes search"| node_rag
node_rag -->|"searches vectors"| node_qdrant
node_rag -->|"returns timestamped answer"| node_agentapi
node_admin -.->|"manages channels and content"| node_contentdb
node_integrity -->|"checks metadata consistency"| node_contentdb
node_integrity -->|"checks vector consistency"| node_qdrant
node_quality -->|"presents integrity status"| node_integrity
node_quality -.->|"uses recovery operations"| node_transactions
node_monitoring -->|"reports processing status"| node_contentdb
node_processorapp -.->|"coordinates processing"| node_jobqueue

click node_collector "https://github.com/gwangil/youtube_agent/blob/main/services/data-collector/app.py"
click node_extractor "https://github.com/gwangil/youtube_agent/blob/main/src/youtube_agent/youtube_extractor.py"
click node_contentdb "https://github.com/gwangil/youtube_agent/blob/main/shared/models/database.py"
click node_jobqueue "https://github.com/gwangil/youtube_agent/blob/main/shared/models/database.py"
click node_stt "https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/stt_worker.py"
click node_sttcore "https://github.com/gwangil/youtube_agent/blob/main/src/youtube_agent/stt_processor.py"
click node_cost "https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/stt_cost_manager.py"
click node_costapi "https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/stt_cost_api.py"
click node_transcript "https://github.com/gwangil/youtube_agent/blob/main/shared/models/database.py"
click node_vectorizer "https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/vectorize_worker.py"
click node_embeddings "https://github.com/gwangil/youtube_agent/blob/main/shared/utils/embeddings.py"
click node_agentapi "https://github.com/gwangil/youtube_agent/blob/main/services/agent-service/app.py"
click node_rag "https://github.com/gwangil/youtube_agent/blob/main/services/agent-service/rag_agent.py"
click node_admin "https://github.com/gwangil/youtube_agent/blob/main/services/admin-dashboard/app.py"
click node_integrity "https://github.com/gwangil/youtube_agent/blob/main/services/data-integrity/data_integrity_manager.py"
click node_transactions "https://github.com/gwangil/youtube_agent/blob/main/services/data-integrity/transaction_manager.py"
click node_quality "https://github.com/gwangil/youtube_agent/blob/main/services/data-integrity/quality_dashboard.py"
click node_monitoring "https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/monitoring_api.py"
click node_processorapp "https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/app.py"

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_collector,node_extractor,node_contentdb,node_jobqueue,node_stt,node_sttcore,node_cost,node_transcript toneBlue
class node_vectorizer,node_embeddings,node_qdrant toneAmber
class node_costapi,node_agentapi,node_rag,node_admin toneMint
class node_integrity,node_transactions,node_quality,node_monitoring,node_processorapp toneRose
class node_youtube,node_user toneIndigo
```

## Components

### Collection and transcripts

- [Channel collector](https://github.com/gwangil/youtube_agent/blob/main/services/data-collector/app.py): `services/data-collector/app.py`
- [Video extractor](https://github.com/gwangil/youtube_agent/blob/main/src/youtube_agent/youtube_extractor.py): `src/youtube_agent/youtube_extractor.py`
- [Content metadata](https://github.com/gwangil/youtube_agent/blob/main/shared/models/database.py): `shared/models/database.py`
- [Processing jobs](https://github.com/gwangil/youtube_agent/blob/main/shared/models/database.py): `shared/models/database.py`
- [STT processing](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/stt_worker.py): `services/data-processor/stt_worker.py`
- [Whisper processor](https://github.com/gwangil/youtube_agent/blob/main/src/youtube_agent/stt_processor.py): `src/youtube_agent/stt_processor.py`
- [STT cost controls](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/stt_cost_manager.py): `services/data-processor/stt_cost_manager.py`
- [Transcript records](https://github.com/gwangil/youtube_agent/blob/main/shared/models/database.py): `shared/models/database.py`

### Processing and indexing

- [Vectorization worker](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/vectorize_worker.py): `services/data-processor/vectorize_worker.py`
- [Embedding utilities](https://github.com/gwangil/youtube_agent/blob/main/shared/utils/embeddings.py): `shared/utils/embeddings.py`
- **Vector search store**

### Search and management

- [Cost approvals API](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/stt_cost_api.py): `services/data-processor/stt_cost_api.py`
- [RAG API](https://github.com/gwangil/youtube_agent/blob/main/services/agent-service/app.py): `services/agent-service/app.py`
- [RAG workflow](https://github.com/gwangil/youtube_agent/blob/main/services/agent-service/rag_agent.py): `services/agent-service/rag_agent.py`
- [Admin dashboard](https://github.com/gwangil/youtube_agent/blob/main/services/admin-dashboard/app.py): `services/admin-dashboard/app.py`

### Operations and integrity

- [Integrity manager](https://github.com/gwangil/youtube_agent/blob/main/services/data-integrity/data_integrity_manager.py): `services/data-integrity/data_integrity_manager.py`
- [Transactional recovery](https://github.com/gwangil/youtube_agent/blob/main/services/data-integrity/transaction_manager.py): `services/data-integrity/transaction_manager.py`
- [Quality dashboard](https://github.com/gwangil/youtube_agent/blob/main/services/data-integrity/quality_dashboard.py): `services/data-integrity/quality_dashboard.py`
- [Processing monitoring](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/monitoring_api.py): `services/data-processor/monitoring_api.py`
- [Processor service](https://github.com/gwangil/youtube_agent/blob/main/services/data-processor/app.py): `services/data-processor/app.py`

### Other components

- **YouTube**
- **Questioner**

## Connections

- YouTube → Channel collector: provides channel content (evidence: `README.md`)
- Channel collector → Video extractor: gets video metadata (evidence: `services/data-collector/app.py`)
- Video extractor → YouTube: retrieves videos and captions (evidence: `src/youtube_agent/youtube_extractor.py`)
- Channel collector → Content metadata: stores content (evidence: `services/data-collector/app.py`)
- Channel collector → Processing jobs: queues transcript jobs (evidence: `services/data-collector/app.py`)
- Processing jobs → STT processing: dispatches work (evidence: `README.md`)
- STT processing → Whisper processor: processes audio
- STT processing → STT cost controls: checks and records cost (evidence: `services/data-processor/stt_worker.py`)
- Cost approvals API → STT cost controls: manages approvals (evidence: `services/data-processor/stt_cost_api.py`)
- STT processing → Transcript records: writes transcript (evidence: `README.md`)
- Transcript records → Vectorization worker: supplies text for indexing (evidence: `README.md`)
- Vectorization worker → Embedding utilities: creates vectors
- Vectorization worker → Vector search store: stores vectors (evidence: `README.md`)
- Questioner → RAG API: submits query (evidence: `README.md`)
- RAG API → RAG workflow: routes search (evidence: `services/agent-service/app.py`)
- RAG workflow → Vector search store: searches vectors (evidence: `README.md`)
- RAG workflow → RAG API: returns timestamped answer (evidence: `services/agent-service/rag_agent.py`)
- Admin dashboard → Content metadata: manages channels and content
- Integrity manager → Content metadata: checks metadata consistency (evidence: `services/data-integrity/data_integrity_manager.py`)
- Integrity manager → Vector search store: checks vector consistency (evidence: `services/data-integrity/data_integrity_manager.py`)
- Quality dashboard → Integrity manager: presents integrity status (evidence: `services/data-integrity/quality_dashboard.py`)
- Quality dashboard → Transactional recovery: uses recovery operations
- Processing monitoring → Content metadata: reports processing status (evidence: `services/data-processor/monitoring_api.py`)
- Processor service → Processing jobs: coordinates processing (evidence: `services/data-processor/app.py`)
