π¨ 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)
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm start
The app will automatically open at http://localhost:3000
Option 2: Using yarn
cd frontend
yarn install
yarn start
Running Both Backend and Frontend
Terminal 1 - Backend:
cd D:\python_workspace\multi-agent
uv run uvicorn main:app --reload
Terminal 2 - Frontend:
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
POST http://localhost:8000/chat
{
"query": "user question",
"file_path": "path/to/uploaded/file" // optional
}
Upload Endpoint
POST http://localhost:8000/upload
FormData: { file: File }
Customization
Change Theme Colors
Edit frontend/src/App.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:
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
cd frontend
npm run build
Serve Static Build
# 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)
npm install -g vercel
cd frontend
vercel
Deploy to Netlify (Free)
- Push to GitHub
- Connect repo to Netlify
- Set build command:
npm run build - Set publish directory:
build
Troubleshooting
"Cannot connect to backend"
Solution:
- Check backend is running:
http://localhost:8000/docs - 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:
# 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:
# 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 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
Start both services:
- Backend:
uv run uvicorn main:app --reload - Frontend:
cd frontend && npm start
- Backend:
Test the interface:
- Try weather queries
- Upload a document
- Schedule a meeting
- Query the database
Customize:
- Change colors in CSS
- Add new features
- Deploy to production
Enjoy your beautiful AI chat interface! π