Architecture Overview
Scalable microservices for 10x growth
8
Services Implemented
RLS
Enforced Security
10x
Scale Ready
Unified Scheduling Service
Centralized availability checking and resource allocation
Features
- checkAvailability - Unified conflict detection
- createHold - 15min soft locks on resources
- releaseHold - Manual hold release
- cleanupExpiredHolds - Auto cleanup (5min intervals)
Benefits
- Prevents double-booking across all resource types
- Handles Studios, Gear, Props, and Event conflicts
- Checks operating hours and quantity limits
- Supports hold-before-payment flows
Asynchronous Processing System
Background job queue with automated task processing
Features
- EmailQueue entity - Queue for async email sending
- BackgroundJob entity - Job tracking and monitoring
- processEmailQueue - Batch email processor (5min intervals)
- systemHealthCheck - Monitors system health (15min intervals)
Benefits
- Reduces API response latency
- Reliable retry mechanism for failed operations
- Batch processing for efficiency
- Decouples critical path from side effects
Commerce Fulfillment Service
Idempotent post-payment processing separated from checkout
Features
- fulfillOrder - Central fulfillment orchestrator
- Type-specific handlers (tickets, bookings, memberships, credits)
- Converts holds to confirmed bookings
- Tracks fulfillment status per line item
Benefits
- Idempotent - safe to retry on webhook failures
- Atomic fulfillment per line item
- Clear separation: payment vs fulfillment
- Detailed fulfillment result tracking
Deferred Payment Capture
Manual payment authorization for quote-based workflows
Features
- createPaymentIntentManual - Authorize card without charging
- capturePaymentIntent - Staff accepts quote → capture funds
- cancelPaymentIntent - Staff revises quote → release hold
- Supports inquiry → quote → acceptance flow
Benefits
- Customer cards authorized but not charged on inquiry
- Staff can review and approve before capture
- Clean cancel/reauthorize flow for revised quotes
- Reduces declined payments and chargebacks
Centralized Authorization Service
Single source of truth for permission checks
Features
- checkPermission - Unified permission validation
- Role-based permissions (admin)
- Member type permissions (from MemberTypeConfig)
- Context-aware permissions (project collaborator, event organizer)
Benefits
- Consistent permission logic across app
- Cacheable permission results
- Dynamic member type permissions
- Project and event-specific permissions
Stripe Product Sync
Sync Base44 Items to Stripe catalog
Features
- syncItemsToStripe - Bulk sync backend function
- StaffStripeSync - Admin UI for managing sync
- Tracks stripe_product_id and stripe_price_id on Items
- Supports Subscriptions, Memberships, EventTickets
Benefits
- Base44 remains source of truth for pricing
- Stripe handles payment processing
- Easy re-sync when prices change
- Clear separation of concerns
Refund Processing Service
Automated refund handling with fulfillment reversal
Features
- processRefund - Full and partial refunds
- Stripe API integration
- Automatic fulfillment reversal
- Customer email notifications
Benefits
- Admin-controlled refund workflow
- Automatic ticket/booking cancellation
- Credit balance adjustments
- Audit trail in Order.activity_log
Monitoring & Logging System
Centralized logging and health monitoring
Features
- SystemLog entity - Structured log storage
- logSystemEvent - Centralized logging function
- systemHealthCheck - Automated health monitoring
- Critical alert notifications
Benefits
- Single source of truth for system logs
- Proactive issue detection
- Automatic admin alerts on critical failures
- Historical log data for debugging
Automated Maintenance
Scheduled cleanup and archival tasks
Features
- cleanupOldDrafts - Daily cleanup (2am)
- archiveCompletedBookings - Weekly archive (Sundays 3am)
- generateDailyReport - Daily metrics (8am)
- cleanupExpiredHolds - Continuous (5min intervals)
Benefits
- Keeps database lean and performant
- Automatic archival of old data
- Regular business insights
- Prevents data bloat at scale
Architecture Complete
✓ Unified scheduling with soft holds
✓ Idempotent order fulfillment
✓ Centralized permission system
✓ Asynchronous background processing
✓ System health monitoring & alerts
✓ Automated maintenance tasks
✓ Structured logging & error tracking
Active Automations
⏱️ Every 5 min: Cleanup Expired Holds
⏱️ Every 5 min: Process Email Queue
⏱️ Every 15 min: System Health Check
📅 Daily 2am: Cleanup Old Drafts (30+ days)
📅 Daily 8am: Generate Business Report
📅 Weekly Sun 3am: Archive Completed Bookings (90+ days)