# narsing64/youtube-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/narsing64/youtube-chatbot
- Repository: https://github.com/narsing64/youtube-chatbot

## Overview

This is a Streamlit YouTube RAG chatbot. A user provides a video and asks questions: the app fetches and segments its transcript, builds timestamped documents, retrieves and reranks relevant passages, then asks an LLM for an answer with timestamp-linked sources. The visible excerpts also establish transcript-provider fallbacks, a YouTube player, and lexical reranking fallback. Source excerpts are partial, so edges are limited to relationships shown there or documented in those excerpts.

Main entry points: [`app.py`](https://github.com/narsing64/youtube-chatbot/blob/main/app.py) (Streamlit app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_app["Streamlit app<br/>[app.py]"]
  node_player["Timestamped player<br/>[app.py]"]
end

subgraph group_ingestion["Transcript ingestion"]
  node_transcript["Transcript fetching<br/>[app.py]"]
  node_youtube_transcripts["YouTube transcripts"]
  node_supadata["Supadata API"]
  node_rapidapi["RapidAPI"]
  node_chunking["Transcript chunking<br/>[app.py]"]
  node_documents["Timestamped documents<br/>[app.py]"]
end

subgraph group_retrieval["RAG answering"]
  node_vector_store[("FAISS index<br/>[app.py]")]
  node_embeddings["Jina embeddings<br/>[app.py]"]
  node_retrieval_flow["Passage retrieval<br/>[app.py]"]
  node_reranking["Passage reranking<br/>[app.py]"]
  node_jina_rerank["Jina reranker API"]
  node_llm["Answer generation<br/>[app.py]"]
  node_groq["Groq chat model"]
end

node_user(("Video viewer"))

node_user -->|"asks about video"| node_app
node_app -->|"fetches transcript"| node_transcript
node_transcript -->|"tries provider"| node_youtube_transcripts
node_transcript -->|"fallback request"| node_supadata
node_transcript -->|"fallback request"| node_rapidapi
node_app -->|"chunks transcript"| node_chunking
node_app -->|"builds documents"| node_documents
node_documents -->|"splits text"| node_chunking
node_app -->|"indexes documents"| node_embeddings
node_app -->|"creates index"| node_vector_store
node_app -->|"answers query"| node_retrieval_flow
node_retrieval_flow -->|"retrieves passages"| node_vector_store
node_retrieval_flow -->|"reranks passages"| node_reranking
node_reranking -->|"requests ranking"| node_jina_rerank
node_retrieval_flow -->|"invokes model"| node_llm
node_llm -->|"generates answer"| node_groq
node_app -->|"shows video"| node_player
node_player -->|"offers timestamps"| node_user

click node_app "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_player "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_transcript "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_chunking "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_documents "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_vector_store "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_embeddings "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_retrieval_flow "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_reranking "https://github.com/narsing64/youtube-chatbot/blob/main/app.py"
click node_llm "https://github.com/narsing64/youtube-chatbot/blob/main/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_app,node_player,node_user toneBlue
class node_transcript,node_youtube_transcripts,node_supadata,node_rapidapi,node_chunking,node_documents toneAmber
class node_vector_store,node_embeddings,node_retrieval_flow,node_reranking,node_jina_rerank,node_llm,node_groq toneMint
```

## Components

### Chat interface

- [Streamlit app](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- [Timestamped player](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`

### Transcript ingestion

- [Transcript fetching](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- **YouTube transcripts**
- **Supadata API**
- **RapidAPI**
- [Transcript chunking](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- [Timestamped documents](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`

### RAG answering

- [FAISS index](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- [Jina embeddings](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- [Passage retrieval](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- [Passage reranking](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- **Jina reranker API**
- [Answer generation](https://github.com/narsing64/youtube-chatbot/blob/main/app.py): `app.py`
- **Groq chat model**

### Other components

- **Video viewer**

## Connections

- Video viewer → Streamlit app: asks about video (evidence: `app.py`)
- Streamlit app → Transcript fetching: fetches transcript (evidence: `app.py`)
- Transcript fetching → YouTube transcripts: tries provider (evidence: `app.py`)
- Transcript fetching → Supadata API: fallback request (evidence: `app.py`)
- Transcript fetching → RapidAPI: fallback request (evidence: `app.py`)
- Streamlit app → Transcript chunking: chunks transcript (evidence: `app.py`)
- Streamlit app → Timestamped documents: builds documents (evidence: `app.py`)
- Timestamped documents → Transcript chunking: splits text (evidence: `app.py`)
- Streamlit app → Jina embeddings: indexes documents (evidence: `app.py`)
- Streamlit app → FAISS index: creates index (evidence: `app.py`)
- Streamlit app → Passage retrieval: answers query (evidence: `app.py`)
- Passage retrieval → FAISS index: retrieves passages (evidence: `app.py`)
- Passage retrieval → Passage reranking: reranks passages (evidence: `app.py`)
- Passage reranking → Jina reranker API: requests ranking (evidence: `app.py`)
- Passage retrieval → Answer generation: invokes model (evidence: `app.py`)
- Answer generation → Groq chat model: generates answer (evidence: `app.py`)
- Streamlit app → Timestamped player: shows video (evidence: `app.py`)
- Timestamped player → Video viewer: offers timestamps (evidence: `app.py`)
