- Phase: 2 (Development & Presentation)
- Status: Core functionality implemented, ready for deployment
- Repository: GitHub repository with full-stack React + Express application
- Deployment Strategy: Monorepo (recommended for academic projects)
- Frontend: React + Vite + Tailwind CSS
- Backend: Express.js + OpenAI SDK
- Testing: Vitest (Frontend), Mocha (Backend), Cypress (E2E)
- Development: Node.js, npm, concurrently
-
Frontend (✅ Complete)
- ChatInterface component with responsive design
- MessageList with proper styling and auto-scroll
- MessageInput with validation and submission
- SettingsPanel with API key and model selection
- Demo mode implementation
- State management with custom hooks
- API integration utilities
-
Backend (✅ Complete)
- Express server with security middleware
- API endpoints for chat, validation, and models
- OpenAI integration with proper error handling
- Demo mode responses
- Rate limiting and CORS protection
- Simplified Management: Single repository, single deployment pipeline
- Cost Effective: One Vercel project instead of two
- Easier Environment Variables: Centralized configuration
- Better for Academic Projects: Simpler for evaluation and demonstration
- Your Current Setup: Your
vercel.jsonis already configured for monorepo deployment
Your existing vercel.json is correctly configured for monorepo deployment:
{
"version": 2,
"builds": [
{
"src": "frontend/package.json",
"use": "@vercel/static-build",
"config": {
"distDir": "dist"
}
},
{
"src": "backend/server.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/api/(.*)",
"dest": "backend/server.js"
},
{
"src": "/(.*)",
"dest": "frontend/dist/$1"
}
]
}This configuration:
- Builds frontend from
frontend/package.jsonusing Vite - Serves backend API from
backend/server.js - Routes
/api/*requests to backend - Routes all other requests to frontend
- All code is committed to GitHub
- No sensitive data in code (API keys, etc.)
- Environment variables are properly configured
- Frontend API URL is set to relative path or environment variable
- Backend CORS is configured for production
Create these in Vercel dashboard after deployment:
Frontend Environment Variables:
VITE_API_URL=https://your-vercel-domain.vercel.app/api
Backend Environment Variables:
NODE_ENV=production
FRONTEND_URL=https://your-vercel-domain.vercel.app
Your frontend currently uses http://localhost:3000/api as fallback. For production, update frontend/src/hooks/useChat.js:
// Change this line:
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api';
// To this (for production):
const API_BASE_URL = import.meta.env.VITE_API_URL || '/api';Your backend CORS is already configured to use environment variables, which is perfect.
-
Ensure all code is committed:
git add . git commit -m "feat: prepare for Vercel deployment" git push origin main
-
Verify your repository is public (required for Vercel free tier)
- Go to vercel.com
- Sign up with your GitHub account
- Complete email verification
-
Import Project:
- Click "New Project" in Vercel dashboard
- Select "Import Git Repository"
- Choose your
ai-chat-interfacerepository - Click "Import"
-
Configure Project Settings:
- Framework Preset: Select "Other" (since it's a monorepo)
- Root Directory: Leave as
/(root) - Build Command: Leave empty (Vercel will use your
vercel.json) - Output Directory: Leave empty (Vercel will use your
vercel.json) - Install Command:
npm run install:all
-
Set Environment Variables:
- Click "Environment Variables" section
- Add the following variables:
VITE_API_URL = https://your-project-name.vercel.app/api NODE_ENV = production FRONTEND_URL = https://your-project-name.vercel.app
-
Deploy:
- Click "Deploy"
- Wait for build to complete (usually 2-3 minutes)
-
Install Vercel CLI:
npm i -g vercel
-
Login to Vercel:
vercel login
-
Deploy:
vercel
-
Follow prompts:
- Link to existing project or create new
- Confirm settings
- Set environment variables when prompted
After deployment, update the VITE_API_URL with your actual domain:
- Go to your Vercel project dashboard
- Navigate to "Settings" → "Environment Variables"
- Update
VITE_API_URLto your actual domain:VITE_API_URL = https://your-actual-domain.vercel.app/api - Redeploy the project
-
Test Frontend:
- Visit your Vercel URL
- Verify the chat interface loads
- Test responsive design
-
Test Backend:
- Visit
https://your-domain.vercel.app/api/chat - Should return a 404 or error (not a connection error)
- Visit
-
Test Demo Mode:
- Enable demo mode in settings
- Send a test message
- Verify demo response works
-
Test API Integration:
- Enter a valid OpenAI API key
- Send a test message
- Verify real API integration works
- Domain: Your project will get a
.vercel.appdomain - Custom Domain: Optional - you can add a custom domain later
- Team: Ensure you're in the correct team/account
Navigate to Settings → Environment Variables and add:
| Name | Value | Environment |
|---|---|---|
VITE_API_URL |
https://your-domain.vercel.app/api |
Production |
NODE_ENV |
production |
Production |
FRONTEND_URL |
https://your-domain.vercel.app |
Production |
- Framework Preset: Other
- Build Command: (leave empty - uses vercel.json)
- Output Directory: (leave empty - uses vercel.json)
- Install Command:
npm run install:all
- Node.js Version: 18.x (recommended)
- Max Duration: 10 seconds (default)
- Memory: 1024 MB (default)
- Password Protection: Disabled (for public access)
- CORS: Already configured in your backend
- Frontend loads without errors
- Responsive design works on mobile
- Settings panel opens and closes
- Demo mode toggle works
- API key input accepts valid keys
- Demo mode sends responses
- Real API mode works with valid key
- Error handling displays properly
- Message history persists during session
- Clear chat functionality works
-
/api/chatresponds correctly -
/api/validate-keyvalidates keys - Rate limiting works
- CORS headers are present
- Security headers are set
- Page loads within 3 seconds
- API responses are under 5 seconds
- No console errors
- Mobile performance is acceptable
Problem: Build fails during deployment Solution:
- Check build logs in Vercel dashboard
- Ensure all dependencies are in
package.json - Verify
npm run install:allworks locally
Problem: Frontend can't connect to backend Solution:
- Verify
VITE_API_URLenvironment variable is set correctly - Check that backend routes are working
- Ensure CORS is configured properly
Problem: Environment variables not accessible Solution:
- Redeploy after setting environment variables
- Check variable names match exactly
- Verify environment (Production/Preview) is correct
Problem: Browser shows CORS errors Solution:
- Verify
FRONTEND_URLenvironment variable is set - Check backend CORS configuration
- Ensure frontend and backend are on same domain
- Two dynamic aspects (Chat + Settings)
- Responsive design
- Frontend-backend communication
- Working application (not mockups)
- Demo mode for evaluation
- GitHub repository
- Documentation
- Live demo capability
- Demo mode for evaluators
- Responsive design showcase
- Security measures explanation
- Architecture overview
- Update README.md with deployment URL
- Add deployment instructions
- Document environment variables
- Create user guide
- Run all tests in production environment
- Verify demo mode works for evaluators
- Test error scenarios
- Check responsive design on various devices
- Prepare live demo script
- Document security measures
- Create architecture slides
- Record demo video
- Enable Vercel Analytics
- Set up error tracking
- Monitor API usage
- Track performance metrics
- Vercel Support: support.vercel.com
- GitHub Issues: Use your repository's issue tracker
- Project Documentation: Check
docs/directory
Note: This deployment guide is specifically tailored for your AI Chat Interface project and assumes monorepo deployment. For separate frontend/backend deployments, refer to Vercel's official documentation for more complex setups.