Open source · FastAPI · LangChain

Enterprise RAG Engine

A secure Retrieval-Augmented Generation service that connects unstructured company documents to LLMs, with tenant isolation, swappable providers and answers that cite their sources.

Watch the demo

Two companies upload their own documents and ask the same question. Only the company that owns the answer gets it. Recorded against the engine running locally on Llama 3.2 via Ollama.

Why it exists

Most RAG tutorials wire an LLM straight to a vector store, with no auth, no tenant boundaries and API keys in the script. This is a small, honest reference implementation of the production version.

Secure by default

API-key auth, rate limiting, a CORS allow-list, upload size and type checks, and zero secrets in source control.

Multi-tenant

Every chunk carries a tenant_id, and retrieval is filtered by it, so one customer's documents never reach another's answers. API keys can be bound to the tenants they may use.

Provider-agnostic

Swap OpenAI for Llama-3 (Groq or Together) or a free local model via Ollama, and Chroma for Pinecone, with one environment variable.

Grounded answers

The model answers only from retrieved context and returns the source snippets, so claims can be checked.

Tested

A pytest suite covers auth enforcement and chunking, with CI and secret scanning on every push.

Runs anywhere

Docker and docker-compose included; local embeddings (MiniLM) mean no paid API is needed to start.

How a question is answered

Ingestion and querying both pass through auth and rate limiting first.

IngestFiles arrive with a tenant ID
ChunkRecursive splitting with overlap
EmbedLocal MiniLM or OpenAI
StoreChroma or Pinecone, tenant-scoped
RetrieveTop-k, filtered by tenant
AnswerGrounded LLM reply with cited sources

API at a glance

Full request and response schemas, generated from the code on every deploy, are in the interactive API reference.

EndpointWhat it does
GET /healthLiveness check
POST /ingestUpload documents for a tenant; they are chunked, embedded and stored
POST /queryAsk a question for a tenant; returns the answer and the source snippets it used

Run it yourself

This page and the API reference are static. To call the API, run the service locally:

git clone https://github.com/CyberAli-eng/enterprise-rag-engine.git
cd enterprise-rag-engine
cp .env.example .env        # add your keys, or set LLM_PROVIDER=ollama
docker compose up --build   # API on http://localhost:8000, docs at /docs

# free & local, no API key: Ollama + Llama 3.2
docker compose --profile local up --build

Built by Ali Khusroo Bin Sabir · MIT licensed