How juaakash123/lesson-plan-creator-using-rag works
This is a temporary PDF question-answering chatbot that generates lesson plans from uploaded documents. A user uploads a PDF through the web/API layer; the server processes it into retrieval indexes and stores a conversational chain by session. Chat requests stream answers from that chain, while session listing and deletion provide basic lifecycle controls. The RAG implementation separates document preparation, hybrid retrieval and reranking, and answer generation. The source shows these stages in one module; relationships to external model services are based on configuration, not inspected service behavior.
Main entry points: main.py FastAPI endpoints · rag_engine.py BM25 and vector indexes · index.html Web UI · dependencies.py Hugging Face embeddings
Components 19
Web and API
- Web UI
app/static/index.html - FastAPI endpoints
app/main.py - Request and response schemas
app/model.py - Uploaded PDF
- Streamed answer
Document RAG
- PDF loading and chunking
app/rag_engine.py - BM25 and vector indexes
app/rag_engine.py - Hybrid retrieval and reranking
app/rag_engine.py - Lesson-plan prompt and chain
app/rag_engine.py - Conversational RAG chain
app/rag_engine.py
Models and sessions
- Chroma vector store
app/rag_engine.py - Active session registry
app/dependencies.py - Chat history store
app/rag_engine.py - Hugging Face embeddings
app/dependencies.py - Gemini language model
app/dependencies.py - FlashRank reranker
app/rag_engine.py
External services
- Embedding model service
- Google Gemini service
Other components
- User
Connections 20
- User → Web UI: uses
- User → FastAPI endpoints: requests
app/main.py - Web UI → FastAPI endpoints: serves through
app/main.py - FastAPI endpoints → Request and response schemas: validates with
app/main.py - FastAPI endpoints → Uploaded PDF: receives
app/main.py - FastAPI endpoints → PDF loading and chunking: calls
app/main.py - PDF loading and chunking → BM25 and vector indexes: splits into
app/rag_engine.py - BM25 and vector indexes → Hugging Face embeddings: embeds chunks
app/rag_engine.py - BM25 and vector indexes → Chroma vector store: writes vectors
app/rag_engine.py - BM25 and vector indexes → Hybrid retrieval and reranking: provides indexes
app/rag_engine.py - Hybrid retrieval and reranking → FlashRank reranker: reranks results
app/rag_engine.py - Hybrid retrieval and reranking → Lesson-plan prompt and chain: supplies context
app/rag_engine.py - Lesson-plan prompt and chain → Gemini language model: generates answer
app/rag_engine.py - Hugging Face embeddings → Embedding model service: calls
app/dependencies.py - Gemini language model → Google Gemini service: calls
app/dependencies.py - FastAPI endpoints → Active session registry: checks and updates
app/main.py - FastAPI endpoints → Conversational RAG chain: streams from
app/main.py - Conversational RAG chain → Chat history store: loads and saves
app/rag_engine.py - Conversational RAG chain → Streamed answer: yields
- Streamed answer → User: streams to