# abhishekadbhute-create/yt_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekadbhute-create/yt_chatbot
- Repository: https://github.com/abhishekadbhute-create/yt_chatbot

## Overview

This is a Streamlit YouTube-video RAG chatbot. Users load a video by URL or provide transcript text; the app fetches or accepts transcript content, builds a FAISS index, then rewrites questions, retrieves relevant chunks, and generates English answers. Video and chat state are maintained in the Streamlit session. The implementation is concentrated in app.py; the graph separates its documented stages and integrations. Relationships are evidenced by app.py or the README; no other runtime source files are present.

Main entry points: [`app.py`](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py) (Streamlit App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Transcript Ingestion"]
  node_app["Streamlit App<br/>[app.py]"]
  node_youtube["YouTube Transcripts"]
  node_manual["Manual Transcript"]
end

subgraph group_retrieval["RAG Retrieval"]
  node_splitter["Text Chunking<br/>[app.py]"]
  node_embeddings["Text Embeddings<br/>[app.py]"]
  node_faiss[("FAISS Vector Store<br/>[app.py]")]
end

subgraph group_answering["Answer Generation"]
  node_rewriter["Query Rewriting<br/>[app.py]"]
  node_retriever["Similarity Retrieval<br/>[app.py]"]
  node_prompt["Answer Prompt<br/>[app.py]"]
  node_llm["Hugging Face LLM"]
end

subgraph group_session["Session Management"]
  node_chat[("Chat History<br/>[app.py]")]
  node_video["Active Video State<br/>[app.py]"]
end

node_user(("Video Viewer"))

node_user -->|"loads and asks"| node_app
node_app -->|"fetches transcript"| node_youtube
node_youtube -->|"returns captions"| node_app
node_app -->|"accepts text"| node_manual
node_app -->|"chunks transcript"| node_splitter
node_app -->|"embeds chunks"| node_embeddings
node_app -->|"builds index"| node_faiss
node_app -->|"rewrites question"| node_rewriter
node_rewriter -->|"invokes model"| node_llm
node_app -->|"searches index"| node_retriever
node_retriever -->|"retrieves chunks"| node_faiss
node_app -->|"supplies context"| node_prompt
node_prompt -->|"generates answer"| node_llm
node_app -->|"resets and appends"| node_chat
node_app -->|"sets active video"| node_video

click node_app "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_splitter "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_embeddings "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_faiss "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_rewriter "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_retriever "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_prompt "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_chat "https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py"
click node_video "https://github.com/abhishekadbhute-create/yt_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_youtube,node_manual,node_user toneBlue
class node_splitter,node_embeddings,node_faiss toneAmber
class node_rewriter,node_retriever,node_prompt,node_llm toneMint
class node_chat,node_video toneRose
```

## Components

### Transcript Ingestion

- [Streamlit App](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`
- **YouTube Transcripts**
- **Manual Transcript**

### RAG Retrieval

- [Text Chunking](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`
- [Text Embeddings](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`
- [FAISS Vector Store](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`

### Answer Generation

- [Query Rewriting](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`
- [Similarity Retrieval](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`
- [Answer Prompt](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`
- **Hugging Face LLM**

### Session Management

- [Chat History](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`
- [Active Video State](https://github.com/abhishekadbhute-create/yt_chatbot/blob/main/app.py): `app.py`

### Other components

- **Video Viewer**

## Connections

- Video Viewer → Streamlit App: loads and asks (evidence: `README.md`)
- Streamlit App → YouTube Transcripts: fetches transcript (evidence: `app.py`)
- YouTube Transcripts → Streamlit App: returns captions (evidence: `app.py`)
- Streamlit App → Manual Transcript: accepts text (evidence: `app.py`)
- Streamlit App → Text Chunking: chunks transcript (evidence: `app.py`)
- Streamlit App → Text Embeddings: embeds chunks (evidence: `app.py`)
- Streamlit App → FAISS Vector Store: builds index (evidence: `app.py`)
- Streamlit App → Query Rewriting: rewrites question (evidence: `app.py`)
- Query Rewriting → Hugging Face LLM: invokes model (evidence: `app.py`)
- Streamlit App → Similarity Retrieval: searches index (evidence: `app.py`)
- Similarity Retrieval → FAISS Vector Store: retrieves chunks (evidence: `app.py`)
- Streamlit App → Answer Prompt: supplies context (evidence: `app.py`)
- Answer Prompt → Hugging Face LLM: generates answer (evidence: `app.py`)
- Streamlit App → Chat History: resets and appends (evidence: `app.py`)
- Streamlit App → Active Video State: sets active video (evidence: `app.py`)
