{
  "docVersion": 1,
  "id": "template-multi-tenant-saas-data-plane",
  "name": "Multi-tenant SaaS data plane",
  "purpose": "SaaS tenancy reference: edge auth + quotas, directory-based tenant routing into a pooled RLS tier and a database-per-tenant silo tier.",
  "nodes": {
    "pooled": {
      "type": "users",
      "label": "Tenants A–xxx",
      "x": 20,
      "y": 160,
      "runtime": "thousands, pooled tier"
    },
    "ent": {
      "type": "users",
      "label": "Enterprise tenant",
      "x": 20,
      "y": 460,
      "runtime": "contractual isolation"
    },
    "edge": {
      "type": "gateway",
      "label": "API Edge",
      "x": 280,
      "y": 300,
      "runtime": "authn · tenant context",
      "patterns": [
        "stateless"
      ]
    },
    "quota": {
      "type": "ratelimiter",
      "label": "Per-tenant Quotas",
      "x": 280,
      "y": 80,
      "runtime": "fair-share throttling",
      "color": "amber",
      "notes": "Rate and concurrency limits are per tenant — one tenant's batch job can't starve the rest."
    },
    "router": {
      "type": "servicediscovery",
      "label": "Tenant Router",
      "x": 540,
      "y": 300,
      "runtime": "directory: tenant → cell",
      "color": "blue",
      "notes": "A lookup table, not a hash — tenants can be moved between tiers and cells deliberately."
    },
    "app1": {
      "type": "k8s",
      "label": "App — pooled cell",
      "x": 800,
      "y": 160,
      "runtime": "multi-tenant workers",
      "patterns": [
        "stateless",
        "autoscale"
      ]
    },
    "app2": {
      "type": "k8s",
      "label": "App — silo cell",
      "x": 800,
      "y": 460,
      "runtime": "dedicated workers",
      "patterns": [
        "stateless"
      ]
    },
    "db1": {
      "type": "database",
      "label": "Pooled DB",
      "x": 1060,
      "y": 160,
      "runtime": "shared tables + RLS",
      "notes": "Every query carries tenant_id; row-level security enforces it even when application code forgets.",
      "patterns": [
        "backup",
        "replicated"
      ]
    },
    "db2": {
      "type": "database",
      "label": "Tenant DB",
      "x": 1060,
      "y": 460,
      "runtime": "database-per-tenant",
      "patterns": [
        "backup"
      ]
    },
    "audit": {
      "type": "audit",
      "label": "Access Audit",
      "x": 1060,
      "y": 660,
      "runtime": "who touched what"
    }
  },
  "edges": {
    "e1": {
      "from": "pooled",
      "to": "edge",
      "fromSide": "right",
      "toSide": "left",
      "label": "requests + tenant JWT",
      "animated": true,
      "patterns": [
        "authenticated"
      ]
    },
    "e2": {
      "from": "ent",
      "to": "edge",
      "fromSide": "right",
      "toSide": "left",
      "patterns": [
        "authenticated"
      ]
    },
    "e3": {
      "from": "edge",
      "to": "quota",
      "fromSide": "top",
      "toSide": "bottom",
      "label": "quota check",
      "style": "dashed",
      "patterns": [
        "rate-limit"
      ]
    },
    "e4": {
      "from": "edge",
      "to": "router",
      "fromSide": "right",
      "toSide": "left",
      "animated": true
    },
    "e5": {
      "from": "router",
      "to": "app1",
      "fromSide": "right",
      "toSide": "left",
      "label": "tier: pooled",
      "animated": true
    },
    "e6": {
      "from": "router",
      "to": "app2",
      "fromSide": "right",
      "toSide": "left",
      "label": "tier: silo"
    },
    "e7": {
      "from": "app1",
      "to": "db1",
      "fromSide": "right",
      "toSide": "left",
      "label": "WHERE tenant_id = ? (+ RLS)"
    },
    "e8": {
      "from": "app2",
      "to": "db2",
      "fromSide": "right",
      "toSide": "left"
    },
    "e9": {
      "from": "app2",
      "to": "audit",
      "fromSide": "bottom",
      "toSide": "left",
      "label": "access log",
      "style": "dashed"
    }
  },
  "boxes": {
    "b1": {
      "x": 760,
      "y": 100,
      "w": 520,
      "h": 220,
      "label": "pooled cell — dense, cheap, RLS-enforced",
      "color": "blue",
      "opacity": 0.04
    },
    "b2": {
      "x": 760,
      "y": 400,
      "w": 520,
      "h": 220,
      "label": "silo cell — database-per-tenant",
      "color": "purple",
      "opacity": 0.04
    }
  },
  "texts": {
    "t1": {
      "x": 20,
      "y": 640,
      "text": "tiering is economics: pooled = margin,\nsilo = the enterprise deal. the router\ndirectory lets one product run both",
      "color": "blue",
      "size": 12
    }
  },
  "meta": {
    "createdAt": "2026-07-13T09:00:00.000Z",
    "modifiedAt": "2026-07-13T09:00:00.000Z"
  }
}