Creating a MongoDB RAG Application
The MongoDB RAG CLI provides a powerful create-rag-app
command that helps you quickly scaffold a complete RAG (Retrieval Augmented Generation) application with both frontend and backend components.
Quick Start
This command creates a new directory my-rag-app
with a fully configured RAG application.
Project Structure
The generated application includes:
Setup
-
Navigate to your project directory:
cd my-rag-app
-
Configure your environment variables in
backend/.env
:MONGODB_URI=your_mongodb_uri
OPENAI_API_KEY=your_openai_key -
Install dependencies and start the application:
# Install backend dependencies
cd backend && npm install
# Install frontend dependencies
cd ../frontend && npm install
# Start both frontend and backend (from root directory)
npm run dev
Features
Backend
- Express.js server with MongoDB integration
- Pre-configured RAG endpoints
- Document processing and vector storage
- Streaming chat responses
- Error handling middleware
Frontend
- Modern React UI with Material-UI
- Interactive chat interface
- Document upload and management
- Real-time search results
- Mobile-responsive design
API Endpoints
The backend exposes these REST API endpoints:
POST /api/documents
- Upload and process documentsPOST /api/chat
- Send questions and receive AI-generated responsesGET /api/search
- Perform vector similarity searchGET /api/documents
- Retrieve processed documents
Customization
You can customize the application by:
- Adjusting vector search parameters in
backend/src/config/ragConfig.js
- Modifying UI components in the frontend
- Adding authentication and authorization
- Implementing domain-specific features
Next Steps
- Deploy your application
- Add your documents to the system
- Customize the UI to match your brand
- Implement user authentication
- Add features specific to your use case