{"slug":"operations/DOMAIN_CLEANUP_PLAN","title":"Domain Cleanup Plan","section":"operations","sectionLabel":"Operations","status":"unclassified","type":"document","path":"operations/DOMAIN_CLEANUP_PLAN.mdx","bytes":8932,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n## IntegrateWise Worker Domains — Post Deep Code Analysis\n\n> **Date**: 2026-05-29  \n> **Status**: Ready for Execution  \n> **Priority**: High (Enforces Gateway-Only Architecture)\n\n---\n\n## Executive Summary\n\nBased on the deep code analysis, we need to clean up Worker domains to enforce the **Gateway-Only Entry Point** architecture. This plan retires duplicate endpoints, removes staging route overlaps, and establishes `platform.integratewise.ai` as the internal ops console.\n\n---\n\n## 1. Retire `api.integratewise.online`\n\n### Current State\n\n- Custom domain: `api.integratewise.online`\n- Points to: `hub-api-prod` Worker\n- Status: Operational but redundant\n\n### Problem\n\n- Violates \"Gateway is the ONLY entry point\" principle\n- Creates confusion about which API endpoint to use\n- Potential security bypass if JWT validation differs\n- Maintenance burden for duplicate routing logic\n\n### Action Plan\n\n```bash\n# Execute cleanup script\ncd /Users/nirmal/Github/integratewise-live/scripts\nchmod +x cleanup-api-online-domain.sh\n./cleanup-api-online-domain.sh\n```\n\n### Steps\n\n1. ✅ Remove custom domain from `hub-api-prod` Worker\n2. ✅ Set up 301 redirect: `api.integratewise.online` → `gateway.integratewise.ai`\n3. ✅ Update any hardcoded references in:\n   - Frontend code (check for `VITE_API_BASE_URL` overrides)\n   - Documentation\n   - External integrations\n   - Postman collections / API clients\n\n### Verification\n\n```bash\n# Test redirect\ncurl -I https://api.integratewise.online/health\n# Should return: 301 Moved Permanently\n# Location: https://gateway.integratewise.ai/health\n```\n\n---\n\n## 2. Clean Up Staging Route Overlaps\n\n### Current State\n\nStaging Workers accessible via **both**:\n\n- Custom domain: `staging-hooks.integratewise.ai`\n- Route pattern: `loader-staging.integratewise.ai/*`\n\n### Problem\n\n- Violates \"single entry point per service\" principle\n- Creates confusion about which hostname to use\n- Staging should mirror production architecture\n\n### Action Plan\n\n```bash\n# Execute cleanup script\ncd /Users/nirmal/Github/integratewise-live/scripts\nchmod +x cleanup-staging-route-overlaps.sh\n./cleanup-staging-route-overlaps.sh\n```\n\n### Affected Services\n\n| Worker                          | Keep (Custom Domain)               | Remove (Route Pattern)               |\n| ------------------------------- | ---------------------------------- | ------------------------------------ |\n| `integratewise-loader-staging`  | `staging-loader.integratewise.ai`  | `loader-staging.integratewise.ai/*`  |\n| `integratewise-hooks-staging`   | `staging-hooks.integratewise.ai`   | `hooks-staging.integratewise.ai/*`   |\n| `integratewise-gateway-staging` | `staging-gateway.integratewise.ai` | `gateway-staging.integratewise.ai/*` |\n\n### Verification\n\n```bash\n# Test staging services via custom domains only\ncurl https://staging-gateway.integratewise.ai/health\ncurl https://staging-hooks.integratewise.ai/health\ncurl https://staging-loader.integratewise.ai/health\n\n# Verify route patterns are removed (should 404)\ncurl https://gateway-staging.integratewise.ai/health\n# Expected: 404 or no route found\n```\n\n---\n\n## 3. Create `platform.integratewise.ai`\n\n### Purpose\n\nInternal operations dashboard for:\n\n- Tenant management (create, update, delete)\n- Worker health monitoring\n- Pipeline queue inspection\n- Quarantine record review\n- Merge candidate approval (HITL)\n- Connector status overview\n- System metrics and logs\n\n### Action Plan\n\n```bash\n# Execute setup script\ncd /Users/nirmal/Github/integratewise-live/scripts\nchmod +x setup-platform-domain.sh\n./setup-platform-domain.sh\n```\n\n### Steps\n\n1. ✅ Attach custom domain `platform.integratewise.ai` to `integratewise-admin` Worker\n2. ✅ Configure Cloudflare Access (email allowlist)\n3. ✅ Verify Worker has all necessary bindings:\n   - `SPINE_URL`\n   - `SPINE_ANON_KEY`\n   - D1 binding: `CACHE_DB`\n   - KV bindings: `CACHE`, `METRICS`, `CONNECTOR_STATUS`\n   - Service bindings: `PIPELINE`, `INTELLIGENCE`, `KNOWLEDGE`\n\n### Cloudflare Access Configuration\n\n```yaml\nApplication Name: IntegrateWise Platform (Internal Ops)\nSubdomain: platform\nDomain: integratewise.ai\nSession Duration: 24 hours\n\nPolicy:\n  Name: Email Allowlist\n  Action: Allow\n  Include:\n    - Emails: nirmal@integratewise.ai\n    - Emails: (add other team members)\n```\n\n### Verification\n\n```bash\n# Test access (should redirect to Cloudflare Access login)\ncurl -I https://platform.integratewise.ai\n\n# After login, test admin endpoints\ncurl https://platform.integratewise.ai/admin/tenants\ncurl https://platform.integratewise.ai/admin/health\n```\n\n---\n\n## 4. Set Up `docs.integratewise.ai`\n\n### Current State\n\n- Not deployed\n- Documentation lives in `integratewise-docs` repo (public) and `BrandDocumentations` repo (internal)\n\n### Recommendation\n\n**Static site deployment** (not a Worker)\n\n### Action Plan\n\n#### Option A: GitHub Pages (Public Docs)\n\n```bash\n# In integratewise-docs repo\n# 1. Enable GitHub Pages in repo settings\n# 2. Set custom domain: docs.integratewise.ai\n# 3. Add CNAME record in Cloudflare DNS:\n#    docs.integratewise.ai → integratewise.github.io\n```\n\n#### Option B: Cloudflare Pages (Recommended)\n\n```bash\n# 1. Connect integratewise-docs repo to Cloudflare Pages\n# 2. Build command: (depends on static site generator)\n# 3. Output directory: (depends on static site generator)\n# 4. Custom domain: docs.integratewise.ai\n```\n\n### Verification\n\n```bash\n# Test docs site\ncurl https://docs.integratewise.ai\n# Should return HTML (not JSON)\n```\n\n---\n\n## Updated Endpoint Map (Post-Cleanup)\n\n### Production (Public)\n\n```\napp.integratewise.ai              → React SPA (Cloudflare Pages)\ngateway.integratewise.ai          → Gateway Worker (ONLY API entry)\nmcp.integratewise.ai              → MCP Connector Worker\nhooks.integratewise.ai            → Webhook Ingress Worker\ndocs.integratewise.ai             → Static site (GitHub Pages / Cloudflare Pages)\n```\n\n### Production (Internal)\n\n```\nplatform.integratewise.ai         → Admin Worker (Cloudflare Access gated)\nthink.integratewise.ai            → Intelligence Worker\nknowledge.integratewise.ai        → Knowledge Worker\nspine.integratewise.ai            → Pipeline Worker (read-only API)\ncontinuity.integratewise.ai       → Continuity Worker\n```\n\n### Staging\n\n```\nstaging-gateway.integratewise.ai  → Gateway Worker (staging)\nstaging-hooks.integratewise.ai    → Webhook Ingress Worker (staging)\nstaging-loader.integratewise.ai   → Loader Worker (staging)\n(All route patterns removed)\n```\n\n### Retired\n\n```\n❌ api.integratewise.online       → 301 redirect to gateway.integratewise.ai\n```\n\n---\n\n## Execution Checklist\n\n### Phase 1: Immediate (Today)\n\n- [ ] Run `cleanup-api-online-domain.sh`\n- [ ] Verify redirect: `api.integratewise.online` → `gateway.integratewise.ai`\n- [ ] Update hardcoded references in codebase\n- [ ] Run `cleanup-staging-route-overlaps.sh`\n- [ ] Test staging services via custom domains only\n\n### Phase 2: This Week\n\n- [ ] Run `setup-platform-domain.sh`\n- [ ] Configure Cloudflare Access for `platform.integratewise.ai`\n- [ ] Verify admin Worker bindings\n- [ ] Test platform dashboard access\n- [ ] Set up `docs.integratewise.ai` (GitHub Pages or Cloudflare Pages)\n\n### Phase 3: Verification\n\n- [ ] All services accessible via custom domains only\n- [ ] No duplicate route patterns in staging\n- [ ] Gateway is the ONLY public API entry point\n- [ ] Platform dashboard accessible with email auth\n- [ ] Documentation site live at `docs.integratewise.ai`\n\n---\n\n## Rollback Plan\n\nIf issues arise:\n\n### Rollback `api.integratewise.online` Retirement\n\n```bash\n# Re-attach custom domain\nwrangler deployments domain add api.integratewise.online --name hub-api-prod\n\n# Remove redirect rule in Cloudflare Dashboard\n```\n\n### Rollback Staging Route Cleanup\n\n```bash\n# Re-add route patterns\nwrangler routes add \"loader-staging.integratewise.ai/*\" --name integratewise-loader-staging --env staging\nwrangler routes add \"hooks-staging.integratewise.ai/*\" --name integratewise-hooks-staging --env staging\n```\n\n### Rollback Platform Domain\n\n```bash\n# Remove custom domain\nwrangler deployments domain remove platform.integratewise.ai --name integratewise-admin\n\n# Delete Cloudflare Access application\n```\n\n---\n\n## Success Criteria\n\n✅ **Gateway-Only Architecture Enforced**\n\n- All API traffic goes through `gateway.integratewise.ai`\n- No duplicate API endpoints\n\n✅ **Staging Mirrors Production**\n\n- Each staging service has ONE custom domain\n- No route pattern overlaps\n\n✅ **Internal Ops Console Established**\n\n- `platform.integratewise.ai` accessible with email auth\n- Admin features available for tenant/worker management\n\n✅ **Documentation Site Live**\n\n- `docs.integratewise.ai` serves public documentation\n- Static site deployment (not Worker)\n\n---\n\n**Document Version**: 1.0  \n**Last Updated**: 2026-05-29  \n**Author**: Kiro (Infrastructure Cleanup)  \n**Review Status**: Ready for Execution\n"}