# lakshitaaaaaa/final_rag architecture

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

- Interactive diagram: https://gitdiagram.com/lakshitaaaaaa/final_rag
- Repository: https://github.com/lakshitaaaaaa/final_rag

## Overview

YouTube RAG Assistant lets users index videos, ask transcript-grounded questions with timestamp citations, and summarize a whole video. The primary flow fetches cached captions or transcribes audio when captions are unavailable, chunks the timestamped transcript, and indexes it for single-video or library-wide retrieval. Question answering checks relevance before generating a response in the question’s language; summarization instead processes the full transcript with map-reduce. The README also documents evaluation capabilities. Some links rely on README documentation or the source index; unsampled implementation details are not inferred.

Main entry points: [`rag/qa_chain.py`](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/qa_chain.py) (Grounded question answering), [`app.py`](https://github.com/lakshitaaaaaa/final_rag/blob/main/app.py) (Streamlit app), [`rag/ingest.py`](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/ingest.py) (Video ingestion), [`eval/run_eval.py`](https://github.com/lakshitaaaaaa/final_rag/blob/main/eval/run_eval.py) (Evaluation harness)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_ingestion["Transcript ingestion"]
  node_ingest["Video ingestion<br/>[ingest.py]"]
  node_transcript["Transcript fetch/cache<br/>[transcript.py]"]
  node_speech["Whisper fallback<br/>[speech_to_text.py]"]
  node_audio_tools["Audio download/split<br/>[speech_to_text.py]"]
  node_transcript_cache[("Transcript cache")]
  node_chunking["Timestamp chunking<br/>[chunking.py]"]
end

subgraph group_answers["Retrieval and generation"]
  node_vectorstore["Embedding and indexing<br/>[vectorstore.py]"]
  node_faiss[("FAISS indexes")]
  node_qa["Grounded question answering<br/>[qa_chain.py]"]
  node_language["Language detection<br/>[language.py]"]
  node_summarize["Whole-video summarization<br/>[summarize.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_eval_runner["Evaluation harness<br/>[run_eval.py]"]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
end

node_user(("Video viewer"))
node_groq["Groq API"]

node_user -->|"submits video/questions"| node_app
node_app -->|"requests indexing"| node_ingest
node_ingest -->|"fetches segments"| node_transcript
node_transcript -->|"reads/writes cache"| node_transcript_cache
node_transcript -->|"falls back to"| node_speech
node_speech -->|"downloads/splits audio"| node_audio_tools
node_audio_tools -.->|"provides audio"| node_groq
node_speech -->|"requests transcription"| node_groq
node_ingest -->|"chunks transcript"| node_chunking
node_ingest -->|"indexes chunks"| node_vectorstore
node_vectorstore -->|"persists indexes"| node_faiss
node_app -->|"loads index scope"| node_vectorstore
node_app -->|"requests answers"| node_qa
node_qa -->|"retrieves similar chunks"| node_faiss
node_qa -->|"detects answer language"| node_language
node_qa -->|"generates grounded answer"| node_groq
node_app -->|"requests summary"| node_summarize
node_summarize -->|"reads full transcript"| node_transcript
node_summarize -->|"chunks for map pass"| node_chunking
node_summarize -->|"uses LLM access"| node_qa
node_eval_runner -->|"runs ingestion"| node_ingest
node_eval_runner -->|"uses indexes"| node_vectorstore
node_eval_runner -->|"evaluates answers"| node_qa
node_eval_runner -->|"scores results"| node_metrics
node_metrics -->|"uses LLM judge"| node_qa
node_metrics -.->|"judges responses"| node_groq

click node_app "https://github.com/lakshitaaaaaa/final_rag/blob/main/app.py"
click node_ingest "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/ingest.py"
click node_transcript "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/transcript.py"
click node_speech "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/speech_to_text.py"
click node_audio_tools "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/speech_to_text.py"
click node_transcript_cache "https://github.com/lakshitaaaaaa/final_rag/tree/main/data/transcripts"
click node_chunking "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/chunking.py"
click node_vectorstore "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/vectorstore.py"
click node_faiss "https://github.com/lakshitaaaaaa/final_rag/tree/main/data/faiss_index"
click node_qa "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/qa_chain.py"
click node_language "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/language.py"
click node_summarize "https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/summarize.py"
click node_eval_runner "https://github.com/lakshitaaaaaa/final_rag/blob/main/eval/run_eval.py"
click node_metrics "https://github.com/lakshitaaaaaa/final_rag/blob/main/eval/metrics.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_user toneBlue
class node_ingest,node_transcript,node_speech,node_audio_tools,node_transcript_cache,node_chunking toneAmber
class node_vectorstore,node_faiss,node_qa,node_language,node_summarize,node_groq toneMint
class node_eval_runner,node_metrics toneRose
```

## Components

### User interface

- [Streamlit app](https://github.com/lakshitaaaaaa/final_rag/blob/main/app.py): `app.py`

### Transcript ingestion

- [Video ingestion](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/ingest.py): `rag/ingest.py`
- [Transcript fetch/cache](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/transcript.py): `rag/transcript.py`
- [Whisper fallback](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/speech_to_text.py): `rag/speech_to_text.py`
- [Audio download/split](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/speech_to_text.py): `rag/speech_to_text.py`
- [Transcript cache](https://github.com/lakshitaaaaaa/final_rag/tree/main/data/transcripts): `data/transcripts`
- [Timestamp chunking](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/chunking.py): `rag/chunking.py`

### Retrieval and generation

- [Embedding and indexing](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/vectorstore.py): `rag/vectorstore.py`
- [FAISS indexes](https://github.com/lakshitaaaaaa/final_rag/tree/main/data/faiss_index): `data/faiss_index`
- [Grounded question answering](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/qa_chain.py): `rag/qa_chain.py`
- [Language detection](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/language.py): `rag/language.py`
- [Whole-video summarization](https://github.com/lakshitaaaaaa/final_rag/blob/main/rag/summarize.py): `rag/summarize.py`

### Evaluation

- [Evaluation harness](https://github.com/lakshitaaaaaa/final_rag/blob/main/eval/run_eval.py): `eval/run_eval.py`
- [Evaluation metrics](https://github.com/lakshitaaaaaa/final_rag/blob/main/eval/metrics.py): `eval/metrics.py`

### Other components

- **Video viewer**
- **Groq API**

## Connections

- Video viewer → Streamlit app: submits video/questions (evidence: `README.md`)
- Streamlit app → Video ingestion: requests indexing (evidence: `app.py`)
- Video ingestion → Transcript fetch/cache: fetches segments (evidence: `rag/ingest.py`)
- Transcript fetch/cache → Transcript cache: reads/writes cache (evidence: `README.md`)
- Transcript fetch/cache → Whisper fallback: falls back to (evidence: `rag/transcript.py`)
- Whisper fallback → Audio download/split: downloads/splits audio (evidence: `rag/speech_to_text.py`)
- Audio download/split → Groq API: provides audio
- Whisper fallback → Groq API: requests transcription (evidence: `rag/speech_to_text.py`)
- Video ingestion → Timestamp chunking: chunks transcript (evidence: `rag/ingest.py`)
- Video ingestion → Embedding and indexing: indexes chunks (evidence: `rag/ingest.py`)
- Embedding and indexing → FAISS indexes: persists indexes (evidence: `rag/vectorstore.py`)
- Streamlit app → Embedding and indexing: loads index scope (evidence: `app.py`)
- Streamlit app → Grounded question answering: requests answers (evidence: `app.py`)
- Grounded question answering → FAISS indexes: retrieves similar chunks (evidence: `README.md`)
- Grounded question answering → Language detection: detects answer language (evidence: `rag/qa_chain.py`)
- Grounded question answering → Groq API: generates grounded answer (evidence: `README.md`)
- Streamlit app → Whole-video summarization: requests summary (evidence: `app.py`)
- Whole-video summarization → Transcript fetch/cache: reads full transcript (evidence: `rag/summarize.py`)
- Whole-video summarization → Timestamp chunking: chunks for map pass (evidence: `rag/summarize.py`)
- Whole-video summarization → Grounded question answering: uses LLM access (evidence: `rag/summarize.py`)
- Evaluation harness → Video ingestion: runs ingestion (evidence: `eval/run_eval.py`)
- Evaluation harness → Embedding and indexing: uses indexes (evidence: `eval/run_eval.py`)
- Evaluation harness → Grounded question answering: evaluates answers (evidence: `eval/run_eval.py`)
- Evaluation harness → Evaluation metrics: scores results (evidence: `eval/run_eval.py`)
- Evaluation metrics → Grounded question answering: uses LLM judge (evidence: `eval/metrics.py`)
- Evaluation metrics → Groq API: judges responses
