A full-stack Retrieval-Augmented Generation (RAG) chatbot for uploading PDFs and asking questions about their content. Built with FastAPI, Next.js, MongoDB, Cohere embeddings, and Groq's Llama 3.3 70B.
- 📄 Upload up to 4 PDFs simultaneously with automatic chunking & vector embeddings
- 💬 Context-aware Q&A using semantic search and RAG
- 👤 JWT authentication with secure password hashing
- 🗂️ Multiple chat conversations with auto-generated titles
- 🎨 Modern dark UI with responsive design
1. Clone & Setup Backend
git clone https://github.com/Krishna41357/KS-RAG.git
cd KS-RAG/server
python -m venv ragbot
source ragbot/bin/activate # Windows: ragbot\Scripts\activate
pip install -r requirements.txt
# Create .env file
cp .env.example .envEdit server/.env:
MONGO_URI=mongodb://localhost:27017/rag_database
COHERE_API_KEY=your_cohere_api_key
GROQ_API_KEY=your_groq_api_key
SECRET_KEY=your_secret_key_32_chars_minimumStart backend:
uvicorn main:app --reload --port 90002. Setup Frontend
cd ../client
npm install
# Create .env.local
cp .env.example .env.localEdit client/.env.local:
NEXT_PUBLIC_API_BASE_URL=http://localhost:9000Start frontend:
npm run devVisit http://localhost:3000
- Sign up/Login at the homepage
- Upload PDFs using the paperclip icon (up to 4 files)
- Ask questions and get AI-powered answers with source citations
- Manage chats from the sidebar
Backend: FastAPI, MongoDB, PyPDF2, Cohere, Groq, JWT
Frontend: Next.js 16, TypeScript, TailwindCSS, Lucide React
| Method | Endpoint | Description |
|---|---|---|
| POST | /users/register |
Register user |
| POST | /users/login |
Login user |
| POST | /upload |
Upload PDFs |
| POST | /chats/{id}/messages |
Send message & get response |
| GET | /chats |
List user chats |
KS-RAG/
├── server/ # FastAPI backend
│ ├── main.py # Entry point
│ ├── vectorstore.py # PDF processing
│ ├── routes/ # API endpoints
│ └── .env.example
├── client/ # Next.js frontend
│ ├── app/ # Pages
│ ├── components/ # React components
│ └── .env.example
└── README.md
Krishna Srivastava
GitHub: @Krishna41357
Email: krishnasrivastava41357@gmail.com
MIT License
Built with ❤️ by Krishna Srivastava