The beginner capstone — assemble everything from the last four days into a complete Retrieval-Augmented Generation pipeline running entirely on Postgres: schema design, ingest and chunking, embeddings, an HNSW-indexed similarity search with a metadata filter, and grounded generation.
This is the beginner capstone. For four days you learned the pieces; today you wire them into a single working RAG (Retrieval-Augmented Generation) pipeline that runs entirely inside Postgres with the pgvector extension. No separate vector database, no extra service — just the Postgres you already operate.
RAG answers a question by retrieving relevant text from your own data and handing it to an LLM as context, so the model answers from your documents instead of guessing from its training data. Two phases:
A first RAG system rarely has more than a few hundred thousand chunks. At that scale pgvector gives you everything you need and three things a standalone vector DB can't:
WHERE clauses, joined against any table you already have (users, permissions, tenants).Each earlier day maps to one stage of today's pipeline:
| Day | Concept | Stage in today's pipeline |
|---|---|---|
| 1 | Postgres as an AI datastore | The documents / chunks schema |
| 2 | pgvector setup | The vector column and <=> operator |
| 3 | Similarity search | The KNN ORDER BY embedding <=> $1 query |
| 4 | Vector indexing | The HNSW index that keeps retrieval fast |
| 5 | (today) | Tying them together into ingest + retrieve + generate |
By the end of this lesson you'll be able to read — and write — every line of a small but complete RAG service.