This monorepo implements a distributed architecture for VS Code extensions with cloud-native backend services.
┌─────────────────┐
│ VS Code IDE │
└────────┬────────┘
│
┌────┴────┐
│ │
┌───▼──┐ ┌──▼───┐
│ Core │ │ Pro │
│ Ext │ │ Ext │
└───┬──┘ └──┬───┘
│ │
└────┬───┘
│
┌────▼─────────────┐
│ Edge Services │
├──────────────────┤
│ Vercel + CF │
└────┬─────────────┘
│
┌────▼─────────────┐
│ Storage Layer │
├──────────────────┤
│ KV, R2, D1, Vec │
└──────────────────┘
Purpose: Provide base functionality available to all users
Components:
- Command handlers
- Base features
- Webviews
- Syntax highlighting
- Snippets
License: MIT (Open Source)
Purpose: Advanced features requiring license validation
Components:
- Advanced commands
- Premium features
- License validation
- Cloud synchronization
- Priority support
License: Proprietary
Extension Activation
↓
Load Configuration
↓
Initialize Features
↓
Register Commands
↓
Validate License (Pro only)
↓
Enable Features
Purpose: Edge computing for low-latency operations
Services:
-
Authentication (
auth.ts)- JWT token generation
- Token validation
- Session management
-
License Management (
license.ts)- License validation
- Activation tracking
- Subscription status
-
Analytics (
analytics.ts)- Usage metrics
- Error tracking
- Performance monitoring
-
Stripe Webhooks (
stripe-webhooks.ts)- Payment processing
- Subscription events
- Refund handling
Storage:
- KV: Session tokens, cache
- R2: Asset storage, backups
- D1: Relational data, licenses
- Vectorize: Semantic search
- Queues: Async processing
Purpose: Regional compute and API endpoints
Functions:
-
Edge Functions:
- Rate limiting
- Authentication middleware
- CDN optimization
-
API Routes:
- License checking
- Customer portal
- Telemetry collection
User Action → Extension
↓
Local Processing
↓
API Request → Vercel Edge
↓
Rate Limit Check
↓
Forward → Cloudflare Worker
↓
Process & Store → KV/D1/R2
↓
Response → Edge → Extension
Use Cases:
- Session tokens
- Cache layer
- Feature flags
- Rate limit counters
Characteristics:
- Global replication
- Eventually consistent
- High read throughput
Use Cases:
- Extension packages
- User uploads
- Backup archives
- Static assets
Characteristics:
- S3-compatible API
- Zero egress fees
- Global distribution
Use Cases:
- User accounts
- License records
- Subscription data
- Audit logs
Characteristics:
- SQL interface
- ACID transactions
- Automatic replication
Use Cases:
- Semantic search
- Code similarity
- Recommendation engine
Characteristics:
- Vector embeddings
- Fast similarity search
- Integrated with Workers
- User initiates auth in extension
- Extension opens OAuth flow
- User authenticates with provider
- Backend generates JWT token
- Extension stores token securely
- Token used for API requests
Pro Extension Start
↓
Read Local License
↓
Validate with API
↓
Check Expiration
↓
Verify Signature
↓
Enable/Disable Features
- Transport: TLS 1.3
- Authentication: JWT with RS256
- Authorization: Role-based access
- Validation: Input sanitization
- Rate Limiting: Per-user quotas
- Audit: Activity logging
Code Change → Git Push
↓
Turborepo Build
↓
Parallel Execution
├─ Lint
├─ Type Check
├─ Test
└─ Build
↓
Artifacts Generated
-
Extensions:
- VS Code Marketplace
- Open VSX Registry
-
Cloudflare:
- Workers (global edge)
- KV/R2/D1/Vectorize
-
Vercel:
- Edge Functions
- API Routes
-
Website:
- GitHub Pages
- Jekyll build
extensions/core-extension
↓
tools/shared-utils
↓
tools/logger
extensions/pro-extension
↓
tools/shared-utils (licensing)
↓
tools/logger
tools/logger: Centralized loggingtools/shared-utils: Common utilitiesconfig/*: Shared configurations
Extension State Change
↓
Queue Sync Event
↓
Background Worker
↓
Cloudflare Queue
↓
Worker Processing
↓
Store in D1/KV
↓
Notify Other Devices
-
Extension Telemetry:
- Activation events
- Command usage
- Error rates
- Performance metrics
-
API Metrics:
- Request count
- Response times
- Error rates
- Geographic distribution
-
Business Metrics:
- Active users
- License activations
- Feature usage
- Conversion rates
- Logs: Cloudflare Logs + Custom logger
- Metrics: Custom dashboards
- Traces: Request correlation
- Alerts: Threshold monitoring
pnpm workspace (package manager)
↓
Turborepo (build orchestration)
↓
TypeScript (language)
↓
Individual packages
- Local development with watch mode
- Hot reload for quick iteration
- Type checking on save
- Pre-commit hooks
- CI validation on push
- Development: Local + dev cloud resources
- Staging: Isolated test environment
- Production: Live user environment
Each environment has:
- Separate Cloudflare accounts/resources
- Isolated Vercel projects
- Environment-specific secrets
- Different API endpoints
- Cloudflare Workers: Auto-scale globally
- Vercel Functions: Regional auto-scale
- D1: Automatic read replicas
- Caching: Aggressive KV caching
- CDN: Static asset delivery
- Code Splitting: Lazy loading
- Bundling: Optimized builds
- Multi-region D1: Geographic data locality
- Real-time Sync: WebSocket connections
- Offline Support: Local-first architecture
- Plugin System: Extensibility framework
- Global edge deployment
- Low latency
- Cost-effective
- Rich ecosystem
- Next.js integration
- Regional compute
- Easy deployment
- Great DX
- Fast incremental builds
- Remote caching
- Task orchestration
- Monorepo-native
- Disk space efficient
- Fast installation
- Strict dependency resolution
- Workspace support
- Stripe: Payment processing
- OAuth Providers: Authentication
- GitHub: Source control
- VS Code Marketplace: Distribution
- Stripe events → Cloudflare Worker
- GitHub events → Automation
- License changes → Extension notification