Production RAG Architecture: Crawl to Cited Answers (2026)
A production RAG (retrieval-augmented generation) system crawls your content, splits it into section-sized chunks, embeds them in a vector database, retrieves and reranks the best matches for each question, and has an LLM answer only from those matches, with citations. Most RAG projects that disappoint in production get the model right and the plumbing wrong: chunks that cut sections in half, no reranking, and an index that silently goes stale.
This guide builds each stage with ready-to-run Python, and spends most of its time on the parts other guides skip: chunking, freshness and measurement.
| Stage | Tool | Key decision |
|---|---|---|
| 1. Crawl | Apify Website Content Crawler | Clean Markdown per page, on a schedule |
| 2. Chunk | Markdown RAG Chunker or LangChain | One section per chunk, ≤512 tokens, stable IDs |
| 3. Embed | OpenAI text-embedding-3-small or local FastEmbed | Cost vs quality |
| 4. Store | Qdrant or pgvector | Dedicated vector DB vs your existing Postgres |
| 5. Retrieve | Dense search + Cohere rerank-v4.0-pro | Top 20 candidates, rerank to top 5 |
| 6. Generate | Claude (claude-opus-5-5) | Answer only from sources, cite them |
| 7. Stay fresh | Stable chunk IDs + document_hash cleanup | Re-embed only what changed |
Install everything (latest stable versions as of October 2026; the code below targets them):
pip install apify-client==3.3.0 langchain-text-splitters==1.1.3 tiktoken==0.14.0 \
openai==3.35.1 fastembed==0.9.0 qdrant-client==1.19.1 cohere==7.2.0 anthropic==1.15.0
You need an Apify account, a Qdrant instance (docker run -p 6333:6333 qdrant/qdrant, or Qdrant Cloud's free tier), and API keys for the services you choose: OpenAI (optional), Cohere and Anthropic.

