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

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

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

## Overview

This is a RAG teaching assistant for finding course material in video subtitles. The main workflow converts course videos into timestamped transcript chunks, embeds them for retrieval, then answers a learner’s question with relevant video and timestamp references. Learners can use either the Flask web chat or the Streamlit app; a separate CLI script offers another query path. The README documents the ingestion stages, while the sampled sources show retrieval and response generation. The audio, JSON, and video directories are documented or referenced in code but are not present in the tree.

Main entry points: [`process_incoming.py`](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/process_incoming.py) (CLI Assistant), [`app.py`](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/app.py) (Flask Assistant), [`static/js/script.js`](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/static/js/script.js) (Chat Client), [`embeddings.joblib`](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/embeddings.joblib) (Embedding Index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Media Ingestion"]
  node_video_convert["Video Converter<br/>[video_to_mp3.py]"]
  node_transcribe["Transcriber<br/>[mp3_to_json.py]"]
end

subgraph group_index["Knowledge Index"]
  node_embed_index["Index Builder<br/>[preprocess_json.py]"]
  node_embeddings[("Embedding Index<br/>[embeddings.joblib]")]
end

subgraph group_assistants["Assistant Interfaces"]
  node_flask_ui["Web Chat UI<br/>[index.html]"]
  node_browser_logic["Chat Client<br/>[script.js]"]
  node_flask_app["Flask Assistant<br/>[app.py]"]
  node_streamlit["Streamlit Assistant<br/>[streamlit_app.py]"]
  node_cli["CLI Assistant"]
end

subgraph group_services["AI Services"]
  node_ollama{{"Ollama"}}
end

node_learner(("Learner"))
node_videos["Course Videos"]
node_audio_files["Audio Files"]
node_transcripts["Transcript Chunks"]
node_prompt_file["Prompt Output<br/>[prompt.txt]"]
node_response_file["Response Output<br/>[response.txt]"]

node_videos -->|"converts"| node_video_convert
node_video_convert -->|"writes audio"| node_audio_files
node_audio_files -->|"transcribes"| node_transcribe
node_transcribe -->|"writes chunks"| node_transcripts
node_transcripts -->|"reads chunks"| node_embed_index
node_embed_index -->|"requests embeddings"| node_ollama
node_embed_index -->|"writes index"| node_embeddings
node_learner -->|"asks question"| node_browser_logic
node_flask_ui -->|"hosts chat"| node_browser_logic
node_browser_logic -->|"posts query"| node_flask_app
node_flask_app -->|"loads and searches"| node_embeddings
node_flask_app -->|"embeds and generates"| node_ollama
node_flask_app -->|"returns answer"| node_browser_logic
node_learner -->|"asks question"| node_streamlit
node_streamlit -->|"loads and searches"| node_embeddings
node_streamlit -->|"embeds and generates"| node_ollama
node_learner -->|"asks question"| node_cli
node_cli -->|"loads and searches"| node_embeddings
node_cli -->|"embeds and generates"| node_ollama
node_cli -->|"writes prompt"| node_prompt_file
node_cli -->|"writes response"| node_response_file

click node_video_convert "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/video_to_mp3.py"
click node_transcribe "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/mp3_to_json.py"
click node_embed_index "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/preprocess_json.py"
click node_embeddings "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/embeddings.joblib"
click node_flask_ui "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/templates/index.html"
click node_browser_logic "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/static/js/script.js"
click node_flask_app "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/app.py"
click node_streamlit "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/streamlit_app.py"
click node_cli "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/process_incoming.py"
click node_prompt_file "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/prompt.txt"
click node_response_file "https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/response.txt"

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_video_convert,node_transcribe toneBlue
class node_embed_index,node_embeddings toneAmber
class node_flask_ui,node_browser_logic,node_flask_app,node_streamlit,node_cli toneMint
class node_ollama toneRose
class node_learner,node_videos,node_audio_files,node_transcripts toneIndigo
class node_prompt_file,node_response_file toneTeal
```

## Components

### Media Ingestion

- [Video Converter](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/video_to_mp3.py): `video_to_mp3.py`
- [Transcriber](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/mp3_to_json.py): `mp3_to_json.py`

### Knowledge Index

- [Index Builder](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/preprocess_json.py): `preprocess_json.py`
- [Embedding Index](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/embeddings.joblib): `embeddings.joblib`

### Assistant Interfaces

- [Web Chat UI](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/templates/index.html): `templates/index.html`
- [Chat Client](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/static/js/script.js): `static/js/script.js`
- [Flask Assistant](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/app.py): `app.py`
- [Streamlit Assistant](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/streamlit_app.py): `streamlit_app.py`
- [CLI Assistant](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/process_incoming.py): `process_incoming.py`

### AI Services

- **Ollama**

### Other components

- **Learner**
- **Course Videos**
- **Audio Files**
- **Transcript Chunks**
- [Prompt Output](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/prompt.txt): `prompt.txt`
- [Response Output](https://github.com/gayatripachpande99/rag-based-ai-teaching-assistant/blob/main/response.txt): `response.txt`

## Connections

- Course Videos → Video Converter: converts
- Video Converter → Audio Files: writes audio
- Audio Files → Transcriber: transcribes
- Transcriber → Transcript Chunks: writes chunks
- Transcript Chunks → Index Builder: reads chunks
- Index Builder → Ollama: requests embeddings
- Index Builder → Embedding Index: writes index
- Learner → Chat Client: asks question
- Web Chat UI → Chat Client: hosts chat
- Chat Client → Flask Assistant: posts query
- Flask Assistant → Embedding Index: loads and searches
- Flask Assistant → Ollama: embeds and generates
- Flask Assistant → Chat Client: returns answer
- Learner → Streamlit Assistant: asks question
- Streamlit Assistant → Embedding Index: loads and searches
- Streamlit Assistant → Ollama: embeds and generates
- Learner → CLI Assistant: asks question
- CLI Assistant → Embedding Index: loads and searches
- CLI Assistant → Ollama: embeds and generates
- CLI Assistant → Prompt Output: writes prompt
- CLI Assistant → Response Output: writes response
