This project implements a RAG (Retrieval-Augmented Generation) system that combines document retrieval with generative AI to provide accurate, context-aware responses.
- MongoDB: Document database for storing scraped articles and metadata
- Vector Database (ChromaDB): For storing and retrieving embeddings
- OpenAI GPT-4: For generating responses and embeddings
- Flask: Backend REST API framework
- Streamlit: Frontend interface
langchain: For RAG implementation and embeddings managementopenai: OpenAI API integrationpymongo: MongoDB clientflask: Web framework for the backend APIchromadb: Vector database for similarity searchrequests: HTTP client for API communication
The system consists of several microservices:
-
Scraper Service
- Responsible for collecting and processing source documents
- Stores documents in MongoDB
-
RAG Updater Service
- Processes documents and generates embeddings
- Updates the vector store with new embeddings
- Maintains the ChromaDB vector database
-
Backend Service
- Provides REST API endpoints
- Handles query processing and RAG operations
- Integrates with OpenAI for response generation
- Manages vector store retrieval
-
Frontend Service
- User interface for interacting with the system
- Displays query results and sources
- Handles user input and visualization
-
MongoDB Service
- Persistent storage for documents and metadata
- Maintains data consistency across services
- Docker and Docker Compose installed
- OpenAI API key
-
Clone the repository
-
Create a
.envfile in the project root with: OPENAI_API_KEY=your_openai_api_key_here -
Run the entire stack using Docker Compose:
docker compose up -dThis will start all services:
- Frontend will be available at
http://localhost:8501 - Backend API at
http://localhost:8000 - MongoDB at
localhost:27017
- Frontend depends on Backend
- Backend depends on MongoDB and vector store
- RAG Updater depends on MongoDB
- Scraper depends on MongoDB
The system uses Docker volumes for persistent storage:
- : For MongoDB documents
mongodb_data - : For ChromaDB vector store
vectorstore_data