
☁️ SaaS & Cloud · C4 Architecture · Pro
A B2B SaaS product serving many customer organisations from one platform: tenant-aware services, per-tenant data isolation, billing and admin.
C4 Architecture diagrams are part of Pro. Anyone can view this one; generating and editing it needs Pro.
Drawing diagram…
Multi-tenant SaaS architecture: users from many customer organisations sign in through an auth service (SSO/SAML per tenant), the API gateway resolves the tenant from the subdomain and token. Services: tenant management (plans, limits, feature flags), core application services, a shared PostgreSQL with schema per tenant (dedicated database for enterprise tenants), a billing service integrated with Stripe/Razorpay, audit logging, and a background job queue.
C4Container
title Multi-Tenant SaaS
Person(user, "Tenant User", "Works in their organisation's space")
Person(admin, "Tenant Admin", "Manages users and billing")
System_Ext(idp, "Customer IdP", "SSO / SAML")
System_Ext(pay, "Billing Provider", "Stripe / Razorpay")
System_Boundary(saas, "SaaS Platform") {
Container(web, "Web App", "React", "acme.app.com")
Container(gw, "API Gateway", "Envoy", "Resolves tenant, rate limits")
Container(auth, "Auth Service", "Go", "Login, SSO per tenant")
Container(tenant, "Tenant Service", "Go", "Plans, limits, feature flags")
Container(core, "Core Services", "Node.js", "Product features")
Container(jobs, "Job Workers", "Node.js", "Exports, emails")
ContainerDb(db, "PostgreSQL", "Schema per tenant", "Tenant data")
Container(billing, "Billing Service", "Go", "Subscriptions and invoices")
}
Rel(user, web, "Uses")
Rel(admin, web, "Uses")
Rel(web, gw, "Calls")
Rel(gw, auth, "Verifies")
Rel(auth, idp, "SAML")
Rel(gw, core, "Routes with tenant ID")
Rel(core, tenant, "Checks limits")
Rel(core, db, "Tenant schema")
Rel(core, jobs, "Queues work")
Rel(billing, pay, "Charges")How a microservices app runs on Kubernetes in the cloud: ingress, namespaces, services with multiple replicas, managed databases and monitoring.
A typical CI/CD pipeline from a pull request to production: build, tests, security scans, staging deploy, approval and a canary release.
The authorization code flow with PKCE used by most modern web and mobile apps to log users in through an identity provider.
The classic three-tier web app on AWS: CloudFront and a load balancer, an autoscaling app tier in private subnets, and a Multi-AZ database.
Services that talk through events instead of direct calls: an order service publishes events that inventory, payments, notifications and analytics react to.
The states of a SaaS customer's subscription: trial, active, past due with retries, paused, cancelled and expired.