Complete guide for deploying CodeIntel to production and local development.
- Docker Desktop installed
.envfile configured (copy from.env.example)
# Clone and navigate to project
cd pebble
# Copy environment file
cp backend/.env.example backend/.env
# Edit backend/.env with your actual API keys
# Build and start all services
docker compose up -d
# View logs
docker compose logs -f backend
# Stop all services
docker compose down- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Redis: localhost:6379
# Rebuild after code changes
docker compose up -d --build backend
# View specific service logs
docker compose logs -f backend
docker compose logs -f frontend
docker compose logs -f redis
# Execute commands in containers
docker compose exec backend python -c "print('Hello')"
docker compose exec redis redis-cli ping
# Stop and remove volumes (clean slate)
docker compose down -v- Sign up at railway.app
- Install Railway CLI:
npm i -g @railway/cli - Login:
railway login
# Initialize Railway project
railway init
# Link to existing project (if you created one in dashboard)
railway link# Deploy from root directory
railway up
# OR use dashboard:
# 1. Connect GitHub repo
# 2. Select "Backend" service
# 3. Set root directory to "./backend"
# 4. Railway auto-detects DockerfileIn Railway dashboard:
- Click "New" β "Database" β "Add Redis"
- Railway automatically sets
REDIS_URLenvironment variable - Update backend to use
REDIS_URLif provided:
# In services/cache.py
import os
redis_url = os.getenv("REDIS_URL")
if redis_url:
redis_client = redis.from_url(redis_url)
else:
redis_client = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)Set these in Railway dashboard for Backend service:
OPENAI_API_KEY=sk-...
PINECONE_API_KEY=...
PINECONE_INDEX_NAME=codeintel
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=eyJ...
API_KEY=production-secret-key-change-this
BACKEND_API_URL=https://your-backend.railway.app
- Railway Dashboard β Backend Service β Settings
- Generate domain or add custom domain
- Update CORS in
backend/main.pyto allow your frontend domain
npm i -g vercelcd frontend
# Deploy to Vercel
vercel
# Production deployment
vercel --prodSet in Vercel project settings:
VITE_API_URL=https://your-backend.railway.app
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm ci
Update backend/main.py with your frontend URL:
app.add_middleware(
CORSMiddleware,
allow_origins=[
"https://your-frontend.vercel.app",
"http://localhost:3000" # Keep for local dev
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)Ensure /health endpoint exists (already implemented):
@app.get("/health")
async def health():
return {"status": "healthy", "timestamp": datetime.now().isoformat()}# View logs in terminal
railway logs
# Or use dashboard
# Railway β Backend Service β Deployments β View Logs# View logs
vercel logs
# Or use dashboard
# Vercel β Project β Deployments β Logs# Connect to Railway Redis
railway run redis-cli
# Monitor commands
MONITOR
# Check memory usage
INFO memory
# View all keys
KEYS *Solution: Ensure REDIS_URL is set in Railway or Docker:
# Railway automatically sets this
# For Docker, use docker-compose networking:
REDIS_HOST=redis
REDIS_PORT=6379Solution:
- Check
VITE_API_URLin frontend environment - Verify CORS settings in backend
- Check Railway backend is actually running
Solution:
- Check Dockerfile path in
railway.json - Verify all dependencies in
requirements.txt - Check Railway build logs for specific error
Solution:
# Change ports in docker-compose.yml
ports:
- "3001:80" # Frontend
- "8001:8000" # BackendBefore going live:
- Change
API_KEYfrom default value - Set up Supabase RLS policies
- Configure rate limiting thresholds
- Set up monitoring (Railway built-in + Sentry/LogRocket)
- Add custom domain to Railway backend
- Add custom domain to Vercel frontend
- Test all endpoints with production data
- Set up backup strategy for Redis data
- Configure WAF/DDoS protection (Cloudflare)
- Set up SSL certificates (auto with Railway/Vercel)
- Automatic scaling based on traffic
- Upgrade plan for more resources
- Add replicas in dashboard
- Automatic CDN distribution
- Serverless edge functions
- Upgrade for more bandwidth
- Railway Redis Pro for persistence
- Consider Redis Cloud for production
- Enable AOF persistence for data durability
Free Tier (Hobby Projects)
- Railway: $5/month credit, backend + Redis
- Vercel: Free for personal projects
- Total: ~$0-5/month
Production (Paid)
- Railway Pro: $20/month (backend + Redis)
- Vercel Pro: $20/month (team features)
- OpenAI API: ~$10-50/month (depending on usage)
- Pinecone: $70/month (starter)
- Total: ~$120-160/month
-
Deploy Backend to Railway
railway login railway init railway up
-
Deploy Frontend to Vercel
cd frontend vercel --prod -
Test Everything
- Hit health endpoint
- Test search functionality
- Check Redis caching
- Monitor logs
-
Set up CI/CD
- Connect GitHub to Railway (auto-deploys)
- Connect GitHub to Vercel (auto-deploys)
- Both platforms support automatic deployments on push