| # π¨ Frontend Setup Guide | |
| ## Overview | |
| Beautiful React.js chat interface with gradient design, real-time updates, and full chat memory. | |
| ## Prerequisites | |
| - Node.js 16+ and npm | |
| - Backend running on port 8000 | |
| ## Installation | |
| ### Option 1: Using npm (Recommended) | |
| ```powershell | |
| # Navigate to frontend directory | |
| cd frontend | |
| # Install dependencies | |
| npm install | |
| # Start development server | |
| npm start | |
| ``` | |
| The app will automatically open at [http://localhost:3000](http://localhost:3000) | |
| ### Option 2: Using yarn | |
| ```powershell | |
| cd frontend | |
| yarn install | |
| yarn start | |
| ``` | |
| ## Running Both Backend and Frontend | |
| **Terminal 1 - Backend:** | |
| ```powershell | |
| cd D:\python_workspace\multi-agent | |
| uv run uvicorn main:app --reload | |
| ``` | |
| **Terminal 2 - Frontend:** | |
| ```powershell | |
| cd D:\python_workspace\multi-agent\frontend | |
| npm start | |
| ``` | |
| ## Features Showcase | |
| ### 1. Chat Interface | |
| - π¬ Modern gradient design | |
| - π Scrollable chat history | |
| - β‘ Real-time typing indicators | |
| - π¨ Different colors for user/assistant/error messages | |
| ### 2. File Upload | |
| - π Click folder icon to upload | |
| - β Supported: PDF, TXT, MD, DOCX | |
| - π File badge shows current upload | |
| - π Ask questions about uploaded documents | |
| ### 3. Example Queries | |
| - π€οΈ "What's the weather in Chennai?" | |
| - π "Schedule a team meeting tomorrow at 2pm" | |
| - πΎ "Show all meetings scheduled tomorrow" | |
| - π "What is the remote work policy?" | |
| ### 4. Chat Memory | |
| - β Full conversation history maintained | |
| - ποΈ Clear chat button to start fresh | |
| - π System messages for file uploads | |
| ## Screenshots | |
| ``` | |
| βββββββββββββββββββββββββββββββββββββββββββ | |
| β π€ Multi-Agent AI Assistant β | |
| β Weather β’ Documents β’ Meetings β’ SQL β | |
| βββββββββββββββββββββββββββββββββββββββββββ | |
| β β | |
| β π€ Hello! I'm your Multi-Agent AI... β | |
| β β | |
| β What's the weather? π€ β | |
| β β | |
| β π€ The weather in Chennai is... β | |
| β β | |
| βββββββββββββββββββββββββββββββββββββββββββ | |
| β π€οΈ Weather | π Meetings | πΎ SQL β | |
| βββββββββββββββββββββββββββββββββββββββββββ | |
| β Type your message... π€ β | |
| βββββββββββββββββββββββββββββββββββββββββββ | |
| ``` | |
| ## API Integration | |
| The frontend uses axios to communicate with FastAPI: | |
| ### Chat Endpoint | |
| ```javascript | |
| POST http://localhost:8000/chat | |
| { | |
| "query": "user question", | |
| "file_path": "path/to/uploaded/file" // optional | |
| } | |
| ``` | |
| ### Upload Endpoint | |
| ```javascript | |
| POST http://localhost:8000/upload | |
| FormData: { file: File } | |
| ``` | |
| ## Customization | |
| ### Change Theme Colors | |
| Edit `frontend/src/App.css`: | |
| ```css | |
| .chat-header { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| } | |
| /* Change to your preferred gradient */ | |
| .chat-header { | |
| background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); | |
| } | |
| ``` | |
| ### Add More Example Queries | |
| Edit `frontend/src/App.js`: | |
| ```javascript | |
| const exampleQueries = [ | |
| 'π€οΈ What\'s the weather in Chennai?', | |
| 'π Schedule a team meeting tomorrow at 2pm', | |
| // Add your custom queries here | |
| 'π Search for AI trends', | |
| ]; | |
| ``` | |
| ## Production Deployment | |
| ### Build for Production | |
| ```powershell | |
| cd frontend | |
| npm run build | |
| ``` | |
| ### Serve Static Build | |
| ```powershell | |
| # Using Python | |
| cd build | |
| python -m http.server 3000 | |
| # Or using serve package | |
| npm install -g serve | |
| serve -s build -p 3000 | |
| ``` | |
| ### Deploy to Vercel (Free) | |
| ```powershell | |
| npm install -g vercel | |
| cd frontend | |
| vercel | |
| ``` | |
| ### Deploy to Netlify (Free) | |
| 1. Push to GitHub | |
| 2. Connect repo to Netlify | |
| 3. Set build command: `npm run build` | |
| 4. Set publish directory: `build` | |
| ## Troubleshooting | |
| ### "Cannot connect to backend" | |
| **Solution:** | |
| 1. Check backend is running: `http://localhost:8000/docs` | |
| 2. Verify proxy setting in `package.json`: `"proxy": "http://localhost:8000"` | |
| ### "File upload failed" | |
| **Reasons:** | |
| - File too large (>10MB) | |
| - Unsupported file type | |
| - Backend not running | |
| **Solution:** Check backend logs and file constraints | |
| ### "npm install fails" | |
| **Solution:** | |
| ```powershell | |
| # Clear npm cache | |
| npm cache clean --force | |
| # Delete node_modules and reinstall | |
| rm -rf node_modules package-lock.json | |
| npm install | |
| ``` | |
| ### Port 3000 already in use | |
| **Solution:** | |
| ```powershell | |
| # Use different port | |
| set PORT=3001 && npm start | |
| # Or kill existing process | |
| npx kill-port 3000 | |
| ``` | |
| ## Development Tips | |
| ### Hot Reload | |
| Changes to React components automatically reload in browser | |
| ### React DevTools | |
| Install [React Developer Tools](https://react.dev/learn/react-developer-tools) for debugging | |
| ### API Testing | |
| Use the browser's Network tab to inspect API calls | |
| ## Architecture | |
| ``` | |
| Frontend (React) | |
| βββ public/ | |
| β βββ index.html # HTML template | |
| βββ src/ | |
| β βββ App.js # Main chat component | |
| β βββ App.css # Styling | |
| β βββ index.js # Entry point | |
| β βββ index.css # Global styles | |
| βββ package.json # Dependencies | |
| βββ README.md # Documentation | |
| ``` | |
| ## Next Steps | |
| 1. **Start both services:** | |
| - Backend: `uv run uvicorn main:app --reload` | |
| - Frontend: `cd frontend && npm start` | |
| 2. **Test the interface:** | |
| - Try weather queries | |
| - Upload a document | |
| - Schedule a meeting | |
| - Query the database | |
| 3. **Customize:** | |
| - Change colors in CSS | |
| - Add new features | |
| - Deploy to production | |
| --- | |
| **Enjoy your beautiful AI chat interface! π** | |