feat: independent deployment architecture for multi-app CF workers #2100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a deployment configuration that enables independent deployment of three distinct applications (
apps/web
,apps/app
, andapps/edge
) while serving them all under the same domain.🎯 Problem Solved
Previously, all applications were tightly coupled in deployment, meaning any change to the marketing site would require redeploying the entire application stack. This created several pain points:
🏗️ Architecture Overview
The new architecture separates concerns while maintaining unified domain experience:
Route Priority & Fallbacks
/login
,/account*
,/billing*
,/team*
,/_app/*
)/*
)📦 Key Changes by Priority
🟢 High Priority - Core Deployment Configuration
Wrangler Configuration for Independent Deployments
apps/web/wrangler.jsonc
: Marketing site deployment configexample.com/*
)apps/app/wrangler.jsonc
: Main application deployment config/_app/*
,/login
,/account*
,/billing*
,/team*
apps/edge/wrangler.jsonc
: Edge worker for API and orchestration/api/*
)Build Output Configuration
apps/app/vite.config.ts
: Optimized asset naming for cache-busting_app/assets/[name]-[hash][extname]
🟡 Medium Priority - Infrastructure & DevOps
Terraform Infrastructure Improvements
DNS Management: Comprehensive DNS configuration for all environments
staging.example.com
subdomainEnhanced Hyperdrive Configuration:
Required Cloudflare Permissions Update:
Zone:DNS:Edit
permission for automated DNS managementPreview Deployment System
paris.example.com
,london.example.com
, etc.🔵 Low Priority - Security & Performance
Security Headers (
apps/web/_headers
)Cache Optimization
max-age=0, must-revalidate
)max-age=31536000, immutable
)max-age=86400
)Package Cleanup
wrangler
dependencies from individual apps🚀 Deployment Flow
Independent Deployment Commands
Multi-Environment Support
Each app supports three deployment targets:
✅ Benefits for Teams
Marketing Team
Engineering Team
DevOps/Platform Team
🧪 Testing Strategy
📚 Documentation Updates
docs/deployment.md
: Updated with new deployment commands and architectureinfra/README.md
: Added required Cloudflare permissionsCLAUDE.md
: Updated essential commands for independent deployments🔄 Migration Path
This change is designed to be backward compatible. Existing single-command deployments continue to work while enabling new independent deployment capabilities.
🤝 For New Contributors
This architecture makes it much easier for new team members to:
The separation of concerns reduces cognitive load and makes the codebase more approachable for developers of all experience levels.