Athar Ahmad · Multi-Tenant SaaS Architecture

Athar Ahmad on Multi-Tenant SaaS Architecture: The Definitive Guide

Multi-tenancy is the foundation of every B2B SaaS product and the pattern most Bubble developers implement incorrectly. Athar Ahmad’s four-layer tenant isolation model, the exact workspace data model, and the five-test isolation protocol run before every production deployment.

4Isolation Layers
5Tests per Deployment
ZeroCross-Tenant Leakage
The Architecture That Separates Products From Projects

Why Multi-Tenancy Is the Most Important Skill in Bubble Development

Multi-tenant SaaS architecture — where a single application serves multiple organisations, each with complete isolation from every other — is the foundation of every B2B SaaS product. It is also the pattern that most Bubble developers implement incorrectly. Athar Ahmad has designed multi-tenant architecture for every production Bubble application he has built. This is his definitive explanation of how it works and why every detail matters.

The Four-Layer Tenant Isolation Model

How Athar Implements Multi-Tenancy

📊

Layer 1: Data Model

Every app data type has a workspace field linking each record to its owning organisation. This field is set on creation and never changed. Without this field, isolation is architecturally impossible regardless of what privacy rules or UI conditions are applied.

🔒

Layer 2: Privacy Rules

PostgreSQL-level row filtering that prevents any query from returning records outside the current user’s workspace. Set before any data is created. Tested before any customer data enters. The security layer that cannot be bypassed by any UI manipulation or API call.

Layer 3: Workflow Guards

Role checks on Step 1 of every sensitive workflow. Even if the UI is somehow manipulated to display a button, the workflow condition prevents execution. Defence in depth: security enforced at the action level as well as the data level.

👥

Layer 4: UI Conditions

Visibility conditions that show admin features only to admin users, show data only from the current workspace, and prevent cross-workspace navigation. The user experience layer that makes the application feel correctly scoped — backed by the three security layers beneath it.

The Workspace Data Model

The Exact Implementation

// The four core data types every multi-tenant Bubble SaaS needs
User

email
text (Bubble built-in)
name
text
current_workspace
-> Workspace (session context)

Workspace

name
text
owner
-> User
plan
-> Plan
subscription_status
option set (Trialing/Active/Past_Due/Cancelled)
stripe_customer_id
text
stripe_sub_id
text

Membership

user
-> User
workspace
-> Workspace
role
option set (Owner/Admin/Member/Viewer)
status
option set (Active/Invited/Removed)

// Every app data type (e.g. Project, Task, Invoice) gets:
workspace
-> Workspace (mandatory field, set on creation, never changed)

// Privacy rule on every app data type:
Condition
: Search for Memberships [user=Current User, workspace=This Record’s workspace, status=Active]:count > 0
Permissions
: Find ✓ View all fields ✓
The Isolation Test Protocol

How Athar Verifies Multi-Tenancy Before Every Launch

Setting up the isolation test: create two separate browser sessions (use a private/incognito window for the second). Log into Workspace A in session one, creating 10+ records across every data type. Log into Workspace B in session two. Navigate every page of the application in session two.

TestExpected ResultIf It Fails
Navigate to every list/dashboard page as Workspace BZero Workspace A records visible anywherePrivacy rule missing or incorrect on one or more data types
Copy a Workspace A record URL from session one, paste into session twoEmpty state or redirect to dashboardURL parameter access not properly restricted
Attempt an admin action as a Member role user in session twoAction does not execute; no data changesWorkflow role check missing on Step 1
Call Bubble Data API with Workspace B user’s token, query all recordsOnly Workspace B records returnedPrivacy rules not covering Data API access
💡

Run This Test Before Every Production Deployment

Takes five minutes. Has caught security vulnerabilities in every team that implements it seriously. New features that add new data types or modify privacy rules can inadvertently break isolation for that data type. This test catches it before a real customer’s data is exposed.

Work With Athar Ahmad

Pakistan’s leading Bubble.io systems architect. Multi-tenant SaaS architecture, Stripe billing, AI integration, and full product builds designed and delivered with precision.

Book a Discovery CallView Our Work

Athar Ahmad on Multi-Tenant SaaS Architecture: The Definitive Guide
Athar Ahmad · Simple Automation Solutions · sasolutionspk.com

Simple Automation Solutions

Business Process Automation, Technology Consulting for Businesses, IT Solutions for Digital Transformation and Enterprise System Modernization, Web Applications Development, Mobile Applications Development, MVP Development