RAG (Rapid Answer Generator) is an intelligent web application designed to transform your PDF documents into a personal, queryable knowledge base. Upload your PDFs, ask questions, and receive precise, context-aware answers instantly. Whether for research, study, or decision-making, RAG empowers you to extract maximum value from your documents efficiently.
- Advanced PDF Processing: Upload up to two PDF documents (max 5MB each). The system automatically detects and performs OCR on scanned PDFs using
ocrmypdfto ensure text is always extractable. - Retrieval-Augmented Generation (RAG): Documents are chunked, vectorized using Google's embeddings, and stored in a ChromaDB vector store for efficient similarity searches.
- Context-Aware Chat: Ask questions and receive answers based on the content of your uploaded documents. The conversation history is used to maintain context.
- Gemini Fallback: If an answer isn't found within the provided documents, the app seamlessly queries the powerful Google Gemini model for a general knowledge response.
- Voice-to-Text Input: Use the built-in voice search to ask questions hands-free, powered by the browser's Speech Recognition API.
- Secure User Authentication: Robust authentication system with Appwrite, supporting both email/password and Google OAuth for quick and secure access.
- Conversation Management: View, revisit, and delete past conversations. Your chat history is saved and linked to your user account.
- Usage Limits: Implements a daily prompt limit per user to manage resource consumption, which resets every 24 hours.
- Fully Responsive UI: A sleek and modern interface built with React, Tailwind CSS, and shadcn/ui that works beautifully on desktop and mobile devices.
The application is built with a modern, full-stack architecture, leveraging powerful tools for both the frontend and backend.
- Framework: React.js
- Build Tool: Vite
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- State Management: Redux Toolkit
- Routing: React Router DOM
- Icons: Lucide React
- Server: Flask (Python)
- BaaS (Backend as a Service): Appwrite
- AI/RAG Framework: LangChain (Python)
- AI Model: Google Gemini API
- Vector Database: ChromaDB
- PDF Processing: PyPDFLoader &
ocrmypdf
Below is a high-level overview of the RAG application's architecture:
Watch a quick demonstration of RAG in action, from setting up to querying your documents:
Follow these instructions to set up and run the RAG application on your local machine.
- Node.js (v18 or higher)
- Python (v3.9 or higher)
- npm or Yarn
ocrmypdf(install viapip install ocrmypdfor your system's package manager)
git clone https://github.com/your-username/rag-project.git
cd rag-projectNavigate to the server directory:
cd serverCreate a Python virtual environment and activate it:
# On Windows
python -m venv venv
.\venv\Scripts\activate
# On macOS/Linux
python3 -m venv venv
source venv/bin/activateInstall the required Python packages:
pip install -r requirements.txtCreate a .env file in the server directory by copying .env.sample and fill in your credentials:
# server/.env
FRONTEND_URL="http://localhost:5173"
VITE_APPWRITE_ENDPOINT="https://cloud.appwrite.io/v1"
VITE_APPWRITE_PROJECT_ID="YOUR_APPWRITE_PROJECT_ID"
VITE_APPWRITE_API_KEY="YOUR_APPWRITE_API_KEY"
VITE_APPWRITE_DATABASE_ID="YOUR_APPWRITE_DATABASE_ID"
VITE_APPWRITE_CONVERSATIONS_COLL_ID="YOUR_CONVERSATIONS_COLLECTION_ID"
VITE_APPWRITE_MESSAGES_COLL_ID="YOUR_MESSAGES_COLLECTION_ID"
VITE_APPWRITE_USER_LIMITS_COLL_ID="YOUR_USER_LIMITS_COLLECTION_ID"
GOOGLE_API_KEY="YOUR_GOOGLE_GEMINI_API_KEY"
Run the Flask server:
flask runThe backend server will typically run on http://127.0.0.1:5000.
Open a new terminal and navigate to the client directory:
cd clientInstall the Node.js dependencies:
npm installCreate a .env file in the client directory by copying .env.sample and fill in your credentials:
# client/.env
VITE_APPWRITE_PROJECT_ID="YOUR_APPWRITE_PROJECT_ID"
VITE_APPWRITE_ENDPOINT="https://cloud.appwrite.io/v1"
VITE_APPWRITE_DATABASE_ID="YOUR_APPWRITE_DATABASE_ID"
VITE_APPWRITE_USERS_COLL_ID="YOUR_USERS_COLLECTION_ID"
VITE_APPWRITE_USER_LIMITS_COLL_ID="YOUR_USER_LIMITS_COLLECTION_ID"
VITE_GOOGLE_OAUTH_CLIENT_ID="YOUR_GOOGLE_OAUTH_CLIENT_ID"
VITE_EMAIL_ADDRESS="your-contact-email@example.com"
VITE_BACKEND_URL="http://127.0.0.1:5000"
VITE_BASE_URL="http://localhost:5173"
Start the React development server:
npm run devThe frontend application will open in your browser at http://localhost:5173.
We welcome contributions to the RAG project! If you have suggestions, bug reports, or want to contribute code, please feel free to:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature/your-feature-name). - Open a Pull Request.
