Phase 04 — Operations
HITL #11 Approved Operations ← Ecosystem 🇧🇷 PT

Phase 04 — Operations

CI/CD, GMUD, SLOs, DORA metrics, infrastructure and A/B testing.

CI/CD Pipeline

Deploy Strategy
Single VPS + PM2 + Nginx + Let’s Encrypt SSL

Domain: food.ecportilho.com

Process Manager: PM2 (zero-downtime reload)

Reverse Proxy: Nginx

SSL: Let’s Encrypt via Certbot

Build Pipeline — 7 Steps

StepCommandDescription
1. pull_latestgit pull origin mainUpdate source code
2. install_dependenciesnpm ci --production=falseInstall dependencies (including devDeps for build)
3. build_frontendnpm run buildBuild React SPA via Vite → client/dist/
4. run_seednpm run seedPopulate SQLite with initial data (idempotent)
5. register_webhooknpm run register-webhookRegister webhook in ecp-digital-bank (idempotent)
6. restartpm2 reload ecosystem.config.cjsGraceful reload (zero-downtime)
7. verify_healthcurl -sf http://127.0.0.1:3000/api/categoriesApplication health check

Rollback

Trigger: Health check fails after deploy OR critical payment error in the first 2 hours.

Command: git checkout HEAD~1 && npm ci && npm run build && pm2 reload ecosystem.config.cjs

Estimated time: 5 minutes

GMUD

GMUD-FOODFLOW-001
Initial Deploy — FoodFlow Marketplace MVP in Production

Type: Normal | Priority: High | Risk: Low-Medium (10/30)

Scope: VPS provisioning, installation of Node.js 20 LTS + PM2 + Nginx + Certbot, application deploy, seed data (6 restaurants, 24 items, 3 users), SSL configuration, webhook registration in ecp-digital-bank, DNS food.ecportilho.com.

Window: Saturday 10:00-12:00 BRT | Estimated duration: 45 minutes | Monitoring: 2h after deploy

Success Criteria

CriterionValidation
Application responding with SSLcurl -sf https://food.ecportilho.com/ returns HTML
API functionalGET /api/categories returns 200
Authentication functionalPOST /api/auth/login returns valid JWT
Bank integration accessiblePOST /api/payments/bank-auth returns token
Webhook registeredecp-digital-bank confirms registration
PM2 stable 30 minpm2 status shows 0 restarts

Service Level Objectives (SLOs)

Measurement window: Rolling 30 days.

SLO-1: API Availability
99.5%
HTTP 2xx/4xx requests (excluding 5xx). Error budget: 3.6h downtime/month. Alert: < 99.0%
SLO-2: P95 Latency — Catalog
200ms
95% of GET requests to /api/restaurants and /api/categories complete in < 200ms. Alert: > 350ms
SLO-3: P95 Latency — Payment
2000ms
95% of requests to /api/payments/* complete in < 2s (includes bank call). Alert: > 3000ms
SLO-4: Error Rate
< 0.5%
5xx error rate over total requests per 1-hour window. Alert: > 1.0%
SLO-5: SSE Delivery Time (PIX)
2000ms
SSE payment_update event delivered to frontend in < 2s after webhook received. Alert: > 5000ms

DORA Metrics

MetricTargetTarget BandHow to Measure
Deployment Frequency 1-2x per week Medium Count of pm2 reloads in production per week
Lead Time for Changes < 1 day High Timestamp of merge to main vs timestamp of deploy
Change Failure Rate < 15% Medium Deploys with rollback / total deploys in the period
Mean Time to Recovery < 30 minutes High Time between incident detection and confirmed restoration

Targets calibrated for MVP with lean team and single VPS. Future: automated CI/CD via GitHub Actions.

Infrastructure

PM2 — Process Manager
  • Metrics: CPU, memory, restarts, uptime
  • Log rotation: max 50MB, retention 10 files, compress
  • Stdout logs: ~/.pm2/logs/foodflow-out.log
  • Stderr logs: ~/.pm2/logs/foodflow-error.log
Nginx — Reverse Proxy
  • Access log: /var/log/nginx/foodflow-access.log
  • Error log: /var/log/nginx/foodflow-error.log
  • SSL: Let’s Encrypt (Certbot auto-renew)
  • Health check: GET /api/categories every 60s, timeout 5s

Environment Variables (15)

NODE_ENV, PORT, HOST, JWT_SECRET, JWT_REFRESH_SECRET, DB_PATH, CORS_ORIGIN, ECP_BANK_API_URL, ECP_BANK_PLATFORM_EMAIL, ECP_BANK_PLATFORM_PASSWORD, ECP_BANK_PLATFORM_PIX_KEY, ECP_BANK_PLATFORM_PIX_KEY_TYPE, ECP_BANK_PIX_EXPIRATION_MINUTES, ECP_BANK_WEBHOOK_SECRET, FOODFLOW_PUBLIC_URL

.env file at project root on VPS. NEVER commit to the repository.

A/B Testing (Future)

Experiment 1
Hero Banner: Daily Promo vs Personalized
KR1 (Conversion)
Test whether a hero banner with personalized recommendations converts better than a generic daily promotion.
Experiment 2
Checkout: 2 Steps vs 3 Steps
KR1 (Conversion)
Test whether consolidating address + coupon into one step reduces cart abandonment.
Experiment 3
Return Coupon: R$ 5 vs Free Delivery
KR2 (Repurchase)
Test which incentive drives better 7-day repurchase rate among second-order users.

Generated Artifacts

04-product-operation/ops-output.json docs/gmud/GMUD-001.md docs/install/install-ecp-digital-food-win.md