Deployment Guide
This guide covers multiple deployment strategies for the Pet Service Management System.Docker
Containerized deployment
Railway
One-click deployment with Railway MCP
Cloud Platforms
AWS, GCP, Vercel
Docker Deployment
Prerequisites
- Docker 20.10+
- Docker Compose 2.0+
Step 1: Build Docker Images
Create aDockerfile in the root directory:
Step 2: Docker Compose Configuration
Createdocker-compose.yml in the root directory:
docker-compose.yml
Step 3: Environment Configuration
Create.env file in the root directory:
.env
Step 4: Build and Run
1
Build Images
2
Start Services
3
Verify Services
4
Access Application
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:3001 - Prisma Studio:
docker-compose exec backend npx prisma studio
Docker Management Commands
Railway Deployment
Railway provides automatic deployments with built-in PostgreSQL and zero-config setup.
Option 1: Deploy via Railway CLI
1
Install Railway CLI
2
Login to Railway
3
Initialize Project
4
Add PostgreSQL Database
DATABASE_URL environment variable.5
Set Environment Variables
6
Deploy Backend
7
Deploy Frontend
8
Run Migrations
Option 2: Deploy via Railway Button
Deploy to Railway
Click to deploy with one button
- Click “Deploy on Railway” button
- Connect your GitHub repository
- Railway auto-detects backend/frontend
- Add PostgreSQL database from Railway marketplace
- Set environment variables in Railway dashboard
- Deploy automatically on git push
Railway Environment Variables
Set these in Railway dashboard or CLI:| Variable | Value | Notes |
|---|---|---|
NODE_ENV | production | Environment mode |
DATABASE_URL | Auto-set by Railway | PostgreSQL connection |
BETTER_AUTH_SECRET | Generate 32+ chars | Auth secret |
SESSION_SECRET | Generate 32+ chars | Session encryption |
JWT_SECRET | Generate 32+ chars | JWT signing |
FRONTEND_URL | https://your-app.railway.app | Frontend URL |
PORT | 3001 (backend) | Service port |
Railway MCP Integration
Railway MCP (Model Context Protocol) enables AI assistants to manage your deployments.
- Install Railway MCP server:
- Configure in your Claude Code settings:
- Use AI commands:
Cloud Platform Deployment
Vercel (Frontend)
1
Install Vercel CLI
2
Deploy Frontend
3
Set Environment Variables
4
Production Deployment
Heroku (Backend)
1
Install Heroku CLI
2
Create Heroku App
3
Add PostgreSQL
4
Set Environment Variables
5
Deploy
6
Run Migrations
AWS (Full Stack)
- Frontend on S3 + CloudFront
- Backend on EC2
- Database on RDS
Production Checklist
Security
Security
- HTTPS/TLS enabled (use Let’s Encrypt or cloud provider SSL)
- Strong secrets (32+ characters, randomly generated)
- Environment variables properly set (no hardcoded secrets)
- CORS configured for specific origins
- Rate limiting enabled on API endpoints
- Database backups configured (daily/hourly)
- Security headers configured (Helmet.js)
Performance
Performance
- CDN configured for static assets
- Database connection pooling enabled
- Query optimization with proper indexes
- Caching strategy implemented (Redis optional)
- Image optimization enabled
- Gzip compression enabled
Monitoring
Monitoring
- Application logging configured
- Error tracking (Sentry, LogRocket)
- Uptime monitoring (UptimeRobot, Pingdom)
- Performance monitoring (New Relic, DataDog)
- Database monitoring (pgAdmin, Railway analytics)
Database
Database
- Production database created
- Migrations applied:
npx prisma migrate deploy - Seed data loaded (if needed)
- Backup strategy configured
- Connection pool configured
- Indexes optimized
Environment
Environment
-
NODE_ENV=productionset - All required environment variables configured
- Frontend API URL points to production backend
- Backend CORS allows production frontend
- Email service configured (SMTP credentials)
Continuous Deployment
GitHub Actions
Create.github/workflows/deploy.yml:
Monitoring & Maintenance
Health Checks
View Logs
- Docker
- Railway
- Heroku
Database Backup
Troubleshooting
Deployment Fails
Deployment Fails
Solution:
- Check build logs:
railway logsordocker-compose logs - Verify environment variables are set
- Ensure dependencies are installed:
npm ci - Check Dockerfile syntax
Database Connection Error
Database Connection Error
Solution:
- Verify
DATABASE_URLis correct - Check database is running
- Confirm firewall rules allow connection
- Test connection:
psql $DATABASE_URL
CORS Errors
CORS Errors
Solution:
- Set
FRONTEND_URLin backend environment - Verify CORS configuration in
main.ts - Check frontend uses correct API URL
SSL/HTTPS Issues
SSL/HTTPS Issues
Solution:
- Use Railway/Vercel automatic SSL
- For custom domains, configure SSL certificate
- Use Let’s Encrypt for free SSL:
certbot
Next Steps
Architecture Overview
Understand system design
API Reference
Explore REST endpoints
Installation Guide
Set up development environment
Back to Home
Return to homepage
Deployment Complete! Your Pet Service Management System is now live.