B2B SaaS Architectures in High-Level Design

Lessons in this section

  1. Multi-Tenancy Models

    Many customers on one system: compare pool (shared tables + tenant key), bridge (schema per tenant) and silo (database or cell per tenant) on cost, isolation, migrations and restore time.

  2. Tenant Context and Isolation

    Carry the tenant through every hop: request, cache, database, queue, worker and search index. Find where the tenant context gets dropped, and fix it with tenant-scoped keys and row-level security.

  3. Noisy Neighbours and Fairness

    One tenant's huge export spikes everyone's p99. Protect shared capacity with per-tenant quotas, fair queues and a dedicated cell for the whale tenant.

  4. Custom Fields and Objects

    Every customer wants different fields. Store customer-defined fields without a schema change per tenant: compare EAV, JSONB and generated columns in real Postgres, with indexes and query plans.

  5. Authorization and Sharing

    Decide who inside a tenant may read, edit or delete each record: role-based access (RBAC), record-level sharing, private records and row-level security, checked in a fixed order with deny by default.

  6. Enterprise Identity: SSO and SCIM

    Customers bring their own identity provider. Follow a SAML and an OIDC login message by message, provision users with SCIM, and close the gap where a leaver keeps access.

  7. Audit Logs and Compliance

    Make every action traceable: an append-only, hash-chained audit trail that shows tampering, answers 'who changed this and when', and keeps each tenant's events exactly as long as its contract says.

  8. Workflow and Automation Engines

    Let each tenant automate its own work with trigger, condition and action rules, then stop the rule that triggers itself, the retry that pages someone twice and the import that takes every worker.

  9. Integrations: Public API and Webhooks

    Customers connect Northwind to their own systems. Deliver every webhook with retries and a dead-letter queue, sign it, keep one broken endpoint from slowing the rest, and rate-limit the API per tenant.

  10. Data Residency, Regions and Cells

    Keep each tenant's data in the regions its contract allows: home cells, a tenant directory for routing, every copy kept in-region, and a tenant moved between cells with no data loss.

  11. Usage Metering and Billing

    Bill exactly what each customer used: usage events with ids, deduplication, late events billed as adjustments instead of edited invoices, and prorated plan changes.

  12. Cloud, Private Cloud and On-Premises

    Run the same product in your cloud, in a customer's cloud account and in an air-gapped data centre from one build: interfaces and adapters, config profiles, offline licences and signed release bundles.