RAG patterns with Laravel and PostgreSQL: retrieval without pretending you shipped ML
A backend-focused look at retrieval-augmented generation — pgvector or external search, chunking, and honest scope for teams integrating knowledge bases into PHP apps.
RAG in production is mostly data engineering and API design: chunk documents, embed with a provider, store vectors, retrieve top-k, inject into the prompt. Laravel orchestrates; it does not need to own the embedding model.
Start with a small corpus and measure retrieval quality before tuning prompts. Bad retrieval cannot be fixed with better system messages. Log which chunks were used for each answer for debugging and compliance.
PostgreSQL with pgvector or an external index (OpenSearch, Algolia) depends on scale and ops appetite. I prefer the simplest store that meets latency SLOs — same philosophy as caching at TLSContact.
Be honest in job profiles: integrating RAG is intermediate backend work; training models is not what most Laravel teams need. I position LLM API integration as growing strength, not fake ML expertise.