Getting Started

DJ Rag is a powerful RAG (Retrieval-Augmented Generation) platform that allows you to chat with your documents. It uses advanced vector search and LLMs to provide accurate, citation-backed answers.

Quick Start

# Clone the repository
git clone https://github.com/DJ-InfinityCoder/RAG.git

# Install Backend Dependencies
cd RagBackend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Install Frontend Dependencies
cd ../RagFrontend
npm install

# Run the Application
# Terminal 1: Backend
./run.sh
# Terminal 2: Frontend
npm run dev

Architecture

The system is built on a modern stack designed for performance and scalability.

Frontend (Next.js 16)

  • App Router & Server Components
  • Tailwind CSS for Styling
  • SWR for Data Fetching & Caching
  • Framer Motion for Animations

Backend (FastAPI)

  • Async API Endpoints
  • LangChain for RAG Pipeline
  • Flashrank for Reranking
  • LRU Caching for Performance

Database & Vector Store

  • Pinecone for Vector Embeddings
  • Neon (PostgreSQL) for Chat History
  • Google Gemini Pro for Embeddings & Generation

Configuration

Configure the application using environment variables. Create a .env file in both backend and frontend directories.

Backend (.env)

VariableDescription
GOOGLE_API_KEYAPI Key for Gemini Pro & Embeddings
PINECONE_API_KEYAPI Key for Pinecone Vector DB
PINECONE_ENVPinecone Environment Region
DATABASE_URLPostgreSQL Connection String (Neon)

Frontend (.env.local)

VariableDescription
NEXT_PUBLIC_API_BASE_URLURL of the deployed Backend API

Deployment

You can deploy this project for free using popular hosting providers.

Frontend (Vercel)

  1. Push your code to GitHub.
  2. Import the repo in Vercel.
  3. Set the Root Directory to RagFrontend.
  4. Add NEXT_PUBLIC_API_BASE_URL env var.
  5. Deploy!

Backend (Render)

  1. Create a new Web Service.
  2. Connect your GitHub repo.
  3. Set Root Directory to RagBackend.
  4. Set Build Command: pip install -r requirements.txt.
  5. Set Start Command: uvicorn main:app --host 0.0.0.0 --port 8000.
  6. Add all backend env vars.

Remarks & Limits

  • Provider Limits: Free tier accounts for Pinecone and Gemini have rate limits. If you encounter errors, wait a moment and try again.
  • Cold Starts: On free hosting like Render, the backend may spin down after inactivity. The first request might take 30-60 seconds to wake it up.
  • File Size: Currently optimized for documents under 10MB to ensure fast processing within serverless timeout limits.