Multi-Tenancy¶
The factory is a multi-tenant SaaS platform, and it generates multi-tenant SaaS products. Tenant isolation is built into every platform, grounded in the ConnectSoft.Extensions.Saas.* libraries and the ConnectSoft.Saas.*Template services.
Tenancy model¶
flowchart TB
subgraph tenantA [Tenant A]
projA["Projects"]
dataA["Tenant-scoped data"]
end
subgraph tenantB [Tenant B]
projB["Projects"]
dataB["Tenant-scoped data"]
end
shared["Shared Factory Platforms<br/>(tenant-aware)"]
isolation["TenantContext + Tenant Guards<br/>(ConnectSoft.Extensions.Saas)"]
tenantA --> isolation
tenantB --> isolation
isolation --> shared
Hold "Alt" / "Option" to enable pan & zoom
Isolation layers¶
| Layer | Mechanism |
|---|---|
| Identity | tenantId claim in OAuth2/JWT tokens (OpenIddict); resolved into an ambient TenantContext. |
| Application | Every command/query handler asserts tenantId scope before acting. |
| Data | tenantId is part of every primary/secondary index; row-level filtering enforced in NHibernate. Optional database-per-tenant for premium isolation. |
| Messaging | Events carry tenantId; subscriptions filter on cs-tenant-id. |
| Knowledge | MemoryAccessPolicy scopes context retrieval to the tenant; cross-tenant knowledge is only shared via explicitly published, classified patterns/marketplace assets. |
| Secrets | Per-tenant Key Vault references; never shared plaintext. |
| Runtime | Generated runtimes isolate tenants per RuntimeTenantBinding; namespace/environment isolation in AKS/Container Apps. |
Editions, quotas, and metering¶
Commercial multi-tenancy is owned by the Control Plane Tenant & Edition context and grounded in real services:
| Capability | Service / library |
|---|---|
| Tenants | ConnectSoft.Saas.TenantsTemplate, TenantService |
| Editions / plans | ConnectSoft.Saas.EntitlementsTemplate, EditionService |
| Subscriptions / billing | ConnectSoft.Saas.BillingTemplate, ConnectSoft.Extensions.Saas.Billing |
| Usage metering | ConnectSoft.Saas.MeteringTemplate, ConnectSoft.Extensions.Saas.Metering |
| Feature flags | FeatureFlagService |
| Quotas | QuotaService (enforced per tenant/edition) |
Generated SaaS inherits the model¶
Products the factory generates inherit this exact tenancy model through the ConnectSoft.Saas.* templates, so every generated SaaS is multi-tenant from day one. See Generated SaaS data model.