|
| 1 | +# 🚀 SmartHavenAI.com Deployment Guide |
| 2 | + |
| 3 | +Quick reference for deploying the Transcript Parser application to production. |
| 4 | + |
| 5 | +## Target Environment |
| 6 | + |
| 7 | +- **VPS**: Hostinger KVM 2 (72.62.86.210) |
| 8 | +- **Domains**: |
| 9 | + - Main app: https://smarthavenai.com |
| 10 | + - N8N workflows: https://n8n.smarthavenai.com |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- SSH access to VPS: `ssh root@72.62.86.210` |
| 15 | +- GitHub repository access |
| 16 | +- Gemini API key |
| 17 | +- Email for SSL certificates |
| 18 | + |
| 19 | +## Quick Deploy (Automated) |
| 20 | + |
| 21 | +The fastest way to deploy is using the automated deployment script: |
| 22 | + |
| 23 | +```bash |
| 24 | +# 1. SSH into VPS |
| 25 | +ssh root@72.62.86.210 |
| 26 | + |
| 27 | +# 2. Download and run deployment script |
| 28 | +curl -fsSL https://raw.githubusercontent.com/KevenWMarkham/transcript-parser/master/scripts/deploy-vps.sh -o deploy.sh |
| 29 | +chmod +x deploy.sh |
| 30 | +./deploy.sh |
| 31 | +``` |
| 32 | + |
| 33 | +The script will: |
| 34 | + |
| 35 | +- Install Docker & Docker Compose |
| 36 | +- Clone the repository |
| 37 | +- Guide you through environment configuration |
| 38 | +- Set up SSL certificates |
| 39 | +- Deploy all services (App, N8N, PostgreSQL, Nginx) |
| 40 | +- Configure firewall |
| 41 | +- Verify deployment |
| 42 | + |
| 43 | +## Manual Deployment Steps |
| 44 | + |
| 45 | +If you prefer manual control, follow these steps: |
| 46 | + |
| 47 | +### 1. System Setup (5 min) |
| 48 | + |
| 49 | +```bash |
| 50 | +ssh root@72.62.86.210 |
| 51 | + |
| 52 | +# Update system |
| 53 | +apt update && apt upgrade -y |
| 54 | + |
| 55 | +# Install Docker |
| 56 | +curl -fsSL https://get.docker.com -o get-docker.sh |
| 57 | +sh get-docker.sh |
| 58 | + |
| 59 | +# Install Docker Compose |
| 60 | +apt install -y docker-compose-plugin |
| 61 | + |
| 62 | +# Verify installation |
| 63 | +docker --version |
| 64 | +docker compose version |
| 65 | +``` |
| 66 | + |
| 67 | +### 2. Clone Repository (2 min) |
| 68 | + |
| 69 | +```bash |
| 70 | +mkdir -p /var/www/smarthaven |
| 71 | +cd /var/www/smarthaven |
| 72 | +git clone https://github.com/KevenWMarkham/transcript-parser.git . |
| 73 | +``` |
| 74 | + |
| 75 | +### 3. Configure Environment (3 min) |
| 76 | + |
| 77 | +```bash |
| 78 | +# Copy template |
| 79 | +cp .env.production.example .env.production |
| 80 | + |
| 81 | +# Edit with your values |
| 82 | +nano .env.production |
| 83 | +``` |
| 84 | + |
| 85 | +**Required values:** |
| 86 | + |
| 87 | +- `POSTGRES_PASSWORD`: Strong password for PostgreSQL |
| 88 | +- `N8N_PASSWORD`: Password for N8N access |
| 89 | +- `VITE_GEMINI_API_KEY`: Your Gemini API key |
| 90 | + |
| 91 | +```bash |
| 92 | +# Create SSL directories |
| 93 | +mkdir -p certbot/conf certbot/www |
| 94 | +``` |
| 95 | + |
| 96 | +### 4. DNS Configuration (5 min) |
| 97 | + |
| 98 | +In your Hostinger DNS settings, add these A records: |
| 99 | + |
| 100 | +| Name | Type | Value | TTL | |
| 101 | +| ---- | ---- | ------------ | ---- | |
| 102 | +| @ | A | 72.62.86.210 | 3600 | |
| 103 | +| www | A | 72.62.86.210 | 3600 | |
| 104 | +| n8n | A | 72.62.86.210 | 3600 | |
| 105 | + |
| 106 | +Verify DNS propagation: |
| 107 | + |
| 108 | +```bash |
| 109 | +nslookup smarthavenai.com |
| 110 | +nslookup www.smarthavenai.com |
| 111 | +nslookup n8n.smarthavenai.com |
| 112 | +``` |
| 113 | + |
| 114 | +### 5. SSL Certificates (10 min) |
| 115 | + |
| 116 | +```bash |
| 117 | +cd /var/www/smarthaven |
| 118 | + |
| 119 | +# Start Nginx temporarily |
| 120 | +docker compose up nginx -d |
| 121 | + |
| 122 | +# Get certificate for main domain |
| 123 | +docker compose run --rm certbot certonly --webroot \ |
| 124 | + --webroot-path=/var/www/certbot \ |
| 125 | + --email your-email@example.com \ |
| 126 | + --agree-tos \ |
| 127 | + --no-eff-email \ |
| 128 | + -d smarthavenai.com \ |
| 129 | + -d www.smarthavenai.com |
| 130 | + |
| 131 | +# Get certificate for N8N |
| 132 | +docker compose run --rm certbot certonly --webroot \ |
| 133 | + --webroot-path=/var/www/certbot \ |
| 134 | + --email your-email@example.com \ |
| 135 | + --agree-tos \ |
| 136 | + --no-eff-email \ |
| 137 | + -d n8n.smarthavenai.com |
| 138 | + |
| 139 | +# Stop temporary Nginx |
| 140 | +docker compose down |
| 141 | +``` |
| 142 | + |
| 143 | +### 6. Deploy Services (5 min) |
| 144 | + |
| 145 | +```bash |
| 146 | +cd /var/www/smarthaven |
| 147 | + |
| 148 | +# Build and start all services |
| 149 | +docker compose up -d --build |
| 150 | + |
| 151 | +# Check status |
| 152 | +docker compose ps |
| 153 | + |
| 154 | +# View logs |
| 155 | +docker compose logs -f |
| 156 | +``` |
| 157 | + |
| 158 | +### 7. Configure Firewall (2 min) |
| 159 | + |
| 160 | +```bash |
| 161 | +# Install UFW |
| 162 | +apt install -y ufw |
| 163 | + |
| 164 | +# Allow required ports |
| 165 | +ufw allow 22/tcp # SSH |
| 166 | +ufw allow 80/tcp # HTTP |
| 167 | +ufw allow 443/tcp # HTTPS |
| 168 | + |
| 169 | +# Enable firewall |
| 170 | +ufw enable |
| 171 | + |
| 172 | +# Check status |
| 173 | +ufw status verbose |
| 174 | +``` |
| 175 | + |
| 176 | +### 8. Verify Deployment (2 min) |
| 177 | + |
| 178 | +```bash |
| 179 | +# Test main app |
| 180 | +curl -I https://smarthavenai.com |
| 181 | + |
| 182 | +# Test N8N |
| 183 | +curl -I https://n8n.smarthavenai.com |
| 184 | + |
| 185 | +# Check all containers are healthy |
| 186 | +docker compose ps |
| 187 | +``` |
| 188 | + |
| 189 | +## Post-Deployment |
| 190 | + |
| 191 | +### Access Applications |
| 192 | + |
| 193 | +- **Main App**: https://smarthavenai.com |
| 194 | +- **N8N Platform**: https://n8n.smarthavenai.com |
| 195 | + - Username: (from `N8N_USER` in .env.production) |
| 196 | + - Password: (from `N8N_PASSWORD` in .env.production) |
| 197 | + |
| 198 | +### Useful Commands |
| 199 | + |
| 200 | +```bash |
| 201 | +# View logs |
| 202 | +docker compose logs -f app |
| 203 | +docker compose logs -f n8n |
| 204 | +docker compose logs -f nginx |
| 205 | + |
| 206 | +# Restart services |
| 207 | +docker compose restart app |
| 208 | +docker compose restart n8n |
| 209 | + |
| 210 | +# Update application |
| 211 | +cd /var/www/smarthaven |
| 212 | +git pull origin master |
| 213 | +docker compose up -d --build app |
| 214 | + |
| 215 | +# Database backup |
| 216 | +docker compose exec postgres pg_dump -U postgres transcript_parser > backup_$(date +%Y%m%d).sql |
| 217 | + |
| 218 | +# Access database |
| 219 | +docker compose exec postgres psql -U postgres transcript_parser |
| 220 | + |
| 221 | +# Check SSL certificate renewal |
| 222 | +docker compose run --rm certbot renew --dry-run |
| 223 | +``` |
| 224 | + |
| 225 | +### Monitoring |
| 226 | + |
| 227 | +```bash |
| 228 | +# Container status |
| 229 | +docker compose ps |
| 230 | + |
| 231 | +# Resource usage |
| 232 | +docker stats |
| 233 | + |
| 234 | +# Disk usage |
| 235 | +df -h |
| 236 | + |
| 237 | +# Check logs for errors |
| 238 | +docker compose logs app | grep -i error |
| 239 | +``` |
| 240 | + |
| 241 | +## Troubleshooting |
| 242 | + |
| 243 | +### Container Won't Start |
| 244 | + |
| 245 | +```bash |
| 246 | +# Check logs |
| 247 | +docker compose logs app |
| 248 | + |
| 249 | +# Recreate container |
| 250 | +docker compose up -d --force-recreate app |
| 251 | +``` |
| 252 | + |
| 253 | +### SSL Certificate Errors |
| 254 | + |
| 255 | +```bash |
| 256 | +# Test renewal |
| 257 | +docker compose run --rm certbot renew --dry-run |
| 258 | + |
| 259 | +# Force renewal |
| 260 | +docker compose run --rm certbot renew --force-renewal |
| 261 | + |
| 262 | +# Restart Nginx |
| 263 | +docker compose restart nginx |
| 264 | +``` |
| 265 | + |
| 266 | +### Database Connection Issues |
| 267 | + |
| 268 | +```bash |
| 269 | +# Check PostgreSQL status |
| 270 | +docker compose ps postgres |
| 271 | + |
| 272 | +# View logs |
| 273 | +docker compose logs postgres |
| 274 | + |
| 275 | +# Restart database |
| 276 | +docker compose restart postgres |
| 277 | +``` |
| 278 | + |
| 279 | +### Out of Disk Space |
| 280 | + |
| 281 | +```bash |
| 282 | +# Check disk usage |
| 283 | +df -h |
| 284 | + |
| 285 | +# Clean Docker system |
| 286 | +docker system prune -a |
| 287 | + |
| 288 | +# Remove old images |
| 289 | +docker image prune -a |
| 290 | +``` |
| 291 | + |
| 292 | +## GitHub Actions CI/CD (Optional) |
| 293 | + |
| 294 | +To enable automated deployments on push to master: |
| 295 | + |
| 296 | +### 1. Generate SSH Key |
| 297 | + |
| 298 | +```bash |
| 299 | +# On your local machine |
| 300 | +ssh-keygen -t ed25519 -C "github-actions@smarthavenai.com" |
| 301 | + |
| 302 | +# Copy private key |
| 303 | +cat ~/.ssh/id_ed25519 |
| 304 | + |
| 305 | +# Add public key to server |
| 306 | +ssh-copy-id root@72.62.86.210 |
| 307 | +``` |
| 308 | + |
| 309 | +### 2. Add GitHub Secrets |
| 310 | + |
| 311 | +Go to: Repository → Settings → Secrets and variables → Actions |
| 312 | + |
| 313 | +Add these secrets: |
| 314 | + |
| 315 | +- `HOSTINGER_SSH_KEY`: Paste private key content |
| 316 | +- `HOSTINGER_KNOWN_HOSTS`: Run `ssh-keyscan 72.62.86.210` |
| 317 | +- `HOSTINGER_USER`: `root` |
| 318 | +- `HOSTINGER_HOST`: `72.62.86.210` |
| 319 | + |
| 320 | +### 3. Test Automated Deployment |
| 321 | + |
| 322 | +```bash |
| 323 | +# Make a change and push |
| 324 | +echo "# Test" >> README.md |
| 325 | +git add README.md |
| 326 | +git commit -m "test: verify automated deployment" |
| 327 | +git push origin master |
| 328 | + |
| 329 | +# Watch GitHub Actions |
| 330 | +# Visit: https://github.com/KevenWMarkham/transcript-parser/actions |
| 331 | +``` |
| 332 | + |
| 333 | +## Architecture |
| 334 | + |
| 335 | +``` |
| 336 | +┌─────────────────────────────────────────────┐ |
| 337 | +│ Internet Traffic │ |
| 338 | +└────────────────┬────────────────────────────┘ |
| 339 | + │ |
| 340 | + ▼ |
| 341 | +┌─────────────────────────────────────────────┐ |
| 342 | +│ Nginx Reverse Proxy (Port 80/443) │ |
| 343 | +│ - SSL Termination (Let's Encrypt) │ |
| 344 | +│ - Routes to App or N8N │ |
| 345 | +└───────┬──────────────────┬──────────────────┘ |
| 346 | + │ │ |
| 347 | + ▼ ▼ |
| 348 | +┌──────────────┐ ┌──────────────────┐ |
| 349 | +│ App │ │ N8N Workflows │ |
| 350 | +│ (Port 3000) │ │ (Port 5678) │ |
| 351 | +└──────┬───────┘ └────────┬─────────┘ |
| 352 | + │ │ |
| 353 | + └──────────┬──────────┘ |
| 354 | + ▼ |
| 355 | + ┌────────────────┐ |
| 356 | + │ PostgreSQL │ |
| 357 | + │ (Port 5432) │ |
| 358 | + │ - app DB │ |
| 359 | + │ - n8n DB │ |
| 360 | + └────────────────┘ |
| 361 | +``` |
| 362 | + |
| 363 | +## Security Checklist |
| 364 | + |
| 365 | +- [ ] Strong passwords in `.env.production` |
| 366 | +- [ ] `.env.production` not committed to git |
| 367 | +- [ ] Firewall enabled (UFW) |
| 368 | +- [ ] Only ports 22, 80, 443 open |
| 369 | +- [ ] SSL certificates valid |
| 370 | +- [ ] PostgreSQL not accessible externally |
| 371 | +- [ ] Regular database backups configured |
| 372 | + |
| 373 | +## Performance Targets |
| 374 | + |
| 375 | +- **Time to First Byte (TTFB)**: < 200ms |
| 376 | +- **First Contentful Paint (FCP)**: < 1.8s |
| 377 | +- **Largest Contentful Paint (LCP)**: < 2.5s |
| 378 | +- **Cumulative Layout Shift (CLS)**: < 0.1 |
| 379 | +- **Time to Interactive (TTI)**: < 3.5s |
| 380 | + |
| 381 | +## Support |
| 382 | + |
| 383 | +For detailed deployment documentation, see: |
| 384 | + |
| 385 | +- [Complete Deployment Guide](specs/epics/epic-01-monorepo-foundation/sprints/sprint-01/deployment/DEPLOYMENT_SESSION_PROMPT.md) |
| 386 | +- [Docker Deployment Details](specs/epics/epic-01-monorepo-foundation/sprints/sprint-01/deployment/DOCKER_DEPLOYMENT.md) |
| 387 | + |
| 388 | +--- |
| 389 | + |
| 390 | +**Generated with [Claude Code](https://claude.com/claude-code)** |
0 commit comments