# munazz-a/edutube---study-assistant architecture

> Architecture diagram of the GitHub repository munazz-a/edutube---study-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/munazz-a/edutube---study-assistant
- Repository: https://github.com/munazz-a/edutube---study-assistant

## Overview

#### Purpose and Entry Points
EduTube is a study assistant that answers questions over educational-video transcripts through retrieval-augmented generation (RAG). It has three deployable layers:
- Browser UI: `Frontend/home.html`, `Frontend/summary.html`
- Node.js API-facing server: `Backend/Server.js`
- Python/FastAPI AI service: `AI-Services/chatbot/app.py`

#### Frontend Interaction Layer
The static frontend provides the user flow for entering a video/transcript-related request and viewing summaries or question-answer results. Client behavior is implemented separately for each page:
- `Frontend/home.js`
- `Frontend/summary.js`
- `Frontend/home.html`

This layer should treat the Node server as its application boundary; it should not directly own embedding, retrieval, or model-provider concerns.

#### Node.js Request Gateway
`Backend/Server.js` is the JavaScript server entry point, with its runtime dependencies defined in `Backend/package.json`. Per the stated design, it handles API requests and bridges browser traffic to the AI-processing service.

This is the likely cross-runtime boundary: JavaScript/Express manages HTTP-facing application routing, while Python owns RAG computation. Any API contract changes must be coordinated across `Frontend/*.js`, `Backend/Server.js`, and FastAPI routes.

#### FastAPI AI Service
`AI-Services/chatbot/app.py` is the Python service entry point and HTTP boundary for AI operations. It composes the chatbot/RAG modules:
- `AI-Services/chatbot/chatbot.py`
- `AI-Services/chatbot/rag.py`
- `AI-Services/chatbot/requirements.txt`

FastAPI enables concurrent service requests; the application should avoid mutable per-request retrieval/chat state leaking across users.

#### RAG Retrieval Pipeline
The core answer path is organized around transcript chunk retrieval:
1. Transcript content is split into chunks.
2. Chunks are encoded into vector embeddings.
3. FAISS indexes the vectors for semantic nearest-neighbor lookup.
4. A user question is embedded and matched against relevant transcript chunks.
5. Retrieved context is passed to answer generation.

The embedding and retrieval responsibilities are grounded in:
- `AI-Services/chatbot/embeddings.py`
- `AI-Services/chatbot/rag.py`
- `AI-Services/chatbot/chatbot.py`

#### Model and External-Service Boundary
Semantic embeddings use the Sentence Transformers `all-MiniLM-L6-v2` model; vector search uses FAISS; final natural-language generation uses the OpenAI API. The OpenAI key is supplied through `OPENAI_API_KEY`, making OpenAI an external dependency and a security boundary.

Python dependencies and model libraries belong to `AI-Services/chatbot/requirements.txt`; Node runtime dependencies belong to `Backend/package.json`. The repository root `package.json` may support root-level JavaScript orchestration, but the server-specific runtime is under `Backend/`.

#### End-to-End Control Flow
A browser action from `Frontend/home.js` or `Frontend/summary.js` reaches the Node server in `Backend/Server.js`. That server forwards or coordinates the request with FastAPI in `AI-Services/chatbot/app.py`. FastAPI invokes embedding/retrieval modules, obtains FAISS-selected transcript context, calls OpenAI for a grounded answer, and returns the result back through Node to the frontend. The key quality boundary is retrieval context: generation accuracy depends on correctly chunked and indexed transcript material rather than on frontend or gateway logic.

Main entry points: [`Backend/Server.js`](https://github.com/munazz-a/edutube---study-assistant/blob/main/Backend/Server.js) (Node API server), [`AI-Services/chatbot/app.py`](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/app.py) (FastAPI service), [`AI-Services/chatbot/chatbot.py`](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/chatbot.py) (Answer orchestration), [`AI-Services/chatbot/rag.py`](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/rag.py) (Transcript retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser UI"]
  node_home["Home page<br/>static page<br/>[home.html]"]
  node_summary["Summary page<br/>static page<br/>[summary.html]"]
  node_home_client["Home client<br/>browser script<br/>[home.js]"]
  node_summary_client["Summary client<br/>browser script<br/>[summary.js]"]
end

subgraph group_gateway["Application Gateway"]
  node_node_server{{"Node API server<br/>Express gateway<br/>[Server.js]"}}
  node_node_dependencies["Node dependencies<br/>runtime manifest<br/>[package.json]"]
end

subgraph group_ai["AI Service"]
  node_fastapi{{"FastAPI service<br/>AI HTTP API<br/>[app.py]"}}
  node_chatbot["Answer orchestration<br/>RAG coordinator<br/>[chatbot.py]"]
  node_python_dependencies["Python dependencies<br/>runtime manifest<br/>[requirements.txt]"]
end

subgraph group_rag["RAG Pipeline"]
  node_rag["Transcript retrieval<br/>RAG pipeline<br/>[rag.py]"]
  node_embeddings["Embedding encoder<br/>Sentence Transformers<br/>[embeddings.py]"]
  node_faiss[("FAISS index<br/>vector search")]
end

node_openai{{"OpenAI API<br/>external model API"}}

node_home -->|"loads"| node_home_client
node_summary -->|"loads"| node_summary_client
node_home_client -->|"API request"| node_node_server
node_summary_client -->|"API request"| node_node_server
node_node_dependencies -.->|"provides runtime"| node_node_server
node_node_server -->|"forwards AI request"| node_fastapi
node_fastapi -->|"invokes"| node_chatbot
node_python_dependencies -.->|"provides runtime"| node_fastapi
node_chatbot -->|"requests context"| node_rag
node_rag -->|"encodes chunks and question"| node_embeddings
node_embeddings -->|"indexes and queries vectors"| node_faiss
node_faiss -->|"relevant chunks"| node_rag
node_rag -->|"retrieved context"| node_chatbot
node_chatbot -->|"grounded generation"| node_openai
node_openai -->|"answer result"| node_fastapi
node_fastapi -->|"AI response"| node_node_server
node_node_server -->|"result"| node_home_client
node_node_server -->|"result"| node_summary_client

click node_home "https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/home.html"
click node_summary "https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/summary.html"
click node_home_client "https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/home.js"
click node_summary_client "https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/summary.js"
click node_node_server "https://github.com/munazz-a/edutube---study-assistant/blob/main/Backend/Server.js"
click node_node_dependencies "https://github.com/munazz-a/edutube---study-assistant/blob/main/Backend/package.json"
click node_fastapi "https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/app.py"
click node_chatbot "https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/chatbot.py"
click node_rag "https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/rag.py"
click node_embeddings "https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/embeddings.py"
click node_python_dependencies "https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/requirements.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_home,node_summary,node_home_client,node_summary_client toneBlue
class node_node_server,node_node_dependencies toneAmber
class node_fastapi,node_chatbot,node_python_dependencies toneMint
class node_rag,node_embeddings,node_faiss toneRose
class node_openai toneNeutral
```

## Components

### Browser UI

- [Home page](https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/home.html): static page · `Frontend/home.html`
- [Summary page](https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/summary.html): static page · `Frontend/summary.html`
- [Home client](https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/home.js): browser script · `Frontend/home.js`
- [Summary client](https://github.com/munazz-a/edutube---study-assistant/blob/main/Frontend/summary.js): browser script · `Frontend/summary.js`

### Application Gateway

- [Node API server](https://github.com/munazz-a/edutube---study-assistant/blob/main/Backend/Server.js): Express gateway · Routes browser API requests to the Python service. · `Backend/Server.js`
- [Node dependencies](https://github.com/munazz-a/edutube---study-assistant/blob/main/Backend/package.json): runtime manifest · `Backend/package.json`

### AI Service

- [FastAPI service](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/app.py): AI HTTP API · Owns concurrent AI request handling. · `AI-Services/chatbot/app.py`
- [Answer orchestration](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/chatbot.py): RAG coordinator · Builds grounded prompts and produces answers. · `AI-Services/chatbot/chatbot.py`
- [Python dependencies](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/requirements.txt): runtime manifest · `AI-Services/chatbot/requirements.txt`

### RAG Pipeline

- [Transcript retrieval](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/rag.py): RAG pipeline · Chunks transcripts and retrieves relevant context. · `AI-Services/chatbot/rag.py`
- [Embedding encoder](https://github.com/munazz-a/edutube---study-assistant/blob/main/AI-Services/chatbot/embeddings.py): Sentence Transformers · Uses all-MiniLM-L6-v2 for transcript and question vectors. · `AI-Services/chatbot/embeddings.py`
- **FAISS index**: vector search · Finds nearest transcript chunks.

### Other components

- **OpenAI API**: external model API · Generation is authenticated with OPENAI_API_KEY.

## Connections

- Home page → Home client: loads
- Summary page → Summary client: loads
- Home client → Node API server: API request
- Summary client → Node API server: API request
- Node dependencies → Node API server: provides runtime
- Node API server → FastAPI service: forwards AI request
- FastAPI service → Answer orchestration: invokes
- Python dependencies → FastAPI service: provides runtime
- Answer orchestration → Transcript retrieval: requests context
- Transcript retrieval → Embedding encoder: encodes chunks and question
- Embedding encoder → FAISS index: indexes and queries vectors
- FAISS index → Transcript retrieval: relevant chunks
- Transcript retrieval → Answer orchestration: retrieved context
- Answer orchestration → OpenAI API: grounded generation
- OpenAI API → FastAPI service: answer result
- FastAPI service → Node API server: AI response
- Node API server → Home client: result
- Node API server → Summary client: result
