# the-full-stack/ask-fsdl architecture

> Architecture diagram of the GitHub repository the-full-stack/ask-fsdl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/the-full-stack/ask-fsdl
- Repository: https://github.com/the-full-stack/ask-fsdl

## Overview

#### Purpose and Entry Points
askFSDL is a retrieval-augmented Q&A system over Full Stack Deep Learning educational content and an LLM literature review. It exposes two user-facing frontends: a Gradio application in `app.py` and a Discord interactions bot in `bot.py`. Both invoke a shared retrieval-and-generation backend pattern.

#### Query Orchestration and Prompting
`app.py` and `bot.py` accept user questions, retrieve relevant corpus passages, assemble an LLM prompt, and return an answer. Prompt templates and response instructions are centralized in `prompts.py`; shared application utilities are in `utils.py`. LangChain organizes LLM invocation and prompt composition.

#### Persistent Document Corpus
Cleaned, structured source documents are persisted in MongoDB Atlas through `docstore.py`. MongoDB is the durable corpus boundary: ETL writes normalized records there, while retrieval/index-refresh processes read from it. Setup guidance and service-specific provisioning live under `setup/mongodb` and `setup/SETUP.md`.

#### Vector Retrieval Layer
`vecstore.py` manages the FAISS vector index used for fast semantic retrieval. This is the low-latency search boundary between a user query and the document corpus: query embeddings are matched against indexed document chunks, then selected context is supplied to the LLM. The vector index is refreshed as corpus ETL changes.

#### Corpus ETL Pipeline
The ETL modules extract and normalize distinct source formats: Markdown in `etl/markdown.py`, PDFs in `etl/pdfs.py`, and video-derived content in `etl/videos.py`. Shared chunking, metadata, and persistence behavior belongs in `etl/shared.py`. The notebook `Running ETL to Build the Document Corpus.ipynb` documents execution of the broader corpus-build workflow.

#### Source Data and Batch Execution
Repository data inputs include course lectures, videos, and paper metadata under `data/lectures-2022.json`, `data/videos.json`, and `data/llm-papers.json`. Batch ETL is launched via `tasks/run_etl.sh`; it writes corpus records and supports rebuilding the FAISS search materialization rather than serving requests directly.

#### Runtime, Deployment, and External Services
Python is the primary runtime, with dependencies declared in `pyproject.toml` and `requirements.txt`. Modal provides serverless hosting for the backend, Discord bot, and batch work; deployment scripts include `tasks/run_backend_modal.sh` and `tasks/run_frontend_modal.sh`. OpenAI provides model/API calls, MongoDB Atlas stores documents, FAISS provides local/vector similarity search, Discord provides the bot interaction endpoint, Gradio provides the lightweight UI, and Gantry monitors production model behavior and user feedback.

Main entry points: [`tasks/run_etl.sh`](https://github.com/the-full-stack/ask-fsdl/blob/main/tasks/run_etl.sh) (ETL batch launcher), [`etl/shared.py`](https://github.com/the-full-stack/ask-fsdl/blob/main/etl/shared.py) (Normalization and chunking), [`bot.py`](https://github.com/the-full-stack/ask-fsdl/blob/main/bot.py) (Discord bot), [`etl/markdown.py`](https://github.com/the-full-stack/ask-fsdl/blob/main/etl/markdown.py) (Markdown ETL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_gradio["Gradio app<br/>frontend<br/>[app.py]"]
  node_discord_bot["Discord bot<br/>[bot.py]"]
end

subgraph group_rag["Retrieval and generation"]
  node_rag_flow{{"RAG orchestration<br/>query pipeline"}}
  node_prompts["Prompt templates<br/>prompt definitions<br/>[prompts.py]"]
  node_utils["Shared utilities<br/>application utilities<br/>[utils.py]"]
  node_langchain["LangChain<br/>LLM orchestration"]
  node_faiss[("FAISS index<br/>vector store<br/>[vecstore.py]")]
end

subgraph group_corpus["Corpus build pipeline"]
  node_batch["ETL batch launcher<br/>shell task<br/>[run_etl.sh]"]
  node_lecture_data["Lecture data<br/>source dataset<br/>[lectures-2022.json]"]
  node_video_data["Video data<br/>source dataset<br/>[videos.json]"]
  node_paper_data["Paper metadata<br/>source dataset<br/>[llm-papers.json]"]
  node_markdown_etl["Markdown ETL<br/>extractor<br/>[markdown.py]"]
  node_pdf_etl["PDF ETL<br/>extractor<br/>[pdfs.py]"]
  node_video_etl["Video ETL<br/>extractor<br/>[videos.py]"]
  node_etl_shared["Normalization and chunking<br/>ETL shared layer<br/>[shared.py]"]
end

subgraph group_services["External services"]
  node_discord["Discord<br/>interaction platform"]
  node_openai["OpenAI<br/>LLM API"]
  node_gantry["Gantry<br/>model monitoring"]
  node_mongodb[("MongoDB Atlas<br/>document corpus<br/>[docstore.py]")]
  node_modal["Modal<br/>serverless runtime"]
end

node_discord -->|"delivers interactions"| node_discord_bot
node_gradio -->|"questions"| node_rag_flow
node_discord_bot -->|"questions"| node_rag_flow
node_utils -->|"supports"| node_rag_flow
node_prompts -->|"instructions"| node_rag_flow
node_rag_flow -->|"composes invocation"| node_langchain
node_rag_flow -->|"retrieves context"| node_faiss
node_langchain -->|"model calls"| node_openai
node_rag_flow -.->|"telemetry and feedback"| node_gantry
node_lecture_data -->|"course content"| node_markdown_etl
node_paper_data -->|"paper sources"| node_pdf_etl
node_video_data -->|"video sources"| node_video_etl
node_markdown_etl -->|"normalized content"| node_etl_shared
node_pdf_etl -->|"normalized content"| node_etl_shared
node_video_etl -->|"normalized content"| node_etl_shared
node_etl_shared -->|"persists records"| node_mongodb
node_batch -->|"runs"| node_markdown_etl
node_batch -->|"runs"| node_pdf_etl
node_batch -->|"runs"| node_video_etl
node_mongodb -->|"corpus refresh"| node_faiss
node_modal -.->|"hosts"| node_gradio
node_modal -.->|"hosts"| node_discord_bot
node_modal -.->|"runs batch work"| node_batch

click node_gradio "https://github.com/the-full-stack/ask-fsdl/blob/main/app.py"
click node_discord_bot "https://github.com/the-full-stack/ask-fsdl/blob/main/bot.py"
click node_prompts "https://github.com/the-full-stack/ask-fsdl/blob/main/prompts.py"
click node_utils "https://github.com/the-full-stack/ask-fsdl/blob/main/utils.py"
click node_faiss "https://github.com/the-full-stack/ask-fsdl/blob/main/vecstore.py"
click node_batch "https://github.com/the-full-stack/ask-fsdl/blob/main/tasks/run_etl.sh"
click node_lecture_data "https://github.com/the-full-stack/ask-fsdl/blob/main/data/lectures-2022.json"
click node_video_data "https://github.com/the-full-stack/ask-fsdl/blob/main/data/videos.json"
click node_paper_data "https://github.com/the-full-stack/ask-fsdl/blob/main/data/llm-papers.json"
click node_markdown_etl "https://github.com/the-full-stack/ask-fsdl/blob/main/etl/markdown.py"
click node_pdf_etl "https://github.com/the-full-stack/ask-fsdl/blob/main/etl/pdfs.py"
click node_video_etl "https://github.com/the-full-stack/ask-fsdl/blob/main/etl/videos.py"
click node_etl_shared "https://github.com/the-full-stack/ask-fsdl/blob/main/etl/shared.py"
click node_mongodb "https://github.com/the-full-stack/ask-fsdl/blob/main/docstore.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_gradio,node_discord_bot toneBlue
class node_rag_flow,node_prompts,node_utils,node_langchain,node_faiss toneAmber
class node_batch,node_lecture_data,node_video_data,node_paper_data,node_markdown_etl,node_pdf_etl,node_video_etl,node_etl_shared toneMint
class node_discord,node_openai,node_gantry,node_mongodb,node_modal toneRose
```

## Components

### User interfaces

- [Gradio app](https://github.com/the-full-stack/ask-fsdl/blob/main/app.py): frontend · `app.py`
- [Discord bot](https://github.com/the-full-stack/ask-fsdl/blob/main/bot.py): bot · `bot.py`

### Retrieval and generation

- **RAG orchestration**: query pipeline · Retrieves context, builds a prompt, and returns answers.
- [Prompt templates](https://github.com/the-full-stack/ask-fsdl/blob/main/prompts.py): prompt definitions · `prompts.py`
- [Shared utilities](https://github.com/the-full-stack/ask-fsdl/blob/main/utils.py): application utilities · `utils.py`
- **LangChain**: LLM orchestration
- [FAISS index](https://github.com/the-full-stack/ask-fsdl/blob/main/vecstore.py): vector store · Low-latency semantic search over indexed document chunks. · `vecstore.py`

### Corpus build pipeline

- [ETL batch launcher](https://github.com/the-full-stack/ask-fsdl/blob/main/tasks/run_etl.sh): shell task · `tasks/run_etl.sh`
- [Lecture data](https://github.com/the-full-stack/ask-fsdl/blob/main/data/lectures-2022.json): source dataset · `data/lectures-2022.json`
- [Video data](https://github.com/the-full-stack/ask-fsdl/blob/main/data/videos.json): source dataset · `data/videos.json`
- [Paper metadata](https://github.com/the-full-stack/ask-fsdl/blob/main/data/llm-papers.json): source dataset · `data/llm-papers.json`
- [Markdown ETL](https://github.com/the-full-stack/ask-fsdl/blob/main/etl/markdown.py): extractor · `etl/markdown.py`
- [PDF ETL](https://github.com/the-full-stack/ask-fsdl/blob/main/etl/pdfs.py): extractor · `etl/pdfs.py`
- [Video ETL](https://github.com/the-full-stack/ask-fsdl/blob/main/etl/videos.py): extractor · `etl/videos.py`
- [Normalization and chunking](https://github.com/the-full-stack/ask-fsdl/blob/main/etl/shared.py): ETL shared layer · Applies shared metadata, chunking, and persistence behavior. · `etl/shared.py`

### External services

- **Discord**: interaction platform
- **OpenAI**: LLM API
- **Gantry**: model monitoring · Monitors production behavior and user feedback.
- [MongoDB Atlas](https://github.com/the-full-stack/ask-fsdl/blob/main/docstore.py): document corpus · Durable store for cleaned, structured source documents. · `docstore.py`
- **Modal**: serverless runtime · Hosts application, bot, and batch workloads.

## Connections

- Discord → Discord bot: delivers interactions
- Gradio app → RAG orchestration: questions
- Discord bot → RAG orchestration: questions
- Shared utilities → RAG orchestration: supports
- Prompt templates → RAG orchestration: instructions
- RAG orchestration → LangChain: composes invocation
- RAG orchestration → FAISS index: retrieves context
- LangChain → OpenAI: model calls
- RAG orchestration → Gantry: telemetry and feedback
- Lecture data → Markdown ETL: course content
- Paper metadata → PDF ETL: paper sources
- Video data → Video ETL: video sources
- Markdown ETL → Normalization and chunking: normalized content
- PDF ETL → Normalization and chunking: normalized content
- Video ETL → Normalization and chunking: normalized content
- Normalization and chunking → MongoDB Atlas: persists records
- ETL batch launcher → Markdown ETL: runs
- ETL batch launcher → PDF ETL: runs
- ETL batch launcher → Video ETL: runs
- MongoDB Atlas → FAISS index: corpus refresh
- Modal → Gradio app: hosts
- Modal → Discord bot: hosts
- Modal → ETL batch launcher: runs batch work
