A production-ready RAG (Retrieval Augmented Generation) application featuring a Django backend and a React frontend. This system allows users to upload documents (PDF, DOCX, Images), process them using OCR and AI Vision, and chat with their content using advanced retrieval mechanisms.
The project consists of two main components:
- Backend: Built with Django and Django REST Framework. Handles document processing, vector storage (PostgreSQL + pgvector), authentication (JWT), and the RAG pipeline.
- Frontend: Built with React, TypeScript, and Vite. Provides a modern user interface for file management and real-time chat.
- JWT Authentication: Secure user management with access and refresh tokens.
- Cloud Storage: Integration with Cloudinary for secure file storage.
- Advanced Document Processing:
- Support for PDF, DOCX, and Image formats.
- Intelligent OCR (Tesseract) and Vision API integration for extracting text from images.
- RAG Pipeline:
- Semantic search using pgvector and OpenAI embeddings.
- Context-aware responses powered by GPT-4.
- Source tracking to cite documents used in answers.
- Real-time Interaction: Streaming chat responses for a responsive user experience.
- Data Isolation: Strict user-level isolation for all uploaded data and chat history.
Before running the application, ensure you have the following services available:
- Docker and Docker Compose (recommended for full stack execution)
- OpenAI API Key
- Cloudinary Credentials (Cloud Name, API Key, API Secret)
- PostgreSQL Database URL (if running locally without Docker)
The easiest way to run the entire application is using Docker Compose.
-
Clone the repository:
git clone <repository-url> cd rag-chatbot
-
Configure Environment Variables: Create a
.envfile in the root directory or ensure thebackenddirectory has its.envconfigured. You will need to set the following variables:DATABASE_URL=postgresql://user:pass@host:5432/db OPENAI_API_KEY=sk-... CLOUDINARY_CLOUD_NAME=... CLOUDINARY_API_KEY=... CLOUDINARY_API_SECRET=... DJANGO_SECRET_KEY=...
-
Run with Docker Compose:
docker-compose up --build
The application will be accessible at:
- Frontend:
http://localhost - Backend API:
http://localhost:8000
- Frontend:
If you prefer to run the services individually, please refer to the README files in each directory:
- Backend Documentation - Detailed setup for Python, Django, and Celery/Workers.
- Frontend Documentation - Setup for Node.js and React.
- Navigate to
backend/. - Install dependencies using
uvorpip. - Configure
.envfile. - Run migrations:
python manage.py migrate. - Start the server:
python manage.py runserver.
- Navigate to
frontend/. - Install dependencies:
npm install. - Start the development server:
npm run dev.
backend/- Django application code, API configuration, and RAG logic.frontend/- React application source code.docker-compose.yml- Orchestration for running the full stack.