# chanakya2906/rag-based-ai-teaching-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/chanakya2906/rag-based-ai-teaching-assistant
- Repository: https://github.com/chanakya2906/rag-based-ai-teaching-assistant

## Overview

This repository implements a local video-lecture RAG workflow: extract audio from videos, transcribe and timestamp it into chunks, embed those chunks into a persisted store, then retrieve relevant passages and generate cited answers through Ollama. `inspect_embeddings.py` provides a separate search-and-inspection utility over the same store. Relationships below are grounded in the sampled scripts; the README is empty, so no additional capabilities are documented.

Main entry points: [`rag_chat.py`](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py) (Interactive RAG chat), [`transcribe_chunks.py`](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/transcribe_chunks.py) (Whisper transcription), [`generate_embeddings.py`](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/generate_embeddings.py) (Embedding generation), [`inspect_embeddings.py`](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/inspect_embeddings.py) (Store inspection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_media["Media preparation"]
  node_extract_audio["Audio extraction<br/>[process_video.py]"]
  node_transcription["Whisper transcription"]
  node_chunking["Timestamped chunks"]
end

subgraph group_index["Transcript indexing"]
  node_chunk_loading["Chunk loading"]
  node_embedding["Embedding generation"]
  node_rag_store[("Embedding store")]
end

subgraph group_query["Question answering"]
  node_chat_entry["Interactive RAG chat<br/>[rag_chat.py]"]
  node_retrieval["Similarity retrieval<br/>[rag_chat.py]"]
  node_prompt["Grounded prompt<br/>[rag_chat.py]"]
  node_generation["Streaming answer<br/>[rag_chat.py]"]
  node_inspection["Store inspection"]
end

node_video_input["Video files"]
node_audio_files["MP3 audio"]
node_whisper["Whisper model"]
node_chunk_files["Chunk JSON"]
node_bge_model["BGE-M3 model"]
node_ollama["Ollama service"]

node_video_input -->|"provides videos"| node_extract_audio
node_extract_audio -->|"writes MP3"| node_audio_files
node_audio_files -->|"provides audio"| node_transcription
node_transcription -->|"transcribes with"| node_whisper
node_transcription -->|"groups segments"| node_chunking
node_chunking -->|"writes chunks"| node_chunk_files
node_chunk_files -->|"loads JSON"| node_chunk_loading
node_chunk_loading -->|"supplies text"| node_embedding
node_embedding -->|"encodes chunks"| node_bge_model
node_embedding -->|"saves bundle"| node_rag_store
node_chat_entry -->|"loads bundle"| node_rag_store
node_chat_entry -->|"calls retrieval"| node_retrieval
node_retrieval -->|"encodes query"| node_bge_model
node_chat_entry -->|"builds prompt"| node_prompt
node_chat_entry -->|"streams answer"| node_generation
node_generation -->|"posts request"| node_ollama
node_inspection -->|"loads bundle"| node_rag_store
node_inspection -->|"encodes queries"| node_bge_model

click node_extract_audio "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/process_video.py"
click node_transcription "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/transcribe_chunks.py"
click node_chunking "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/transcribe_chunks.py"
click node_chunk_loading "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/generate_embeddings.py"
click node_embedding "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/generate_embeddings.py"
click node_rag_store "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/generate_embeddings.py"
click node_chat_entry "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py"
click node_retrieval "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py"
click node_prompt "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py"
click node_generation "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py"
click node_inspection "https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/inspect_embeddings.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_extract_audio,node_transcription,node_chunking toneBlue
class node_chunk_loading,node_embedding,node_rag_store toneAmber
class node_chat_entry,node_retrieval,node_prompt,node_generation,node_inspection toneMint
class node_video_input,node_audio_files,node_whisper,node_chunk_files,node_bge_model,node_ollama toneIndigo
```

## Components

### Media preparation

- [Audio extraction](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/process_video.py): `process_video.py`
- [Whisper transcription](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/transcribe_chunks.py): `transcribe_chunks.py`
- [Timestamped chunks](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/transcribe_chunks.py): `transcribe_chunks.py`

### Transcript indexing

- [Chunk loading](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/generate_embeddings.py): `generate_embeddings.py`
- [Embedding generation](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/generate_embeddings.py): `generate_embeddings.py`
- [Embedding store](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/generate_embeddings.py): `generate_embeddings.py`

### Question answering

- [Interactive RAG chat](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py): `rag_chat.py`
- [Similarity retrieval](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py): `rag_chat.py`
- [Grounded prompt](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py): `rag_chat.py`
- [Streaming answer](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/rag_chat.py): `rag_chat.py`
- [Store inspection](https://github.com/chanakya2906/rag-based-ai-teaching-assistant/blob/main/inspect_embeddings.py): `inspect_embeddings.py`

### Other components

- **Video files**
- **MP3 audio**
- **Whisper model**
- **Chunk JSON**
- **BGE-M3 model**
- **Ollama service**

## Connections

- Video files → Audio extraction: provides videos (evidence: `process_video.py`)
- Audio extraction → MP3 audio: writes MP3 (evidence: `process_video.py`)
- MP3 audio → Whisper transcription: provides audio (evidence: `transcribe_chunks.py`)
- Whisper transcription → Whisper model: transcribes with (evidence: `transcribe_chunks.py`)
- Whisper transcription → Timestamped chunks: groups segments (evidence: `transcribe_chunks.py`)
- Timestamped chunks → Chunk JSON: writes chunks (evidence: `transcribe_chunks.py`)
- Chunk JSON → Chunk loading: loads JSON (evidence: `generate_embeddings.py`)
- Chunk loading → Embedding generation: supplies text (evidence: `generate_embeddings.py`)
- Embedding generation → BGE-M3 model: encodes chunks (evidence: `generate_embeddings.py`)
- Embedding generation → Embedding store: saves bundle (evidence: `generate_embeddings.py`)
- Interactive RAG chat → Embedding store: loads bundle (evidence: `rag_chat.py`)
- Interactive RAG chat → Similarity retrieval: calls retrieval (evidence: `rag_chat.py`)
- Similarity retrieval → BGE-M3 model: encodes query (evidence: `rag_chat.py`)
- Interactive RAG chat → Grounded prompt: builds prompt (evidence: `rag_chat.py`)
- Interactive RAG chat → Streaming answer: streams answer (evidence: `rag_chat.py`)
- Streaming answer → Ollama service: posts request (evidence: `rag_chat.py`)
- Store inspection → Embedding store: loads bundle (evidence: `inspect_embeddings.py`)
- Store inspection → BGE-M3 model: encodes queries (evidence: `inspect_embeddings.py`)
