- Python 3.10+
- Node.js 25+
- PostgreSQL database (or Neon cloud database)
- API Keys:
- OpenAI API key
- ElevenLabs API key
- Groq API key (optional)
- Create and activate virtual environment:
cd /Users/david/GitHub/pad
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
cd vera-api
pip install -r requirements.txt- Configure environment variables:
Create
.envfile in project root:
DATABASE_URL=postgresql://user:password@localhost/vera
SECRET_KEY=your-secret-key-min-32-chars
OPENAI_API_KEY=sk-...
GROQ_API_KEY=gsk_...
ELEVENLABS_API_KEY=sk_...
ADMIN_PASSWORD=your-admin-password
CORS_ORIGINS=http://localhost:3000- Run database migrations:
alembic upgrade head- Seed research IDs (optional):
python scripts/seed_research_ids.py- Start backend server:
uvicorn app.main:app --reload --port 8000Backend available at: http://localhost:8000
- API docs: http://localhost:8000/docs
- Health check: http://localhost:8000/health
- Install dependencies:
cd vera-frontend
npm install- Configure environment variables:
Create
.env.localfile:
NEXT_PUBLIC_API_URL=http://localhost:8000/api/v1
NEXT_PUBLIC_WS_URL=ws://localhost:8000/api/v1/chat/ws/chat- Start development server:
npm run devFrontend available at: http://localhost:3000
- Open browser to http://localhost:3000
- Enter research ID (e.g., RID001-RID010 if seeded)
- Accept disclaimer
- Start chatting with VERA
- Audio should play automatically after first interaction
Troubleshooting:
- Check browser console for errors (F12)
- Check backend logs for TTS generation
- Verify WebSocket connection in Network tab
- Ensure microphone permissions granted for voice input
Vercel (Frontend) ←→ Railway (Backend) ←→ Neon (Database)
↓
ElevenLabs (TTS)
OpenAI (LLM)
-
Create Railway project:
- Go to railway.app
- Click "New Project"
- Select "Deploy from GitHub repo"
- Choose
vera-apirepository - Set Root Directory to
vera-api
-
Configure environment variables: Go to Variables tab and add:
DATABASE_URL=postgresql://neondb_owner:xxx@ep-xxx.aws.neon.tech/neondb?sslmode=require SECRET_KEY=YOUR_SECRET_KEY_MIN_32_CHARS_HERE OPENAI_API_KEY=sk-proj-xxx GROQ_API_KEY=gsk_xxx ELEVENLABS_API_KEY=sk_YOUR_ELEVENLABS_API_KEY_HERE ADMIN_PASSWORD=your-admin-password CORS_ORIGINS=https://your-frontend.vercel.app RAILWAY_ENVIRONMENT=production -
Configure deployment:
- Railway should auto-detect Python
- Start command (in railway.toml):
uvicorn app.main:app --host 0.0.0.0 --port $PORT - Health check path:
/health
-
Get Railway URL:
- After deployment, copy the public URL
- Example:
https://vera-api-production.up.railway.app - Note this URL for frontend configuration
Method 1: Git Push (Automatic)
git add .
git commit -m "Update backend"
git push origin mainRailway auto-deploys on push to main branch.
Method 2: Manual Redeploy
- Go to Railway dashboard
- Click "Deploy" → "Redeploy"
View Logs:
- Railway dashboard → Deployments → View Logs
- Check for startup errors and TTS generation logs
-
Create Vercel project:
- Go to vercel.com
- Click "New Project"
- Import from GitHub
- Select
vera-frontendrepository - Root Directory:
vera-frontend - Framework: Next.js (auto-detected)
-
Configure environment variables: Go to Settings → Environment Variables and add:
NEXT_PUBLIC_API_URL=https://vera-api-production.up.railway.app/api/v1 NEXT_PUBLIC_WS_URL=wss://vera-api-production.up.railway.app/api/v1/chat/ws/chatImportant:
- Use
https://for API_URL - Use
wss://(WebSocket Secure) for WS_URL - Replace with your actual Railway URL
- Use
-
Deploy:
- Click "Deploy"
- Wait for build to complete
-
Get Vercel URL:
- Copy the production URL
- Example:
https://vera-frontend.vercel.app - Add this URL to Railway CORS_ORIGINS
Method 1: Git Push (Automatic)
git add .
git commit -m "Update frontend"
git push origin mainVercel auto-deploys on push to main branch.
Method 2: Manual Redeploy
- Go to Vercel dashboard
- Select deployment → Click "Redeploy"
View Logs:
- Vercel dashboard → Deployments → View Function Logs
- Check for build errors
- Get your Vercel production URL
- Go to Railway → Variables
- Update
CORS_ORIGINS:CORS_ORIGINS=https://your-frontend.vercel.app - Redeploy backend
- Get your Railway production URL
- Go to Vercel → Settings → Environment Variables
- Update both variables:
NEXT_PUBLIC_API_URL=https://your-backend.up.railway.app/api/v1 NEXT_PUBLIC_WS_URL=wss://your-backend.up.railway.app/api/v1/chat/ws/chat - Redeploy frontend
- Visit
https://your-backend.up.railway.app/health - Should return:
{"status": "healthy"}
- Visit
https://your-frontend.vercel.app - Page should load without errors
- Open DevTools Console (F12)
- Should see "WebSocket connected successfully"
- Enter valid research ID
- Accept disclaimer
- Should reach chat interface
- Send a test message
- VERA should respond with streaming text
- Check console for "Generating TTS for response" (backend logs)
- Check console for "Received audio message" (frontend)
- Send message (triggers audio unlock)
- Check console for "Audio enabled successfully"
- Wait for VERA response
- Audio should play automatically
- Test 2-3 more messages to verify consistency
- Open DevTools → Network tab
- Filter by "WS" (WebSocket)
- Should see connection with Status 101
- Click on connection → Messages
- Should see message flow
Symptoms:
- Text appears but no audio plays
- Console shows "Audio playback failed"
Debug Steps:
-
Check environment variables:
# Vercel vercel env ls # Railway (via dashboard or CLI) railway variables
-
Check WebSocket connection:
- Open DevTools → Network → WS
- Verify connection established (Status 101)
- Check message flow for
type: "audio"
-
Check backend logs:
# Railway logs railway logs # Look for: # ✅ "Generating TTS for response" # ✅ "TTS generated successfully" # ❌ "TTS generation failed"
-
Check browser console:
✅ "WebSocket connected successfully" ✅ "Audio enabled successfully" ✅ "Received audio message: Audio data present" ❌ "Audio playback failed" ❌ "NotAllowedError: play() failed" -
Common fixes:
- Verify
ELEVENLABS_API_KEYset in Railway - Verify
NEXT_PUBLIC_WS_URLuseswss://notws:// - Verify CORS_ORIGINS includes Vercel URL
- Clear browser cache and cookies
- Try different browser (Chrome recommended)
- Ensure user interacted with page first (click or type)
- Verify
Symptoms:
- Console: "Access to XMLHttpRequest has been blocked by CORS policy"
- Console: "WebSocket connection failed"
Fix:
- Check
CORS_ORIGINSin Railway includes exact Vercel URL - No trailing slash:
https://app.vercel.appnothttps://app.vercel.app/ - Include protocol:
https://not justapp.vercel.app - Redeploy backend after updating
Symptoms:
- "WebSocket disconnected" repeatedly
- Network tab shows failed WS connection
Fix:
- Verify
NEXT_PUBLIC_WS_URLuseswss://(notws://) - Verify Railway backend is running (check health endpoint)
- Check Railway logs for WebSocket errors
- Verify no firewall/proxy blocking WebSocket
Backend (Railway):
# Check requirements.txt has all dependencies
pip freeze > requirements.txt
# Verify Python version in runtime.txt (if used)
python-3.11.0Frontend (Vercel):
# Check package.json and package-lock.json in sync
npm install
# Test build locally
npm run build
# Check Next.js version compatibility
npm ls next- Backend health endpoint responding
- Database connection working
- ElevenLabs API quota and usage
- OpenAI API quota and usage
- Error logs in Railway
- Build logs in Vercel
- Railway: Check usage and billing
- Vercel: Check bandwidth and function invocations
- Neon: Check database storage and connections
- ElevenLabs: Check character usage (charged per character)
- OpenAI: Check token usage
- Rotate API keys quarterly
- Review CORS origins
- Check for dependency updates
- Review access logs for suspicious activity
- Ensure SECRET_KEY not exposed
# Backend
cd vera-api
source ../.venv/bin/activate
uvicorn app.main:app --reload
# Frontend
cd vera-frontend
npm run dev
# Database
alembic upgrade head # Run migrations
alembic revision --autogenerate -m "message" # Create migration
# Testing
pytest # Backend tests
npm test # Frontend tests# View Railway logs
railway logs --follow
# View Vercel logs
vercel logs [deployment-url]
# Redeploy
git push origin main # Auto-deploys both platforms
# Force redeploy
vercel --prod # Frontend
railway up # Backend- Railway: https://railway.app/dashboard
- Vercel: https://vercel.com/dashboard
- Neon: https://console.neon.tech/
- ElevenLabs: https://elevenlabs.io/app
- OpenAI: https://platform.openai.com/
- Check browser console for errors
- Check Railway logs for backend errors
- Review plan.md for troubleshooting
- Check decisions.md for architecture context
- Audio requires first user interaction (browser policy - expected)
- Safari may have stricter autoplay policies than Chrome
- WebSocket connection requires
wss://in production
- Project repository: [GitHub link]
- Documentation: This repo's markdown files