# Pre-Deployment Checklist

## Before You Start

### InMotion VPS Requirements
- [ ] VPS plan: VPS-1000HA or higher recommended
- [ ] Operating System: Ubuntu 22.04 LTS
- [ ] Minimum RAM: 2GB (4GB recommended)
- [ ] Minimum Storage: 40GB
- [ ] Root or sudo access
- [ ] Domain name configured and pointing to VPS IP

### Local Preparation
- [ ] Repository is up to date on GitHub
- [ ] All tests passing locally
- [ ] Environment variables documented
- [ ] Database backup strategy planned
- [ ] SSL certificate plan (Let's Encrypt)

## Information You'll Need

### 1. Server Access
```
VPS IP Address: ___________________
SSH Username: ___________________
SSH Password/Key: ___________________
```

### 2. Domain Configuration
```
Primary Domain: ___________________
WWW Subdomain: ___________________
DNS A Record pointing to VPS IP: [ ] Configured
```

### 3. MongoDB Credentials (Generate Strong Passwords)
```
Admin Username: annaadmin
Admin Password: ___________________ (min 16 chars)

App Username: annaapp
App Password: ___________________ (min 16 chars)
```

### 4. Application Secrets
```
JWT_SECRET: ___________________ (64 chars - generate with script)
```

### 5. Email Configuration (Optional)
```
SMTP Host: ___________________
SMTP Port: ___________________
Email User: ___________________
Email Password: ___________________
```

## Deployment Timeline

### Phase 1: Server Setup (30 minutes)
- [ ] Connect to VPS via SSH
- [ ] Run automated deployment script
- [ ] Verify all services installed

### Phase 2: Configuration (20 minutes)
- [ ] Configure MongoDB authentication
- [ ] Set up environment variables
- [ ] Generate JWT secret
- [ ] Configure Nginx

### Phase 3: Application Deployment (15 minutes)
- [ ] Start application with PM2
- [ ] Configure PM2 startup
- [ ] Test application locally

### Phase 4: SSL & Security (15 minutes)
- [ ] Install SSL certificate
- [ ] Configure firewall
- [ ] Test HTTPS access

### Phase 5: Verification (10 minutes)
- [ ] Test all endpoints
- [ ] Change default admin password
- [ ] Verify database connection
- [ ] Check logs for errors

### Phase 6: Monitoring Setup (10 minutes)
- [ ] Configure log rotation
- [ ] Set up automated backups
- [ ] Configure monitoring alerts

**Total Estimated Time: 90 minutes**

## Quick Start Commands

### 1. Connect to Server
```bash
ssh root@YOUR_VPS_IP
```

### 2. Run Deployment Script
```bash
wget https://raw.githubusercontent.com/nsanthosh718/anna-stockroom-enterprise/main/scripts/deploy-inmotion.sh
chmod +x deploy-inmotion.sh
sudo ./deploy-inmotion.sh
```

### 3. Generate JWT Secret
```bash
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
```

### 4. Configure Environment
```bash
cd /var/www/anna-stockroom
nano .env
```

### 5. Start Application
```bash
pm2 start ecosystem.config.js --env production
pm2 save
pm2 startup
```

## Post-Deployment Verification

### Test Checklist
- [ ] Application accessible via domain
- [ ] HTTPS working (SSL certificate)
- [ ] Login functionality working
- [ ] Database operations working
- [ ] File uploads working
- [ ] API endpoints responding
- [ ] No errors in logs

### Security Verification
- [ ] Firewall active and configured
- [ ] MongoDB authentication enabled
- [ ] Strong passwords set
- [ ] SSL certificate valid
- [ ] Default admin password changed
- [ ] Rate limiting working

### Performance Check
- [ ] Page load time < 3 seconds
- [ ] API response time < 500ms
- [ ] No memory leaks
- [ ] CPU usage normal
- [ ] Disk space adequate

## Rollback Plan

If deployment fails:

1. **Stop Application**
   ```bash
   pm2 stop anna-stockroom
   ```

2. **Check Logs**
   ```bash
   pm2 logs anna-stockroom --lines 100
   sudo tail -f /var/log/nginx/anna-stockroom-error.log
   ```

3. **Restore Previous Version**
   ```bash
   cd /var/www/anna-stockroom
   git log --oneline -10
   git checkout PREVIOUS_COMMIT_HASH
   npm install --production
   pm2 restart anna-stockroom
   ```

4. **Restore Database** (if needed)
   ```bash
   mongorestore --uri="mongodb://annaapp:PASSWORD@localhost:27017/anna_stockroom?authSource=anna_stockroom" /var/backups/mongodb/BACKUP_DIR
   ```

## Support Contacts

- **Technical Issues**: support@annallc.com
- **InMotion Support**: https://www.inmotionhosting.com/support
- **Documentation**: See INMOTION_DEPLOYMENT.md

## Notes

- Keep this checklist handy during deployment
- Document any deviations from the plan
- Save all passwords in a secure password manager
- Take screenshots of successful steps
- Keep deployment logs for reference

---

**Ready to Deploy?** Follow the detailed guide in `INMOTION_DEPLOYMENT.md`
