Document RAG platform with hybrid search and citations
Build a self-contained Retrieval-Augmented Generation (RAG) platform that runs entirely on 3B storage — no external database. Tenant members upload documents, which get parsed, chunked, and embedded into a shared vector + full-text store. They then ask natural-language questions and get answers composed strictly from the retrieved passages, with citations back to the source documents. The goal is a private, grounded "ask your documents" tool where answers never stray beyond what's actually in the corpus. Trigger it with HTTP routes, gated so only authenticated members of the tenant can reach it. Build these pieces: A web console (single-page React app) as the main entry point — upload documents by drag-and-drop or picker, browse the corpus, inspect a document's chunks, delete documents, and ask questions with answers rendered alongside expandable, scored sources. Give it a strong, distinctive editorial look. An ingest endpoint that accepts one document, extracts its text (support PDF, DOCX, HTML, and plain text/Markdown), splits it into overlapping chunks, embeds each chunk, and writes documents + chunks + a full-text index into the shared store. A query endpoint that embeds the question and does hybrid retrieval — semantic (vector cosine similarity) combined with keyword (full-text/BM25) ranking, fused together — then sends the top chunks to a language model with a strict instruction to answer only from the provided sources and cite them. A documents endpoint to list and delete documents (and their chunks and index entries). Use a single SQLite database on a persistent named volume as the store, with the writing endpoints holding an exclusive write lock and the query endpoint reading it read-only. Store chunk embeddings as fixed-dimension float vectors. For embeddings and answer generation, use OpenAI (text-embedding-3-small for embeddings, gpt-4o-mini for answers) via a connector — or swap in your preferred model provider (Anthropic, Google Gemini, Azure OpenAI, etc.). Keep the embedding model and answer model easy to change, and note that changing the embedding model means re-ingesting documents. Tools used: OpenAI API (text-embedding-3-small, gpt-4o-mini), OpenAI connector, SQLite (FTS5), 3B named volume storage
What this prompt builds
A self-contained RAG platform that runs entirely on 3B storage, allowing tenant members to upload documents, which are parsed, chunked, and embedded into a shared vector and full-text store. Users ask natural-language questions and receive answers composed strictly from retrieved passages with citations back to source documents. The workflow uses OpenAI embeddings and GPT-4o-mini for answer generation, stored in SQLite with no external database required.
The problem
Teams with internal documents, knowledge bases, or proprietary data need a way to ask natural-language questions and get accurate, grounded answers without hallucination or generic responses. Most AI tools either don't connect to company data or require complex external infrastructure. This workflow builds a private, self-contained RAG platform where users upload documents—PDFs, DOCX, HTML, Markdown—then query them in plain English. Answers are composed strictly from retrieved passages and include citations back to the source, ensuring every response is backed by the organization's actual data.
Solution and impact
The workflow delivers a fully functional "ask your documents" tool that runs entirely on 3B storage with no external database. It combines semantic vector search and keyword full-text search (hybrid retrieval) to surface the most relevant passages, then uses a language model constrained to answer only from those sources. Users get accurate, citation-backed answers drawn directly from their corpus, eliminating hallucination and keeping all data private within the tenant.