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)
| Variable | Description |
|---|---|
| GOOGLE_API_KEY | API Key for Gemini Pro & Embeddings |
| PINECONE_API_KEY | API Key for Pinecone Vector DB |
| PINECONE_ENV | Pinecone Environment Region |
| DATABASE_URL | PostgreSQL Connection String (Neon) |
Frontend (.env.local)
| Variable | Description |
|---|---|
| NEXT_PUBLIC_API_BASE_URL | URL of the deployed Backend API |
Deployment
You can deploy this project for free using popular hosting providers.
Frontend (Vercel)
- Push your code to GitHub.
- Import the repo in Vercel.
- Set the Root Directory to
RagFrontend. - Add
NEXT_PUBLIC_API_BASE_URLenv var. - Deploy!
Backend (Render)
- Create a new Web Service.
- Connect your GitHub repo.
- Set Root Directory to
RagBackend. - Set Build Command:
pip install -r requirements.txt. - Set Start Command:
uvicorn main:app --host 0.0.0.0 --port 8000. - 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.