# Production Deployment Checklist

Use this checklist to ensure all deployment steps are completed successfully.

## Pre-Deployment

- [ ] VPS/Server purchased and accessible via SSH
- [ ] Domain name registered and ready
- [ ] DNS access available (for A records)
- [ ] SSL email address for Let's Encrypt
- [ ] Database password chosen (strong password)
- [ ] Server IP address noted: `_________________`
- [ ] Domain name confirmed: `_________________`

---

## Phase 1: Server Setup (30 minutes)

- [ ] SSH into server as root
- [ ] Create `deploy` user
- [ ] Update system packages
- [ ] Configure firewall (UFW)
- [ ] Set correct timezone

**Verification:** `sudo ufw status` shows ports 22, 80, 443 open

---

## Phase 2: Install Software (45 minutes)

- [ ] PHP 8.2 installed
- [ ] MySQL 8.0 installed and secured
- [ ] Database created: `neosolvix_production`
- [ ] Database user created: `neosolvix`
- [ ] Redis installed and running
- [ ] Node.js 20.x installed
- [ ] PM2 installed globally
- [ ] Nginx installed
- [ ] Composer installed
- [ ] Supervisor installed

**Verification Commands:**
```bash
php -v  # 8.2.x
mysql --version  # 8.0.x
redis-cli ping  # PONG
node -v  # 20.x
nginx -v
composer --version
```

---

## Phase 3: Deploy Laravel (30 minutes)

- [ ] Created `/var/www/neosolvix` directory
- [ ] Code uploaded (Git or rsync)
- [ ] Composer dependencies installed
- [ ] `.env` file configured
- [ ] Application key generated
- [ ] Migrations run successfully
- [ ] Warming schedules seeded
- [ ] Laravel caches cleared and regenerated
- [ ] Permissions set correctly (755/775)

**Verification:** `php artisan migrate:status` shows all migrations run

---

## Phase 4: Deploy WhatsApp Service (15 minutes)

- [ ] Node dependencies installed
- [ ] `.env` file configured
- [ ] Sessions directory created
- [ ] Service starts without errors

**Verification:** `npm start` runs without errors (then Ctrl+C)

---

## Phase 5: Configure Nginx (20 minutes)

- [ ] Site configuration created
- [ ] Configuration syntax tested (`nginx -t`)
- [ ] Site enabled
- [ ] Nginx reloaded
- [ ] DNS A records created:
  - [ ] `your-domain.com` → server IP
  - [ ] `www.your-domain.com` → server IP
  - [ ] `whatsapp.your-domain.com` → server IP
- [ ] DNS propagation confirmed (5-10 min wait)

**Verification:** `curl http://your-domain.com` returns HTML

---

## Phase 6: SSL/HTTPS (15 minutes)

- [ ] Certbot installed
- [ ] SSL certificate obtained for main domain
- [ ] SSL certificate obtained for WhatsApp subdomain
- [ ] Auto-renewal tested
- [ ] `.env` files updated to HTTPS URLs
- [ ] Laravel cache cleared

**Verification:** `https://your-domain.com` loads with green padlock

---

## Phase 7: Process Management (20 minutes)

### PM2 for WhatsApp Service
- [ ] `ecosystem.config.js` copied to whatsapp-service/
- [ ] PM2 service started
- [ ] PM2 saved
- [ ] PM2 startup configured

**Verification:** `pm2 list` shows whatsapp-service running

### Supervisor for Queue Worker
- [ ] `supervisor-worker.conf` copied to `/etc/supervisor/conf.d/`
- [ ] Supervisor reloaded
- [ ] Worker started
- [ ] Worker status checked

**Verification:** `sudo supervisorctl status` shows neosolvix-worker RUNNING

### Cron for Scheduler
- [ ] Crontab edited (`crontab -e`)
- [ ] Scheduler command added
- [ ] Cron entry saved

**Verification:** `crontab -l` shows scheduler command

---

## Phase 8: Security (15 minutes)

- [ ] PHP version hidden
- [ ] Fail2Ban installed (optional)
- [ ] MySQL secured (test users removed)
- [ ] Root SSH login disabled
- [ ] SSH key authentication enabled (recommended)

**Verification:** `curl -I https://your-domain.com` doesn't show PHP version

---

## Phase 9: Monitoring & Backups (20 minutes)

- [ ] Log rotation configured
- [ ] Backup script created (`/usr/local/bin/neosolvix-backup.sh`)
- [ ] Backup script executable
- [ ] Backup cron job scheduled (daily 2 AM)
- [ ] Test backup run manually
- [ ] Backup directory verified (`/var/backups/neosolvix`)

**Verification:** `sudo /usr/local/bin/neosolvix-backup.sh` completes successfully

---

## Phase 10: Testing (30 minutes)

### Service Tests
- [ ] Laravel responds: `curl -I https://your-domain.com` → 200 OK
- [ ] WhatsApp service responds: `curl https://whatsapp.your-domain.com/health` → {"status":"ok"}
- [ ] Queue worker running: `sudo supervisorctl status` → RUNNING
- [ ] PM2 process running: `pm2 list` → online
- [ ] Scheduler listed: `php artisan schedule:list` → shows commands

### Functional Tests
- [ ] Can access website in browser
- [ ] Can login to admin panel
- [ ] Can navigate to WhatsApp module
- [ ] Can see "Connect Account" page
- [ ] QR code loads when creating account
- [ ] Can scan QR code with phone
- [ ] Account connects successfully
- [ ] Can import contacts
- [ ] Can create campaign
- [ ] Can launch campaign
- [ ] Queue processes jobs
- [ ] Messages sent successfully
- [ ] Dashboard stats update

---

## Post-Deployment (Immediate)

- [ ] Document server credentials (securely)
- [ ] Document database credentials (securely)
- [ ] Set up monitoring alerts (optional)
- [ ] Configure email notifications (optional)
- [ ] Share access with team (if applicable)
- [ ] Create admin user accounts
- [ ] Import initial contacts (if any)
- [ ] Test disaster recovery (restore from backup)

---

## Post-Deployment (Within 24 hours)

- [ ] Monitor logs for errors
- [ ] Check disk space usage
- [ ] Verify backups created automatically
- [ ] Test queue worker handling failures
- [ ] Monitor WhatsApp connection stability
- [ ] Check SSL certificate auto-renewal schedule
- [ ] Review server resource usage (CPU, RAM)
- [ ] Set up uptime monitoring (optional - UptimeRobot, Pingdom)

---

## Maintenance Schedule

### Daily
- [ ] Check service status (pm2, supervisor)
- [ ] Review error logs
- [ ] Monitor disk space

### Weekly
- [ ] Review backup logs
- [ ] Check failed queue jobs
- [ ] Review WhatsApp account health

### Monthly
- [ ] Update system packages
- [ ] Review and rotate old logs
- [ ] Test backup restoration
- [ ] Review security updates

---

## Emergency Contacts

**Hosting Provider Support:**
- Provider: `_________________`
- Support Email: `_________________`
- Support Phone: `_________________`

**Domain Registrar:**
- Registrar: `_________________`
- Support: `_________________`

**Technical Contacts:**
- Developer: `_________________`
- System Admin: `_________________`

---

## Quick Reference Commands

```bash
# Restart all services
sudo systemctl restart nginx php8.2-fpm mysql redis-server
sudo supervisorctl restart all
pm2 restart all

# Check all service status
sudo systemctl status nginx php8.2-fpm mysql redis-server
sudo supervisorctl status
pm2 status

# View logs
tail -f /var/www/neosolvix/storage/logs/laravel.log
pm2 logs whatsapp-service
sudo supervisorctl tail neosolvix-worker
tail -f /var/log/nginx/neosolvix-error.log

# Run backup manually
sudo /usr/local/bin/neosolvix-backup.sh

# Update application
cd /var/www/neosolvix
git pull
composer install --no-dev
php artisan migrate --force
php artisan config:cache
sudo supervisorctl restart neosolvix-worker
```

---

## Deployment Complete! 🎉

**Total Time:** ~4-5 hours (first time), ~2-3 hours (experienced)

**What You Now Have:**
- ✅ Production WhatsApp marketing platform
- ✅ HTTPS/SSL secured
- ✅ Automated backups
- ✅ Process monitoring
- ✅ Queue workers
- ✅ Security hardened
- ✅ Ready for customers

**Next Steps:**
1. Import your contact list
2. Create your first campaign
3. Monitor performance
4. Scale as needed

**Need Help?**
- Check `PRODUCTION_DEPLOYMENT_GUIDE.md` for detailed steps
- Check `WHATSAPP_TESTING_GUIDE.md` for testing procedures
- Check `TROUBLESHOOTING.md` for common issues

---

**Deployment Date:** `_________________`

**Deployed By:** `_________________`

**Server IP:** `_________________`

**Domain:** `_________________`

**Notes:**
```
_______________________________________________________________________

_______________________________________________________________________

_______________________________________________________________________
```
