Skip to content

SheinRG/RAG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

RAG Research Assistant

A full-stack Retrieval-Augmented Generation web application that lets you upload documents (PDF, TXT, MD) and ask natural language questions about them. Answers are grounded strictly in your uploaded content — no hallucinations.

Deployed and publicly accessible. Zero cost.

Tech Stack React Groq Supabase Vercel


Features

  • 📤 Upload documents — drag-and-drop PDF, TXT, or Markdown files
  • 🔍 Semantic search — vector similarity search using pgvector + sentence-transformers
  • 🤖 Blazing-fast AI answers — powered by Groq API (LLaMA 3.3 70B)
  • 📎 Source citations — see exactly which documents were used
  • Background ingestion — upload returns immediately, processing happens async
  • 🗑️ Document management — view status, delete documents and their vectors
  • 💬 Chat interface — sleek Q&A with message history
  • ☁️ Fully cloud-hosted — accessible from anywhere

Tech Stack

Layer Technology
Backend Python 3.11 · FastAPI · SQLAlchemy · Gunicorn
Embeddings sentence-transformers (all-MiniLM-L6-v2)
LLM Groq API (LLaMA 3.3 70B Versatile)
Vector Search PostgreSQL + pgvector (cosine similarity)
Document Parsing LangChain community loaders
Frontend React · Vite · Tailwind CSS · Axios
Database Supabase PostgreSQL (metadata + vectors)
File Storage Supabase Storage
Backend Hosting Render / Railway
Frontend Hosting Vercel

Architecture

┌─────────────┐     HTTPS      ┌──────────────────┐     REST      ┌─────────────┐
│   Vercel     │ ──────────────▶│  Render/Railway   │ ────────────▶│  Groq API   │
│  (React UI)  │                │  (FastAPI Server)  │              │  (LLM)      │
└─────────────┘                └──────────────────┘              └─────────────┘
                                       │
                                       │ SQL + pgvector
                                       ▼
                              ┌──────────────────┐
                              │    Supabase       │
                              │  PostgreSQL +     │
                              │  Storage          │
                              └──────────────────┘

Quick Start (Local Development)

Prerequisites

1. Set up Supabase

  1. Create a new Supabase project
  2. Go to SQL Editor and run: CREATE EXTENSION IF NOT EXISTS vector;
  3. Create a Storage bucket called documents (set to public or use service key)
  4. Copy your Project URL, Service Role Key, and Database URI

2. Configure environment

cd backend
cp .env.example .env
# Fill in your Groq API key and Supabase credentials

3. Start the backend

cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

4. Start the frontend

cd frontend
npm install
npm run dev

5. Open the app


Cloud Deployment

Backend → Render / Railway

  1. Push your repo to GitHub
  2. Create a new Web Service on Render
  3. Set Root Directory to backend
  4. Set Build Command: pip install -r requirements.txt
  5. Set Start Command: gunicorn main:app -w 2 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT
  6. Add all env vars from .env.example

Frontend → Vercel

  1. Import your repo to Vercel
  2. Set Root Directory to frontend
  3. Set Framework Preset to Vite
  4. Add env var: VITE_API_BASE_URL = your Render backend URL

API Endpoints

Method Endpoint Description
POST /api/documents/upload Upload a document
GET /api/documents List all documents
GET /api/documents/{id} Get document status
DELETE /api/documents/{id} Delete a document
POST /api/ask Ask a question
POST /api/ask/stream Ask with streaming (SSE)
GET /health Health check

Project Structure

├── backend/
│   ├── main.py               # FastAPI app entry point
│   ├── config.py             # Central configuration (env vars)
│   ├── database.py           # SQLAlchemy + pgvector models
│   ├── ingest.py             # Document ingestion pipeline
│   ├── retriever.py          # pgvector similarity search
│   ├── llm.py                # Groq API integration
│   ├── routes/
│   │   ├── documents.py      # Upload, list, delete routes
│   │   └── query.py          # Q&A routes
│   ├── models/
│   │   └── schemas.py        # Pydantic schemas
│   └── utils/
│       └── file_handler.py   # Supabase Storage utilities
├── frontend/
│   ├── src/
│   │   ├── App.jsx           # Root layout
│   │   ├── components/       # React components
│   │   ├── hooks/            # Custom hooks
│   │   └── api/              # Axios client
│   └── vite.config.js        # Vite config
└── README.md

Future Enhancements

  • Streaming responses with SSE (route already scaffolded)
  • Conversation memory (pass last N messages to LLM)
  • Hybrid search: BM25 keyword + vector search
  • Reranking with cross-encoder
  • Multiple knowledge bases per user
  • JWT authentication
  • Document preview panel

About

A Retrieval-Augmented Generation Research assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors