Skip to content

About

Enterprise-ready RAG system featuring Hybrid Search (Dense + BM25), Cross-Encoder Reranking, FastAPI, and automated RAGAS evaluation.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Production RAG Engine

Python Version FastAPI React Docker Status

An Enterprise-grade Retrieval-Augmented Generation (RAG) Engine designed to securely ingest, index, and query confidential documents using state-of-the-art hybrid search (Vector + Sparse) and cross-encoder reranking.

✨ Key Features

  • Advanced Hybrid Search: Combines semantic search (ChromaDB + FastEmbed) and keyword search (BM25) using Reciprocal Rank Fusion (RRF).
  • Precision Reranking: Uses FlashRank cross-encoder to guarantee highly relevant context extraction.
  • Strict Guardrails: Built-in prompt engineering to prevent hallucinations and strictly restrict the LLM to context-only answers.
  • Source Citations: Transparent answers with exact chunk-level metadata citations.
  • Streaming UI: A modern, responsive React + Tailwind v4 interface for real-time generative chat.
  • Secure & Local Ready: Easy drop-in for open-source local LLMs (e.g., Llama 3) or API providers (Groq/Gemini).

🏗️ System Architecture

graph TD
    subgraph Data Pipeline
        Docs[Raw Documents: PDF/TXT] --> Loaders[Multi-Format Loaders]
        Loaders --> Chunker[Token-Aware Recursive Splitter]
        Chunker --> Dense[FastEmbed BGE-small-en]
        Chunker --> Sparse[BM25 Indexer]
        Dense --> Chroma[(ChromaDB)]
        Sparse --> BM25Store[(Sparse Index)]
    end

    subgraph Retrieval Engine
        Query[User Query] --> HybridSearch[Hybrid Search: RRF]
        Chroma --> HybridSearch
        BM25Store --> HybridSearch
        HybridSearch --> TopK[Top-K Candidates]
        TopK --> Reranker[FlashRank Reranker]
    end

    subgraph Generation & UI
        Reranker --> Guardrails[Prompt with Guardrails]
        Guardrails --> LLM[LLM Generator]
        LLM --> UI[React Frontend]
    end
Loading

🚀 Quick Start

1. Prerequisites

  • Docker and Docker Compose installed.
  • A valid Groq API Key (or your preferred LLM provider).

2. Configuration

Copy the sample environment file and add your credentials:

cp .env.example .env
# Edit .env and insert your GROQ_API_KEY

3. Run with Docker Compose

Spin up both the backend API and the frontend application in one command:

docker-compose up --build

4. Usage

  • Frontend App: Open your browser and navigate to http://localhost:5173.
  • Backend API Docs: Open http://localhost:8000/docs to test endpoints via Swagger UI.
  • Upload Documents: Use the sidebar in the UI to upload PDF, DOCX, or TXT files.
  • Ask Questions: Chat with the RAG engine. It will search your uploaded documents and cite its sources.

📁 Project Structure

  • /src/api - FastAPI routes and server configuration.
  • /src/generation - LLM clients, RAG chains, and prompt guardrails.
  • /src/retrieval - Hybrid search engines, BM25 indexers, and Rerankers.
  • /src/vectorstores - Persistent vector database (ChromaDB) managers.
  • /src/ingestion - Document parsing and chunking logic.
  • /frontend - React SPA with Tailwind CSS v4 and Vite.
  • /data - Local persistence layer for ChromaDB, BM25 indices, and FlashRank cache.

🛡️ Security Note

  • Never commit your .env file or API Keys.
  • Do not commit the /data directory as it contains your indexed documents and cache. These are ignored via .gitignore by default.

Built with ❤️ for Enterprise AI solutions.

About

Enterprise-ready RAG system featuring Hybrid Search (Dense + BM25), Cross-Encoder Reranking, FastAPI, and automated RAGAS evaluation.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages