# geraldohomero/dh-youtube-database architecture

> Architecture diagram of the GitHub repository geraldohomero/dh-youtube-database, 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/geraldohomero/dh-youtube-database
- Repository: https://github.com/geraldohomero/dh-youtube-database

## Overview

This is a research-oriented YouTube collection and analysis repository. The principal documented workflow updates configured channels, gathers video metadata, comments, and transcripts, persists them in SQLite, then supports channel-specific and cross-channel analysis. The graph also preserves transcript retrieval/cleanup and audio processing as distinct capabilities. Some analysis and audio scripts were read but their internal calls were not shown, so those branches are connected only where the README documents the relationship; unsampled wiring is omitted.

Main entry points: [`db`](https://github.com/geraldohomero/dh-youtube-database/tree/main/db) (SQLite research store), [`database/db_manager.py`](https://github.com/geraldohomero/dh-youtube-database/blob/main/database/db_manager.py) (Database manager), [`api/youtube_client.py`](https://github.com/geraldohomero/dh-youtube-database/blob/main/api/youtube_client.py) (YouTube API client), [`toDatabase.py`](https://github.com/geraldohomero/dh-youtube-database/blob/main/toDatabase.py) (Ingestion runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection"]
  node_annual_update["Annual update"]
  node_period_update["Period update<br/>[periodo.py]"]
  node_ingest_runner["Ingestion runner<br/>[toDatabase.py]"]
  node_api_client["YouTube API client<br/>[youtube_client.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_processing["Enrichment"]
  node_video_service["Video processing<br/>[video_service.py]"]
  node_transcript_service["Transcript service"]
  node_transcript_fetch["Transcript retrieval<br/>[transcript.py]"]
  node_audio_tools["Audio processing<br/>[audioScript.py]"]
  node_data_models["Research data models<br/>[data_models.py]"]
end

subgraph group_storage["Persistence"]
  node_db_manager["Database manager<br/>[db_manager.py]"]
  node_sqlite[("SQLite research store")]
end

subgraph group_research["Research analysis"]
  node_channel_analysis["Channel analysis<br/>[canalEspecifico.py]"]
  node_transcript_cleaning["Transcript cleaning"]
  node_topic_analysis["Topic analysis<br/>[topic.py]"]
  node_all_channel_topics["Cross-channel topics"]
  node_database_analysis["Database analysis"]
  node_transcript_export["Missing transcript export"]
end

node_researcher(("Researcher"))
node_youtube{{"YouTube"}}
node_transcript_api{{"Transcript API"}}

node_researcher -->|"starts update"| node_annual_update
node_researcher -->|"starts ingestion"| node_ingest_runner
node_researcher -->|"starts analysis"| node_channel_analysis
node_ingest_runner -->|"reads channels"| node_config
node_ingest_runner -->|"checks existing IDs"| node_db_manager
node_ingest_runner -->|"processes channels"| node_video_service
node_video_service -->|"fetches video data"| node_api_client
node_video_service -->|"requests transcript"| node_transcript_service
node_video_service -->|"saves video comments"| node_db_manager
node_api_client -->|"fetches metadata comments"| node_youtube
node_api_client -->|"uses API keys"| node_config
node_transcript_service -->|"retrieves transcript"| node_transcript_fetch
node_transcript_fetch -->|"fetches transcript"| node_transcript_api
node_transcript_service -.->|"transcript data"| node_data_models
node_api_client -->|"builds channel details"| node_data_models
node_db_manager -->|"accepts research records"| node_data_models
node_db_manager -->|"uses database path"| node_config
node_db_manager -->|"reads and writes"| node_sqlite
node_period_update -->|"persists period results"| node_db_manager
node_period_update -->|"uses YouTube client"| node_api_client
node_period_update -->|"requests transcripts"| node_transcript_service
node_annual_update -.->|"updates channel data"| node_youtube
node_channel_analysis -.->|"analyzes stored data"| node_sqlite
node_transcript_cleaning -.->|"cleans transcript data"| node_sqlite
node_topic_analysis -.->|"analyzes research data"| node_sqlite
node_all_channel_topics -.->|"analyzes research data"| node_sqlite
node_database_analysis -.->|"reads stored data"| node_sqlite
node_transcript_export -.->|"exports missing transcripts"| node_sqlite
node_audio_tools -.->|"transcribes audio"| node_transcript_api

click node_annual_update "https://github.com/geraldohomero/dh-youtube-database/blob/main/canaisAtualizacaoAnual.py"
click node_period_update "https://github.com/geraldohomero/dh-youtube-database/blob/main/periodo.py"
click node_ingest_runner "https://github.com/geraldohomero/dh-youtube-database/blob/main/toDatabase.py"
click node_api_client "https://github.com/geraldohomero/dh-youtube-database/blob/main/api/youtube_client.py"
click node_config "https://github.com/geraldohomero/dh-youtube-database/blob/main/config.py"
click node_video_service "https://github.com/geraldohomero/dh-youtube-database/blob/main/services/video_service.py"
click node_transcript_service "https://github.com/geraldohomero/dh-youtube-database/blob/main/services/transcript_service.py"
click node_transcript_fetch "https://github.com/geraldohomero/dh-youtube-database/blob/main/data/transcriptions/transcript.py"
click node_audio_tools "https://github.com/geraldohomero/dh-youtube-database/blob/main/audio/audioScript.py"
click node_data_models "https://github.com/geraldohomero/dh-youtube-database/blob/main/models/data_models.py"
click node_db_manager "https://github.com/geraldohomero/dh-youtube-database/blob/main/database/db_manager.py"
click node_sqlite "https://github.com/geraldohomero/dh-youtube-database/tree/main/db"
click node_channel_analysis "https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/canalEspecifico.py"
click node_transcript_cleaning "https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/clean_transcripts.py"
click node_topic_analysis "https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/topic.py"
click node_all_channel_topics "https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/topicTodosCanais.py"
click node_database_analysis "https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/getDataFromSQLite.py"
click node_transcript_export "https://github.com/geraldohomero/dh-youtube-database/blob/main/export_missing_transcripts.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_annual_update,node_period_update,node_ingest_runner,node_api_client,node_config toneBlue
class node_video_service,node_transcript_service,node_transcript_fetch,node_audio_tools,node_data_models toneAmber
class node_db_manager,node_sqlite,node_transcript_api toneMint
class node_channel_analysis,node_transcript_cleaning,node_topic_analysis,node_all_channel_topics,node_database_analysis,node_transcript_export toneRose
class node_researcher,node_youtube toneIndigo
```

## Components

### Collection

- [Annual update](https://github.com/geraldohomero/dh-youtube-database/blob/main/canaisAtualizacaoAnual.py): `canaisAtualizacaoAnual.py`
- [Period update](https://github.com/geraldohomero/dh-youtube-database/blob/main/periodo.py): `periodo.py`
- [Ingestion runner](https://github.com/geraldohomero/dh-youtube-database/blob/main/toDatabase.py): `toDatabase.py`
- [YouTube API client](https://github.com/geraldohomero/dh-youtube-database/blob/main/api/youtube_client.py): `api/youtube_client.py`
- [Runtime configuration](https://github.com/geraldohomero/dh-youtube-database/blob/main/config.py): `config.py`

### Enrichment

- [Video processing](https://github.com/geraldohomero/dh-youtube-database/blob/main/services/video_service.py): `services/video_service.py`
- [Transcript service](https://github.com/geraldohomero/dh-youtube-database/blob/main/services/transcript_service.py): `services/transcript_service.py`
- [Transcript retrieval](https://github.com/geraldohomero/dh-youtube-database/blob/main/data/transcriptions/transcript.py): `data/transcriptions/transcript.py`
- [Audio processing](https://github.com/geraldohomero/dh-youtube-database/blob/main/audio/audioScript.py): `audio/audioScript.py`
- [Research data models](https://github.com/geraldohomero/dh-youtube-database/blob/main/models/data_models.py): `models/data_models.py`

### Persistence

- [Database manager](https://github.com/geraldohomero/dh-youtube-database/blob/main/database/db_manager.py): `database/db_manager.py`
- [SQLite research store](https://github.com/geraldohomero/dh-youtube-database/tree/main/db): `db`

### Research analysis

- [Channel analysis](https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/canalEspecifico.py): `pipeline/canalEspecifico.py`
- [Transcript cleaning](https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/clean_transcripts.py): `pipeline/clean_transcripts.py`
- [Topic analysis](https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/topic.py): `pipeline/topic.py`
- [Cross-channel topics](https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/topicTodosCanais.py): `pipeline/topicTodosCanais.py`
- [Database analysis](https://github.com/geraldohomero/dh-youtube-database/blob/main/pipeline/getDataFromSQLite.py): `pipeline/getDataFromSQLite.py`
- [Missing transcript export](https://github.com/geraldohomero/dh-youtube-database/blob/main/export_missing_transcripts.py): `export_missing_transcripts.py`

### Other components

- **Researcher**
- **YouTube**
- **Transcript API**

## Connections

- Researcher → Annual update: starts update (evidence: `README.md`)
- Researcher → Ingestion runner: starts ingestion (evidence: `README.md`)
- Researcher → Channel analysis: starts analysis (evidence: `README.md`)
- Ingestion runner → Runtime configuration: reads channels (evidence: `toDatabase.py`)
- Ingestion runner → Database manager: checks existing IDs (evidence: `toDatabase.py`)
- Ingestion runner → Video processing: processes channels (evidence: `toDatabase.py`)
- Video processing → YouTube API client: fetches video data (evidence: `services/video_service.py`)
- Video processing → Transcript service: requests transcript (evidence: `services/video_service.py`)
- Video processing → Database manager: saves video comments (evidence: `services/video_service.py`)
- YouTube API client → YouTube: fetches metadata comments (evidence: `README.md`)
- YouTube API client → Runtime configuration: uses API keys (evidence: `api/youtube_client.py`)
- Transcript service → Transcript retrieval: retrieves transcript (evidence: `services/transcript_service.py`)
- Transcript retrieval → Transcript API: fetches transcript (evidence: `README.md`)
- Transcript service → Research data models: transcript data
- YouTube API client → Research data models: builds channel details (evidence: `api/youtube_client.py`)
- Database manager → Research data models: accepts research records (evidence: `database/db_manager.py`)
- Database manager → Runtime configuration: uses database path (evidence: `database/db_manager.py`)
- Database manager → SQLite research store: reads and writes (evidence: `database/db_manager.py`)
- Period update → Database manager: persists period results (evidence: `README.md`)
- Period update → YouTube API client: uses YouTube client (evidence: `periodo.py`)
- Period update → Transcript service: requests transcripts (evidence: `periodo.py`)
- Annual update → YouTube: updates channel data
- Channel analysis → SQLite research store: analyzes stored data (evidence: `README.md`)
- Transcript cleaning → SQLite research store: cleans transcript data
- Topic analysis → SQLite research store: analyzes research data (evidence: `README.md`)
- Cross-channel topics → SQLite research store: analyzes research data (evidence: `README.md`)
- Database analysis → SQLite research store: reads stored data
- Missing transcript export → SQLite research store: exports missing transcripts
- Audio processing → Transcript API: transcribes audio (evidence: `README.md`)
