|
| 1 | +--- |
| 2 | +id: create-rag-app |
| 3 | +title: Creating a RAG Application |
| 4 | +sidebar_label: Create RAG App |
| 5 | +--- |
| 6 | + |
| 7 | +# Creating a MongoDB RAG Application |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Quick Start |
| 14 | + |
| 15 | +This command creates a new directory `my-rag-app` with a fully configured RAG application. |
| 16 | + |
| 17 | +## Project Structure |
| 18 | + |
| 19 | +The generated application includes: |
| 20 | + |
| 21 | +## Setup |
| 22 | + |
| 23 | +1. Navigate to your project directory: |
| 24 | + ```bash |
| 25 | + cd my-rag-app |
| 26 | + ``` |
| 27 | + |
| 28 | +2. Configure your environment variables in `backend/.env`: |
| 29 | + ```bash |
| 30 | + MONGODB_URI=your_mongodb_uri |
| 31 | + OPENAI_API_KEY=your_openai_key |
| 32 | + ``` |
| 33 | + |
| 34 | +3. Install dependencies and start the application: |
| 35 | + ```bash |
| 36 | + # Install backend dependencies |
| 37 | + cd backend && npm install |
| 38 | + |
| 39 | + # Install frontend dependencies |
| 40 | + cd ../frontend && npm install |
| 41 | + |
| 42 | + # Start both frontend and backend (from root directory) |
| 43 | + npm run dev |
| 44 | + ``` |
| 45 | + |
| 46 | +## Features |
| 47 | + |
| 48 | +### Backend |
| 49 | +- Express.js server with MongoDB integration |
| 50 | +- Pre-configured RAG endpoints |
| 51 | +- Document processing and vector storage |
| 52 | +- Streaming chat responses |
| 53 | +- Error handling middleware |
| 54 | + |
| 55 | +### Frontend |
| 56 | +- Modern React UI with Material-UI |
| 57 | +- Interactive chat interface |
| 58 | +- Document upload and management |
| 59 | +- Real-time search results |
| 60 | +- Mobile-responsive design |
| 61 | + |
| 62 | +## API Endpoints |
| 63 | + |
| 64 | +The backend exposes these REST API endpoints: |
| 65 | + |
| 66 | +- `POST /api/documents` - Upload and process documents |
| 67 | +- `POST /api/chat` - Send questions and receive AI-generated responses |
| 68 | +- `GET /api/search` - Perform vector similarity search |
| 69 | +- `GET /api/documents` - Retrieve processed documents |
| 70 | + |
| 71 | +## Customization |
| 72 | + |
| 73 | +You can customize the application by: |
| 74 | + |
| 75 | +- Adjusting vector search parameters in `backend/src/config/ragConfig.js` |
| 76 | +- Modifying UI components in the frontend |
| 77 | +- Adding authentication and authorization |
| 78 | +- Implementing domain-specific features |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +## Next Steps |
| 83 | + |
| 84 | +1. Deploy your application |
| 85 | +2. Add your documents to the system |
| 86 | +3. Customize the UI to match your brand |
| 87 | +4. Implement user authentication |
| 88 | +5. Add features specific to your use case |
| 89 | + |
| 90 | +For more detailed information about MongoDB RAG, visit the [main documentation](./README.md). |
0 commit comments