How arcoders/adonisjs-lasagna-saas-tenancy works
This is an AdonisJS tenancy package that provisions and routes tenants into isolated PostgreSQL schemas, then adds lifecycle operations, tenant-scoped controls, and optional SaaS satellites. The main workflow is an HTTP or admin operation resolving a tenant, applying isolation and policy, and dispatching lifecycle work; operators can also manage tenants through commands. The graph preserves documented backups, resilience, replicas, health, quotas, and satellites. Evidence is limited to the README and supplied excerpts/source-index references; links for unsampled wiring are omitted or marked unverified.
Main entry points: admin_controller.ts Tenant Admin · database_pg_driver.ts Isolation Drivers · middleware Tenant Middleware · routes.ts Admin REST API
Components 27
Entry and Routing
- Route Macros
src/extensions/router.ts - Tenant Middleware
src/middleware - Admin REST API
src/admin/routes.ts - Tenant Admin
src/admin/admin_controller.ts - Operator Commands
src/commands - Package Configuration
src/config.ts
Tenant Operations
- Tenant Repository
src/types/contracts.ts - Provisioning Jobs
src/jobs/install_tenant.ts - Tenant Lifecycle Services
src/services - Typed Lifecycle Events
src/events
Isolation Runtime
- Isolation Drivers
src/services/isolation/database_pg_driver.ts - Tenant PostgreSQL Schemas
- Circuit and Resilience
src/services/circuit_breaker_service.ts - Tenant Queue
src/services/tenant_queue_service.ts - Contextual Logging
src/services/tenant_logger.ts - Read Replica Routing
src/services/read_replica_service.ts
Tenant Capabilities
- Backup and Restore
src/services/backup_service.ts - Tenant Doctor
src/services/doctor/doctor_service.ts - Health and Metrics
src/health/health_service.ts
SaaS Satellites
- Plans and Quotas
src/services/quota_service.ts - Admin Satellites
src/admin/controllers - Webhook Delivery
src/services/webhook_service.ts - Stripe Webhook Intake
src/controllers/stripe_webhook_controller.ts - Stripe Event Worker
src/jobs/process_stripe_event_job.ts - Stripe Billing
src/services/billing_service.ts
Other components
- Host Application
- Stripe
Connections 28
- Host Application → Route Macros: registers routes
src/extensions/router.ts - Route Macros → Tenant Middleware: attaches guards
src/extensions/router.ts - Host Application → Admin REST API: calls admin API
README.md - Admin REST API → Tenant Admin: routes requests
src/admin/routes.ts - Tenant Admin → Tenant Repository: loads tenants
src/admin/admin_controller.ts - Tenant Admin → Isolation Drivers: destroys schema
src/admin/admin_controller.ts - Tenant Admin → Tenant Doctor: runs report
src/admin/admin_controller.ts - Tenant Admin → Typed Lifecycle Events: dispatches events
src/admin/admin_controller.ts - Operator Commands → Provisioning Jobs: runs operations
README.md - Provisioning Jobs → Tenant Repository: uses tenant model
src/jobs/install_tenant.ts - Provisioning Jobs → Isolation Drivers: provisions schema
- Isolation Drivers → Tenant PostgreSQL Schemas: routes connections
README.md - Isolation Drivers → Circuit and Resilience: guards database calls
README.md - Tenant Middleware → Isolation Drivers: selects tenant context
README.md - Tenant Middleware → Plans and Quotas: enforces quotas
README.md - Tenant Queue → Contextual Logging: propagates context
README.md - Read Replica Routing → Tenant PostgreSQL Schemas: routes reads
README.md - Backup and Restore → Tenant PostgreSQL Schemas: backs up schemas
README.md - Tenant Doctor → Tenant PostgreSQL Schemas: checks tenant state
README.md - Health and Metrics → Host Application: exports probes
README.md - Admin REST API → Admin Satellites: routes satellite APIs
src/admin/routes.ts - Admin Satellites → Webhook Delivery: manages webhooks
src/admin/controllers/webhooks_controller.ts - Tenant Middleware → Stripe Webhook Intake: verifies webhook requests
README.md - Stripe Webhook Intake → Stripe Event Worker: enqueues verified events
src/controllers/stripe_webhook_controller.ts - Stripe Event Worker → Stripe Billing: processes billing events
src/jobs/process_stripe_event_job.ts - Stripe Billing → Stripe: calls Stripe API
README.md - Stripe Webhook Intake → Stripe: receives Stripe events
README.md - Host Application → Package Configuration: configures package
README.md