Unclassified

Cloudflare Workers Deployment

Architecture

IntegrateWise backend runs on Cloudflare Workers, organized as:

  1. Gateway (entrypoint) → routes to all services via internal bindings
  2. Core Services (pipeline, spine, connector, intelligence, knowledge, workflow, hermes, govern, act)
  3. MCP Services (provider-management, integration-management for auth)
  4. Next.js Frontend (apps/web) → deployed to Vercel or Cloudflare Pages, calls Gateway APIs

Deployment

Prerequisites

  1. Install Wrangler CLI: pnpm add -D wrangler@latest
  2. Authenticate: pnpm exec wrangler login
  3. Verify account_id in services/gateway/wrangler.toml

Deploy Services (Staging)

pnpm run deploy:staging
# or manually per service:
cd services/gateway && pnpm exec wrangler deploy --env staging
cd services/pipeline && pnpm exec wrangler deploy --env staging
# etc.

Deploy Services (Production)

pnpm run deploy:prod

Environment Variables

Secrets are configured per environment in wrangler.toml and stored in Cloudflare Secrets Manager:

# Set secrets in Cloudflare
pnpm exec wrangler secret put SUPABASE_URL --env staging
pnpm exec wrangler secret put SUPABASE_SERVICE_ROLE_KEY --env staging
pnpm exec wrangler secret put DATABASE_URL --env staging

Service Bindings

The Gateway binds all services internally:

[services]
pipeline = { binding = "PIPELINE" }
spine = { binding = "SPINE" }
connector = { binding = "CONNECTOR" }
intelligence = { binding = "INTELLIGENCE" }
# etc.

Services are NOT directly accessible; all requests route through the Gateway.

Frontend Deployment

Option 1: Cloudflare Pages (static export)

# Build with static export enabled
STATIC_EXPORT=1 pnpm run build --filter @integratewise/web
# Deploy to Cloudflare Pages (automatic via Git)

Option 2: Vercel (Server Mode)

# Deploy as-is (server mode for Route Handlers + dynamic RSC)
pnpm run deploy --filter @integratewise/web
# Gateway URL configured in NEXT_PUBLIC_API_BASE_URL

Routing

  • Gateway URL: https://gateway.{env}.integratewise.ai/
  • Frontend URL (Vercel): https://integratewise.ai/
  • Frontend URL (Cloudflare Pages): https://pages.{env}.integratewise.ai/

All frontend requests to /api/* proxied to Gateway via environment variable NEXT_PUBLIC_API_BASE_URL.

Verification

# Health check
curl https://gateway.staging.integratewise.ai/health

# List apps (marketplace)
curl https://gateway.staging.integratewise.ai/api/marketplace/apps \
  -H "Authorization: Bearer YOUR_JWT"

# Check service bindings
pnpm exec wrangler tail --env staging

Rollback

Each deploy creates a new version. Rollback via:

pnpm exec wrangler deployments list
pnpm exec wrangler rollback --version YOUR_VERSION

Notes

  • No static export on production: Authenticated product routes require server mode. Remove STATIC_EXPORT=1 for production builds.
  • D1 Database: Gateway reads tenant/user records from D1 (integratewise-spine-cache). Ensure D1 is replicated across regions for HA.
  • Rate Limiting: Configured in Gateway; adjust in services/gateway/src/lib/rate-limit.ts.
  • CORS: Configured in Gateway; update CORS_ORIGINS as needed.