Course
RAG and Vector Databases
130 lessons across 17 modules
From why RAG exists to production systems: embeddings, vector databases, chunking, your first RAG app, frameworks, retrieval optimization, evaluation, security, scaling and deployment - plus four projects. Each lesson explains one idea in simple steps, with code you can run and the real output.
RAG Fundamentals
Why RAG exists, before writing real systems
What is Generative AI?
1.1Generative AI creates new content - text, images, code - instead of looking something up. Run llama3 on your own laptop, ask for the same slogan six times, and see why it can write anything: including a confident, invented phone number for a bakery that does not exist.
What is a Large Language Model (LLM)?
1.2An LLM predicts the next piece of text, again and again. Watch llama3 choose " Paris" with 64% probability, count tokens (Telugu cost five times more than English), read the model’s size and limits, and see a long prompt silently cut to a third - the fact in the middle was lost.
What is Retrieval-Augmented Generation (RAG)?
1.3RAG = find the right documents, put them in the prompt, then let the model answer. Build a working RAG app in 40 lines for a bakery: without it llama3 rambled; with it, correct answers with sources. Then watch the two ways it fails - too strict, then inventing a gift card - and the small fix in code.
Problems with LLM knowledge and hallucinations
1.4Why models invent facts, and how often
Ten bakery questions, counted right and wrong
RAG vs. fine-tuning
1.5Teach the model vs give it the documents
When each one is the right choice
RAG architecture and end-to-end workflow
1.6Ingestion pipeline and query pipeline
The full path of one question
Use cases and limitations of RAG
1.7Where RAG shines and where it struggles
Support bot, policy search, code docs
Embeddings and Semantic Search
How documents and questions become searchable vectors
What are vector embeddings?
2.1Text as a list of numbers that captures meaning
"refund" and "return" close together
Tokens and text preprocessing
2.2Cleaning text before embedding
Whitespace, case and HTML leftovers
How embedding models work
2.3Encoder models vs chat models
Why llama3 could not embed
Generating embeddings using an API
2.4Local and hosted embedding models
Embed the bakery documents
Vector dimensions and similarity
2.5What 768 or 1536 dimensions mean
Comparing two sentences
Cosine similarity, dot product, and Euclidean distance
2.6Three ways to measure "close"
The same vectors, three scores
Semantic search vs. keyword search
2.7Meaning vs exact words
Where Lesson 1.3’s word search failed
Vector Database Fundamentals
Storing and searching millions of vectors
What is a vector database?
3.1A database built for nearest-neighbour search
From a Python list to a database
Vector database vs. relational database
3.2Similarity search vs exact queries
The same data in both
Collections, records, vectors, and metadata
3.3The parts of a vector record
A record for one document chunk
Inserting and retrieving vectors
3.4Upsert and top-k queries
Insert 100 chunks, find the best 3
Metadata filtering
3.5Similarity plus exact conditions
Only documents from 2026
Indexing and approximate nearest-neighbor search
3.6Trading a little accuracy for a lot of speed
Exact vs approximate on 100,000 vectors
Measuring vector search quality
3.7Recall@k and latency
Is the right chunk in the top 5?
Choosing and Implementing a Vector Database
Five popular options, used hands-on and compared
PostgreSQL with pgvector
4.1Vectors inside the database you already use
A vector column and an index
Chroma
4.2A simple embedded vector store
Local collection in a few lines
FAISS
4.3A fast vector search library
Search one million vectors in memory
Qdrant
4.4A dedicated vector database server
Collections with payload filters
Pinecone
4.5A fully managed hosted service
Serverless index setup
Comparing deployment, cost, scalability, and features
4.6The trade-offs side by side
One table, five databases
Selecting a database for a real project
4.7A decision checklist
Three projects, three choices
Document Ingestion and Chunking
Turning real documents into searchable pieces
Supported document types: TXT, Markdown, PDF, DOCX, and HTML
5.1What each format hides
One policy in five formats
Extracting text from documents
5.2Libraries and their pitfalls
Tables and headers in a PDF
Why document chunking is necessary
5.3Context limits and precise retrieval
A 40-page PDF as one chunk
Fixed-size chunking
5.4Split every N characters or tokens
Sentences cut in half
Recursive character chunking
5.5Split on paragraphs, then sentences
Cleaner chunks from the same text
Chunk overlap and context preservation
5.6Repeat a little text between chunks
An answer that spans two chunks
Metadata design and document IDs
5.7Source, page, section, version
Citations that point to a page
Updating and deleting indexed documents
5.8Keep the index in sync with the files
A policy changes - old chunks must go
Build Your First RAG Application
From documents to cited answers, step by step
Setting up the Python environment
6.1Virtual environment, packages, configuration
A clean project layout
Connecting to an LLM API
6.2Local and hosted models behind one function
llama3 now, a hosted model later
Generating document embeddings
6.3Embed every chunk once
Embedding the bakery handbook
Storing embeddings in a vector database
6.4Records with vectors and metadata
Load the chunks into pgvector
Converting user questions into embeddings
6.5Same model for questions and documents
What happens if the models differ
Retrieving relevant document chunks
6.6Top-k search with scores
The best 3 chunks for a question
Constructing the prompt with retrieved context
6.7Instructions, context, question
A prompt template that works
Generating answers grounded in documents
6.8Answer only from the context
Checking faithfulness by hand
Returning source citations
6.9File, page and chunk in every answer
Clickable sources
Handling questions with no relevant results
6.10Thresholds and honest fallbacks
The gift card question, done properly
RAG Frameworks
LangChain and LlamaIndex - and when to skip them
Building RAG without a framework
7.1Everything in plain Python
The Module 6 app, reviewed
Introduction to LangChain
7.2Building blocks for LLM apps
The same app in LangChain
LangChain document loaders and text splitters
7.3Loading and chunking with ready-made parts
PDFs and Markdown in a few lines
LangChain retrievers and vector stores
7.4One interface for many databases
Swap Chroma for pgvector
Building a RAG chain
7.5Retriever, prompt, model, parser
A chain with sources
Introduction to LlamaIndex
7.6A data framework for LLM apps
Index a folder of documents
Indexes, query engines, and retrievers
7.7LlamaIndex’s main parts
A query engine with citations
Choosing between custom code, LangChain, and LlamaIndex
7.8Control vs speed of building
One feature, three ways
Retrieval Optimization
Finding the right chunks more often
Top-k retrieval
8.1How many chunks to send
k = 1, 3 and 10 compared
Similarity thresholds
8.2Drop weak matches
Choosing the cut-off from data
Metadata-based filtering
8.3Narrow the search before ranking
Only the user’s department
Hybrid search: keyword plus vector search
8.4Combine exact words and meaning
Product codes and natural questions
Reranking retrieved documents
8.5A second, more careful ranking
A cross-encoder reorders the top 20
Query rewriting and expansion
8.6Improve the question before searching
Short, vague questions made clear
Multi-query retrieval
8.7Several versions of one question
Merging their results
Context compression and deduplication
8.8Send less, but the right part
Remove repeated chunks
Advanced RAG Patterns
Patterns for harder questions and bigger collections
Parent-child chunk retrieval
9.1Search small, answer with the bigger section
Precise match, full context
Multi-query RAG
9.2Answer from several searches
A question with two parts
Multi-document RAG
9.3Combine and compare across documents
Old policy vs new policy
Query routing
9.4Send each question to the right source
HR docs, IT docs or the database
Contextual retrieval
9.5Add document context to each chunk
Chunks that know where they came from
Graph RAG fundamentals
9.6Entities and relationships as a graph
Who reports to whom
Agentic RAG
9.7An agent decides when and what to retrieve
A LangGraph agent with a search tool
Choosing the right RAG architecture
9.8From simple to agentic
Match the pattern to the problem
Build APIs and Integrate the Frontend
A RAG service other apps can use
RAG service architecture
10.1Ingestion, query and storage services
The parts of a production RAG service
Creating FastAPI endpoints
10.2Endpoints for documents and questions
/documents and /ask
Uploading documents through an API
10.3File uploads and validation
Upload a PDF, get a document ID
Implementing background document processing
10.4Ingest without blocking the request
Status: queued, processing, ready
Creating a question-answering endpoint
10.5Answer, sources and timing
A JSON response with citations
Streaming LLM responses
10.6Words appear as they are generated
Server-Sent Events to the browser
Connecting a React frontend
10.7A chat screen for the RAG API
Upload, ask, see sources
Integrating RAG with Node.js and TypeScript
10.8Calling the Python service from Node
A typed client for /ask
Evaluation and Testing
Measuring quality instead of guessing
Why RAG evaluation matters
11.1Answers that look right but are not
Two pipelines, same demo, different quality
Creating a test dataset
11.2Questions with known answers and sources
30 questions for the bakery
Measuring retrieval precision and recall
11.3Did we find the right chunks?
Recall@3 for every question
Measuring answer relevance and faithfulness
11.4Does the answer stick to the sources?
Catching invented details
Evaluating context relevance
11.5Was the retrieved text useful?
Noise in the context
Comparing chunk sizes and retrieval strategies
11.6Experiments with numbers
200 vs 500 vs 1000 tokens
Automated RAG evaluation
11.7LLM-as-judge and evaluation tools
An evaluation run in CI
Regression testing after pipeline changes
11.8Never get worse without knowing
A failing test after a new chunker
Security and Production Readiness
Keeping data, users and the system safe
Protecting API keys and secrets
12.1Keys out of code and logs
Environment variables and a secret store
Authentication and authorization
12.2Who is asking, and what may they see
JWT on the /ask endpoint
Tenant isolation in multi-tenant RAG
12.3One company never sees another’s data
tenant_id in every query
Document-level access control
12.4Filter by permission at retrieval
HR documents only for HR
Prompt injection through retrieved documents
12.5Documents that give the model orders
A poisoned PDF
PII handling and data privacy
12.6Personal data in documents and logs
Masking phone numbers before indexing
Rate limits, retries, and timeouts
12.7Survive slow and failing services
An embedding API that times out
Logging, tracing, and error handling
12.8Know what happened for every answer
A trace from question to citation
Scaling Vector Databases
From thousands to millions of vectors
Vector indexing strategies
13.1Flat, graph and cluster indexes
When each one fits
HNSW and IVF indexes
13.2The two most common ANN indexes
Tuning recall vs speed
Batch embedding and ingestion
13.3Embed and insert in batches
100,000 chunks in minutes, not hours
Caching embeddings and query results
13.4Never pay twice for the same work
A cache for repeated questions
Database partitioning and sharding concepts
13.5Split data across machines
Partition by tenant
Replication, availability, and backups
13.6Survive a failed server
Restore an index from backup
Latency, throughput, and cost optimization
13.7The three numbers that matter
Measuring p95 latency
Scaling ingestion and retrieval independently
13.8Separate the write and read paths
Big uploads without slow answers
Observability and Cost Optimization
Seeing what the system does, and what it costs
Tracking LLM token usage
14.1Tokens in and out per request
Cost per answer
Estimating embedding costs
14.2Ingestion cost before you start
10,000 documents, priced
Monitoring retrieval latency
14.3Where the milliseconds go
Embedding, search, generation
Tracing the complete RAG pipeline
14.4One trace per question
Retrieval and generation in one view
Detecting retrieval failures and poor answers
14.5Signals that something is wrong
Low scores and "I don’t know" rates
Caching and model selection
14.6Cheaper models where they are enough
A small model for easy questions
Production dashboards and alerts
14.7The numbers to watch daily
An alert when quality drops
Deployment and Cloud Infrastructure
Running RAG in production
Containerizing a RAG application with Docker
15.1One image for the API, one for workers
docker compose up
Running PostgreSQL and pgvector
15.2A production database with vectors
Settings, extensions, backups
Deploying FastAPI
15.3Workers, health checks, configuration
Zero-downtime deploys
Managing document storage
15.4Files in object storage
S3 for uploads
Background workers and queues
15.5Ingestion jobs that retry
A queue for document processing
CI/CD for RAG applications
15.6Tests and evaluations in the pipeline
Block a release that lowers quality
Deploying on AWS
15.7The services a RAG app needs
ECS, RDS and S3
AWS Bedrock integration
15.8Hosted models and knowledge bases on AWS
Swap the local model for Bedrock
Production deployment checklist
15.9Everything to check before launch
A go-live review
Interview Preparation and System Design
Explaining and designing RAG systems
Explain RAG end to end
16.1A clear two-minute explanation
From upload to cited answer
Explain embeddings and vector similarity
16.2Simple words for a deep idea
With one drawing
Choose a vector database for a workload
16.3Reasoning about the trade-offs
Three interview scenarios
Troubleshoot poor retrieval quality
16.4A step-by-step diagnosis
"The bot gives wrong answers"
Design RAG for millions of documents
16.5Ingestion, indexing and query at scale
A system design walkthrough
Design a multi-tenant enterprise RAG platform
16.6Isolation, permissions and cost
An enterprise design review
RAG system design interview questions
16.7Common questions and strong answers
Mock interview
Project presentation and architecture review
16.8Presenting your own RAG project
A ten-minute architecture talk
Practical Projects
Four projects, from a beginner chatbot to a production agentic RAG system
Project 1: Document Q&A chatbot
17.1Beginner - after Module 6: upload documents, ask questions, answers with sources
Python, FastAPI, embeddings, Chroma or FAISS
Project 2: Enterprise knowledge assistant
17.2Intermediate - metadata filters, hybrid search, reranking, document updates
FastAPI, PostgreSQL with pgvector, React, background workers
Project 3: Multi-tenant RAG platform
17.3Advanced - authentication, tenant isolation, access control, usage tracking, evaluation
React, Node.js/TypeScript, FastAPI, PostgreSQL/pgvector
Project 4: Production-ready agentic RAG
17.4Capstone - retrieves knowledge, selects tools, calls APIs, evaluates itself, traceable answers
Python, LangGraph, vector database, LLM API, Docker, AWS