As a software engineer, I have spent a lot of time this year learning how to build with large language models. The pattern that keeps coming up in real products is not a clever prompt. It is RAG: retrieval-augmented generation.
In simple terms, RAG lets an LLM answer from your data instead of only from what it memorised in training. You store your documents as embeddings, retrieve the most relevant chunks for a question, and give those chunks to the model as context.
It sounds simple. The difference between a demo and a useful product is in the engineering around it.
Why RAG, and when not to use it
RAG is a good fit when:
- Your answers need to come from private or changing documents
- Users ask specific questions, not general knowledge questions
- You need to show sources, not just an answer
- Hallucinations are costly, and a wrong answer is worse than no answer
It is not the right tool for everything. If the answer is stable, public knowledge, a plain LLM call is faster and cheaper. If you need exact calculations or up-to-date structured data, an API or database query will beat retrieval every time.
Choosing RAG is an engineering decision, not a default.
My stack: FastAPI + Postgres/pgvector + React
For a practical RAG app, I would keep the stack boring and familiar:
- FastAPI for the API, because it is fast to build with in Python and handles async retrieval well
- Postgres with pgvector for storage, because you get a real database and vector search in one place, instead of adding a separate vector store too early
- React with TypeScript for the frontend, because the interesting work is in the UI: showing sources, streaming answers, and handling follow-up questions
This is the same stack I am building with in my current AI upskilling work. Python for the LLM and retrieval logic, React for the product surface.
The pipeline that actually matters
A RAG system has four parts, and most failures happen in the first two:
- Ingestion: Split documents into chunks that make sense on their own. A chunk that cuts a paragraph in half will retrieve badly, no matter how good your model is.
- Embedding and storage: Store the chunk, its embedding, and its source. Keep the metadata. You will need it to show citations and to debug bad answers.
- Retrieval: Search by meaning, not just keywords. Start with top 5 chunks, then test with real questions. More chunks is not always better, it adds noise.
- Generation: Give the model the retrieved chunks and clear instructions: answer only from the context, say when you do not know, and cite the source.
If an answer is wrong, do not start by changing the model. Check what was retrieved first.
Quality, reliability, and human oversight
AI can accelerate development, but human oversight remains critical here too. A RAG app can retrieve the wrong document, quote it confidently, and look correct.
Good engineering still requires:
- Testing with real questions from real users, not just examples that work
- Measuring retrieval quality, not just whether the final answer sounds good
- Logging questions, retrieved chunks, and answers so you can improve them
- Clear fallbacks when confidence is low or no relevant document is found
RAG does not remove responsibility. It makes the quality of your data and retrieval part of the product.
What I would build first
If you are learning RAG, do not start with a complex agent framework. Build the smallest useful version:
- One document set you understand well
- A simple upload and ask flow in React
- FastAPI endpoints for ingest, ask, and feedback
- Source citations in every answer
Then iterate on chunking, retrieval, and evaluation. That loop is where the learning happens.
AI is not replacing software engineers. It is reshaping the craft toward system design, data quality, and good judgment about when to trust the model. RAG is a good place to practise exactly those skills, because the model is only as good as the system around it.
Top comments (0)