Skip to content

adithya-s-k/RAG-SaaS

Repository files navigation

RAG SaaS

Ship RAG solutions quickly⚡

RAG-SaaS Logo

A end to end SaaS Solution for Retrieval-Augmented Generation (RAG)
and Agentic based applications.

Features · Tech Stack · Getting Started · Deployment · Roadmap

GitHub Stars GitHub Forks GitHub Issues GitHub Pull Requests

Features Demo Video
  • 🔐 Basic Authentication
  • 💬 Chat History Tracking
  • 🧠 Multiple RAG Variations
    • Basic RAG
    • Two additional configurations
  • 👨‍💼 Admin Dashboard
    • 📥 Data Ingestion
    • 📊 Monitoring
    • 👁️ Observability
    • 🔄 RAG Configuration Switching
  • 🗄️ S3 Integration for PDF uploads
  • 🐳 Easy Deployment with Docker / Docker Compose

f937cd54-217f-4106-81b6-56636a17306f (1)

RAG.SAAS.Fast.mp4

Tech Stack

  • 🦙 LlamaIndex: For building and orchestrating RAG pipelines
  • 📦 MongoDB: Used as both a normal database and a vector database
  • ⚡ FastAPI: Backend API framework
  • ⚛️ Next.js: Frontend framework
  • 🔍 Qdrant: Vector database for efficient similarity search
  • 👁️ Arize Phoenix: Observability Platform to monitor/evaluate your RAG system

🌟 Why RAG-SaaS?

Setting up reliable RAG systems can be time-consuming and complex. RAG-SaaS allows developers to focus on fine-tuning and developing their RAG pipeline rather than worrying about packaging it into a usable application. Built on top of create-llama by LlamaIndex, RAG-SaaS provides a solid foundation for your RAG-based projects.

🚀 Getting Started

  1. Clone the repository:
    git clone https://github.com/adithya-s-k/RAG-SaaS.git
    cd RAG-SaaS

🐳 Docker Compose Deployment

Environment Variables

🔑 How to Set up .env

Environment Variables

To properly configure and run RAG-SaaS, you need to set up several environment variables. These are divided into three main sections: Frontend, Backend, and Docker Compose. Here's a detailed explanation of each:

Frontend Environment (./frontend/.env.local)

  • NEXT_PUBLIC_SERVER_URL: (Compulsory) The endpoint URL of your FastAPI server.
  • NEXT_PUBLIC_CHAT_API: (Compulsory) Derived from NEXT_SERVER_URL, typically set to ${NEXT_PUBLIC_SERVER_URL}/api/chat.

Backend Environment (./backend/.env)

  1. Model Configuration:

    • MODEL_PROVIDER: (Compulsory) The AI model provider (e.g., 'openai').
    • MODEL: (Compulsory) The name of the LLM model to use.
    • EMBEDDING_MODEL: (Compulsory) The name of the embedding model.
    • EMBEDDING_DIM: (Compulsory) The dimensionality of the embedding model.
  2. OpenAI Configuration:

    • OPENAI_API_KEY: (Compulsory) Your OpenAI API key.
  3. Application Settings:

    • CONVERSATION_STARTERS: (Compulsory) A list of starter questions for users.
    • SYSTEM_PROMPT: (Compulsory) The system prompt for the AI model.
    • SYSTEM_CITATION_PROMPT: (Optional) Additional prompt for citation.
    • APP_HOST: (Compulsory) The host address for the backend (default: '0.0.0.0').
    • APP_PORT: (Compulsory) The port for the backend (default: 8000).
  4. Database Configuration:

    • MONGODB_URI: (Compulsory) The MongoDB connection URI.
    • MONGODB_NAME: (Compulsory) The MongoDB database name (default: 'RAGSAAS').
    • QDRANT_URL: (Compulsory) The URL for the Qdrant server.
    • QDRANT_COLLECTION: (Compulsory) The Qdrant collection name.
    • QDRANT_API_KEY: (Optional) API key for Qdrant authentication.
  5. Authentication:

    • JWT_SECRET_KEY: (Compulsory) Secret key for signing JWT tokens.
    • JWT_REFRESH_SECRET_KEY: (Compulsory) Secret key for signing JWT refresh tokens.
    • ADMIN_EMAIL: (Compulsory) Administrator email for application login.
    • ADMIN_PASSWORD: (Compulsory) Administrator password for application login.
  6. AWS S3 Configuration (Optional):

    • AWS_ACCESS_KEY_ID: AWS Access Key ID.
    • AWS_SECRET_ACCESS_KEY: AWS Secret Access Key.
    • AWS_REGION: AWS Region for your services.
    • BUCKET_NAME: The name of the S3 bucket to use.
  7. Observability:

    • ARIZE_PHOENIX_ENDPOINT: (Optional) Endpoint for Arize Phoenix observability.

S3 Integration

To enable S3 integration for PDF uploads/Ingestion:

  1. Set the following environment variables in your .env file:

AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=bucket_region
BUCKET_NAME=your_bucket_name

Docker Compose Env (./env)

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    image: ragsaas/backend:latest
    container_name: backend
    ports:
      - '8000:8000'
    environment:
      # MongoDB Configuration
      MONGODB_NAME: RAGSAAS
      MONGODB_URI: mongodb://admin:password@mongodb:27017/
      # Qdrant Configuration
      QDRANT_COLLECTION: default
      QDRANT_URL: http://qdrant:6333
      # QDRANT_API_KEY:
      # OPENAI_API_KEY is compulsory
      OPENAI_API_KEY:
      # Backend Application Configuration
      MODEL_PROVIDER: openai
      MODEL: gpt-4o-mini
      EMBEDDING_MODEL: text-embedding-3-small
      EMBEDDING_DIM: 1536
      FILESERVER_URL_PREFIX: http://backend:8000/api/files
      SYSTEM_PROMPT: 'You are a helpful assistant who helps users with their questions.'
      APP_HOST: 0.0.0.0
      APP_PORT: 8000
      JWT_SECRET_KEY:
      JWT_REFRESH_SECRET_KEY:
      ARIZE_PHOENIX_ENDPOINT: http://arizephoenix:4317

For Docker Compose deployment, use:

docker compose up -d

Pull down the containers

docker compose down

Development Mode

To run the project in development mode, follow these steps:

  1. Start the Next.js Frontend:

    Navigate to the frontend directory and install the required dependencies. Then, run the development server:

    cd frontend
    npm install
    npm run dev
  2. Set Up the Vector Database (Qdrant), Database (MongoDB), and Observability Platform (Arize Phoenix):

    You can either self-host these services using Docker or use hosted solutions.

    Self-Hosted Options:

    • Qdrant:

      docker pull qdrant/qdrant
    • MongoDB:

      docker pull mongo
    • Arize Phoenix:

      docker pull arizephoenix/phoenix

    Hosted Options:

  3. Start the FastAPI Server:

    Navigate to the backend directory and set up the Python environment. You can use either Conda or Python's built-in venv:

    cd backend

    Using Conda:

    conda create -n ragsaas-venv python=3.11
    conda activate ragsaas-venv

    Using Python's venv:

    python -m venv ragsaas-venv
    \ragsaas-venv\Scripts\activate  # On Windows
    source ragsaas-venv/bin/activate  # On macOS/Linux

    Install the required dependencies and run the server:

    pip install -e .
    python main.py

Roadmap

  • add support to store ingested data in AWS S3
  • Add Docker compose for each set up
  • Implement Observability
  • Improve authentication system
  • Integrate OmniParse API for efficient Data ingestion
  • Provide more control to Admin over RAG configuration
  • Implement Advanced and Agentic RAG

👥 Contributing

We welcome contributions to RAG-SaaS! Please see our CONTRIBUTING.md for more details on how to get started.

📄 Licensing

This project is available under a dual license:

  • Apache License 2.0 for students, developers, and individuals
  • GNU General Public License v3.0 for companies and commercial use

See the LICENSING.md file for more details.

🙏 Acknowledgements

This project is built on the following frameworks, technologies and tools:

Contact & Support

Bug Reports

If you encounter any issues or bugs, please report them in the Issues tab of our GitHub repository.

Commercial Use & Custom Solutions

For inquiries regarding:

  • Commercial licensing
  • Custom modifications
  • Managed deployment
  • Specialized integrations

Please contact: adithyaskolavi@gmail.com

We're here to help tailor RAG-SaaS to your specific needs and ensure you get the most out of our solution.

Star History

Star History Chart

Releases

No releases published

Packages

No packages published