Skip to content

Build one RAG system from first principles

I built this Course for developers who know basic Python, terminal commands, and how APIs work. You do not need experience with machine learning, SQL, Docker, embeddings, or vector databases.

I follow one question-answering application throughout the Course instead of starting a new example in every lesson. You can read the chapters without cloning or running a separate exercise. The code is shown directly where each concept is explained.

Some lesson titles below may be new to you. That is expected. Each lesson explains the concept before asking you to use it.

Main Path

Foundations

  1. RAG is more than a vector database
  2. Meet the example Sources
  3. Discover Sources with glob
  4. Search and read Sources with ripgrep
  5. See how coding agents retrieve context
  6. See the complete learning path

Build the retrieval pipeline

  1. Model and ingest Sources
  2. Parse and normalize Sources
  3. Chunk without losing context
  4. Add ranked lexical search
  5. Retrieve structured facts
  6. Understand embeddings and cosine similarity
  7. Build brute-force vector search
  8. Persist retrieval in PostgreSQL and pgvector
  9. Combine lexical and vector retrieval
  10. Rerank retrieved candidates
  11. Assemble Evidence and verified Citations
  12. Generate grounded Answers
  13. Evaluate retrieval and Answers separately
  14. Connect the complete PostgreSQL-backed system

Let the model choose retrieval tools

  1. Build a read-only retrieval agent
  2. Read Pi as a real Agent Harness

Prepare the system for production

  1. Secure retrieved content and agent tools
  2. Cache expensive stages safely
  3. Monitor a request from start to finish
  4. Serve the pipeline with FastAPI
  5. Test RAG-specific behavior
  6. Harden and deploy the service

Advanced RAG

After the Main Path, you can add retrieval for follow-up questions, advanced database retrieval, webpage parsing, and PDF parsing for text or scanned pages.

Start the Course