Multi-Tenancy Architecture
ValidonX uses a database-per-tenant isolation model. Each tenant gets a dedicated MySQL database containing their licenses, activations, entitlements, and usage data. The platform database stores shared data: tenants, users, subscriptions, billing, and audit logs.
How It Works
┌─────────────────────────────────────┐
│ Platform Database │
│ (validonx_platform) │
│ │
│ tenants, users, admins, plans, │
│ subscriptions, invoices, api_keys, │
│ audit_logs, webhook_endpoints │
└─────────────────────────────────────┘
│
│ tenant_id foreign key
│
┌─────┴─────┬──────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Tenant A │ │ Tenant B │ │ Tenant C │
│ (vx_ │ │ (vx_ │ │ (vx_ │
│ tenant_ │ │ tenant_ │ │ tenant_ │
│ acme) │ │ beta) │ │ corp) │
│ │ │ │ │ │
│ licenses │ │ licenses │ │ licenses │
│ activ. │ │ activ. │ │ activ. │
│ entitl. │ │ entitl. │ │ entitl. │
│ usage │ │ usage │ │ usage │
└──────────┘ └──────────┘ └──────────┘Tenant Resolution
Every API request is routed to the correct tenant database via middleware:
- Integration API (
/v1/integration/*): Resolved fromX-API-Keyheader. The API key hash is looked up in the platform database to find the tenant. - Tenant API (
/v1/tenant/*): Resolved from the authenticated user's Sanctum token. If a user belongs to multiple tenants, theX-Tenant-IDheader selects which one.
Provisioning
New tenants go through a 12-stage idempotent pipeline:
- Validate tenant record
- Create isolated database
- Run tenant migrations
- Seed configuration defaults
- Initialize subscription (plan-linked)
- Initialize entitlements (plan-specific)
- Initialize usage counters
- Set branding defaults
- Generate API key (HMAC-SHA256 hashed)
- Create webhook endpoint placeholder
- Emit audit event
- Health check and status → active
Data Isolation Guarantees
- Each tenant's data is in a separate database — no shared tables
- Database connection is switched per-request via
TenantDatabaseManager - API keys are scoped to a single tenant
- Rate limits are enforced per-tenant and per-API-key
- Audit logs include
tenant_idfor correlation