The student assistant now supports two modes:
- Server Mode (Recommended): Uses a Flask backend hosted on Vercel
- Client Mode: Users provide their own API keys (original implementation)
- Node.js installed
- Vercel CLI (
npm i -g vercel) - Google AI Studio API key
- Deploy to Vercel:
# In your project root
vercel- Configure Environment Variable:
vercel env add GEMINI_API_KEY
# Enter your Gemini API key when prompted- Deploy Production:
vercel --prod- Update Frontend Configuration:
- The frontend auto-detects the backend URL
- For custom URLs, update
detectBackendUrl()inassistant.js
Set these in Vercel dashboard or CLI:
GEMINI_API_KEY: Your Google AI Studio API key
- Automatically detects if backend is available
- Falls back to client mode if backend is unreachable
- Shows real-time backend status
Users can switch between:
- Server Mode: Uses hosted backend (no API key needed)
- Client Mode: Uses personal API key (stored locally)
- ✅ Backend ready and configured
⚠️ Backend available but not configured- ❌ Backend unavailable
- 🔄 Checking status...
cd backend
pip install -r requirements.txt
export GEMINI_API_KEY="your_key_here"
python app.py- Open
assistant.htmlin browser - Backend URL auto-detects to
http://localhost:5000
The frontend automatically detects the backend URL:
localhost:http://localhost:5000- Vercel domains: Uses same origin
- Custom: Update
detectBackendUrl()method
- Mode selection is saved in localStorage
- API keys are stored locally (never sent to backend)
- Backend status is checked on page load
- Check Vercel deployment logs
- Verify environment variables are set
- Test API endpoints directly
- Check browser console for errors
- Verify network connectivity
- Try switching between modes
- Backend mode: Shared quota (managed by admin)
- Client mode: Individual user quotas
- API keys stored as environment variables
- CORS configured for frontend domain
- Input validation and error handling
- No sensitive data logged
- API keys stored locally only
- Secure HTTPS connections
- XSS protection via DOMPurify
GET /- Health checkGET /api/status- Configuration status- Monitor Vercel function logs
- Google Analytics integrated
- Error tracking in console
- User interaction metrics
- Vercel auto-scales serverless functions
- Monitor usage and adjust quotas
- Consider caching for frequent queries
- CDN delivery via GitHub Pages
- Optimized asset loading
- Responsive design for all devices