# πŸš€ TurboTrades - Deployment Summary **Date:** January 10, 2026 **Status:** βœ… Ready for Deployment **Repository:** https://git.turbotrades.dev/iDefineHD/TurboTrades.git --- ## πŸ“‹ Configuration Overview ### Domain Setup - **Frontend:** https://turbotrades.dev - **Backend API:** https://api.turbotrades.dev - **WebSocket:** https://ws.turbotrades.dev ### Server Paths - **Backend Code:** `/root/ttbackend` - **Frontend Build:** `/var/www/html/turbotrades` - **Nginx Config:** Already configured βœ… - **SSL Certificates:** Already configured βœ… ### PM2 Configuration - **App Name:** `turbotrades-backend` - **Port:** 3000 - **Mode:** Cluster - **Auto-restart:** Enabled --- ## 🎯 Quick Start ### Deploy to Production ```bash # 1. SSH to server ssh root@turbotrades.dev # 2. Initial setup (first time only) cd /root/ttbackend git clone https://git.turbotrades.dev/iDefineHD/TurboTrades.git . # 3. Deploy ./deploy.sh ``` ### Push Changes from Local ```bash # Option 1: Use helper script ./push.sh # Option 2: Manual git add . git commit -m "Your changes" git push origin main # Then SSH and deploy ssh root@turbotrades.dev cd /root/ttbackend ./deploy.sh ``` --- ## πŸ“ Files Created for Deployment ### Deployment Scripts - βœ… `deploy.sh` - Main deployment script - βœ… `push.sh` - Quick commit and push helper - βœ… `ecosystem.config.js` - PM2 configuration (updated) ### Configuration - βœ… `nginx-config/turbotrades.conf` - Nginx configuration example - βœ… `.github/workflows/deploy.yml` - Gitea Actions workflow ### Documentation - βœ… `DEPLOY.md` - Simple deployment guide - βœ… `GITEA_DEPLOY.md` - Complete deployment documentation - βœ… `DEPLOY_SUMMARY.md` - This file --- ## πŸ”§ What Was Updated ### Repository Configuration - βœ… Git remote updated to Gitea: `https://git.turbotrades.dev/iDefineHD/TurboTrades.git` - βœ… All documentation updated with Gitea URLs - βœ… Removed all tunnel-related files and scripts ### Backend Configuration (`ecosystem.config.js`) ```javascript { name: "turbotrades-backend", cwd: "/root/ttbackend", env: { FRONTEND_URL: "https://turbotrades.dev", BACKEND_URL: "https://api.turbotrades.dev", WS_URL: "https://ws.turbotrades.dev" } } ``` ### Frontend Configuration - βœ… WebSocket connects to `wss://ws.turbotrades.dev` in production - βœ… API calls go to `https://api.turbotrades.dev` - βœ… Vite proxy configured for local development ### Deployment Workflow ``` Local Changes β†’ Git Push β†’ SSH to Server β†’ Run deploy.sh β†’ Live! πŸŽ‰ ``` --- ## πŸ“¦ deploy.sh Script Actions The deployment script automatically: 1. ⏸️ **Stops** backend (PM2) 2. πŸ’Ύ **Creates** backup of current version 3. πŸ“₯ **Pulls** latest code from Gitea 4. πŸ“¦ **Installs** backend dependencies (`npm ci --production`) 5. 🎨 **Builds** frontend (`npm run build`) 6. πŸš€ **Deploys** frontend to `/var/www/html/turbotrades` 7. πŸ”’ **Sets** proper permissions (www-data:www-data) 8. ▢️ **Restarts** backend with PM2 9. πŸ’Ύ **Saves** PM2 configuration 10. βœ… **Runs** health checks **Deployment Time:** ~2-3 minutes --- ## 🌐 Environment Variables Required Create `/root/ttbackend/.env` with: ```env # Application NODE_ENV=production PORT=3000 # URLs FRONTEND_URL=https://turbotrades.dev BACKEND_URL=https://api.turbotrades.dev WS_URL=https://ws.turbotrades.dev # Database MONGODB_URI=mongodb://localhost:27017/turbotrades # Security JWT_SECRET=your-super-secret-jwt-key REFRESH_TOKEN_SECRET=your-refresh-token-secret SESSION_SECRET=your-session-secret # Steam OAuth STEAM_API_KEY=your-steam-api-key STEAM_REALM=https://turbotrades.dev STEAM_RETURN_URL=https://api.turbotrades.dev/auth/steam/return # Email (optional) SMTP_HOST=smtp.example.com SMTP_PORT=587 SMTP_USER=your-email@example.com SMTP_PASS=your-password SMTP_FROM=noreply@turbotrades.dev ``` --- ## πŸ“Š Monitoring Commands ### PM2 Status ```bash pm2 list # List all processes pm2 logs turbotrades-backend # View logs pm2 monit # Monitor resources pm2 restart turbotrades-backend # Restart backend ``` ### Health Checks ```bash curl https://api.turbotrades.dev/api/health # Backend API curl https://turbotrades.dev # Frontend ``` ### Nginx Logs ```bash tail -f /var/log/nginx/turbotrades-error.log tail -f /var/log/nginx/api-turbotrades-error.log tail -f /var/log/nginx/ws-turbotrades-error.log ``` --- ## πŸ› Common Issues & Fixes ### Backend Won't Start ```bash pm2 logs turbotrades-backend # Check logs systemctl status mongod # Check MongoDB pm2 restart turbotrades-backend # Force restart ``` ### Frontend 404 ```bash ls -la /var/www/html/turbotrades/ # Check files exist chown -R www-data:www-data /var/www/html/turbotrades # Fix permissions ``` ### 502 Bad Gateway ```bash pm2 restart turbotrades-backend # Backend probably down netstat -tulpn | grep 3000 # Check if port 3000 is listening ``` ### WebSocket Won't Connect ```bash # Check WebSocket domain is correct in frontend # Should be: wss://ws.turbotrades.dev pm2 logs turbotrades-backend # Check backend logs ``` --- ## πŸ”„ Deployment Workflow Examples ### Regular Update ```bash # Local machine git add . git commit -m "Update feature X" git push origin main # Server ssh root@turbotrades.dev cd /root/ttbackend ./deploy.sh ``` ### Hotfix ```bash # Local machine git add . git commit -m "Hotfix: Critical bug" git push origin main # Server ssh root@turbotrades.dev cd /root/ttbackend ./deploy.sh ``` ### Frontend Only Update ```bash # Server ssh root@turbotrades.dev cd /root/ttbackend git pull origin main cd frontend && npm ci && npm run build rm -rf /var/www/html/turbotrades/* cp -r dist/* /var/www/html/turbotrades/ chown -R www-data:www-data /var/www/html/turbotrades ``` ### Backend Only Update ```bash # Server ssh root@turbotrades.dev cd /root/ttbackend git pull origin main npm ci --production pm2 restart turbotrades-backend ``` --- ## 🚨 Emergency Rollback ```bash ssh root@turbotrades.dev pm2 stop turbotrades-backend # List backups ls -lt /root/ | grep ttbackend-backup # Restore cd /root rm -rf ttbackend cp -r ttbackend-backup-YYYYMMDD-HHMMSS ttbackend cd ttbackend pm2 restart turbotrades-backend ``` --- ## βœ… Pre-Deployment Checklist - [x] Git remote configured to Gitea - [x] Tunnel infrastructure removed - [x] Deployment scripts created and executable - [x] PM2 ecosystem config updated - [x] Frontend WebSocket configured for production - [x] Nginx configuration ready - [x] Domain structure documented - [x] Server paths configured ### Before First Deployment - [ ] Server prerequisites installed (Node.js, PM2, MongoDB, Nginx) - [ ] Directories created (`/root/ttbackend`, `/var/www/html/turbotrades`) - [ ] Nginx configuration deployed - [ ] SSL certificates configured - [ ] `.env` file created with proper secrets - [ ] MongoDB running and accessible - [ ] Repository cloned to `/root/ttbackend` ### Before Each Deployment - [ ] Code tested locally - [ ] Environment variables updated if needed - [ ] Database migrations prepared (if any) - [ ] Team notified of deployment - [ ] Backup created (deploy.sh does this automatically) --- ## πŸŽ‰ Ready to Deploy! Everything is configured and ready. To deploy: ```bash # 1. Push your changes git add . git commit -m "Ready for production" git push origin main # 2. Deploy to server ssh root@turbotrades.dev cd /root/ttbackend git pull origin main ./deploy.sh ``` **Your site will be live at:** - 🌐 https://turbotrades.dev - πŸ”§ https://api.turbotrades.dev - πŸ’¬ https://ws.turbotrades.dev --- ## πŸ“š Documentation - **Quick Deploy:** `DEPLOY.md` - **Complete Guide:** `GITEA_DEPLOY.md` - **Nginx Config:** `nginx-config/turbotrades.conf` - **PM2 Config:** `ecosystem.config.js` --- ## πŸ†˜ Support If you encounter issues: 1. Check the logs: `pm2 logs turbotrades-backend` 2. Check nginx logs: `tail -f /var/log/nginx/api-turbotrades-error.log` 3. Review documentation in `DEPLOY.md` or `GITEA_DEPLOY.md` 4. Check health endpoints with curl --- **Last Updated:** January 10, 2026 **Status:** βœ… Ready for Production Deployment **Next Step:** SSH to server and run `./deploy.sh`