Skip to content
Webliska TechnologiesFlaxxa is a registered product of Webliska Technologies, Faridabad, HaryanaGSTIN: 06ATYPG3011E1ZX
Flaxxa AI is now in open beta.
Flaxxa
Start Free
← All posts
Engineering· 3 min read

Multi-tenant from line one — the architecture decision that compounded

Why every Flaxxa product is multi-tenant by default — and what that means when you're building on top of Core.

Multi-tenancy is one of those engineering decisions you can defer for years. The cost of deferring is invisible until it isn't, and then it's expensive. We chose to pay it on day one.

The choice that compounds

Every table in Flaxxa Core has a tenant_id column. Every Eloquent model has a BelongsToTenant trait that adds a global scope. Every API request resolves a tenant context before the controller runs. The kernel enforces tenant isolation at the row level via Postgres RLS — cross-tenant queries are physically impossible.

That's a lot of plumbing for a startup with one customer. We wrote it before we had ten customers.

What it bought us

By the time we shipped the helpdesk product, every product downstream of it inherited tenant isolation for free. WAPI ships in a tenant boundary. AI ships in a tenant boundary. Forms, Push, Social — every one of them got tenant isolation as a structural property of the platform, not as a feature each squad re-implemented.

The dollar value is hard to measure but the days-of-engineering value is easy: each new product saves ~10 engineering-days because the tenant work is already done. Across 10 products, that's a developer-quarter.

What it cost us

We over-engineered the tenant resolver. The first version supported five different ways to identify a tenant (subdomain, header, cookie, JWT claim, query param) and a router that fell back through them in order. We needed the first two. The other three were dead code for 14 months.

We also under-invested in tooling. Migrating data between tenants, copying a tenant for QA, exporting all data for a single tenant — these are operations you do constantly once you have customers. We had none of them ergonomically. We built them as one-offs over the next year.

What I'd tell a team facing this fork

Multi-tenant from day one is the right call if you have any reasonable expectation of B2B SaaS. The work is bounded; the savings compound. But:

  • Pick the simplest tenant resolution mechanism and stop. Don't build five.
  • Build the per-tenant ops tools (export, copy-for-QA, impersonate) before you need them.
  • Use Postgres RLS, not application-layer scopes. Application scopes get bypassed accidentally; RLS doesn't.
  • Have a tenant-isolation test suite that runs on every CI build. Once it's broken, you don't notice for months.

The compounding part shows up later than you expect. By product 3 you'll feel it. By product 6 you can't imagine working without it.

Built on Flaxxa

Run your business on one platform.

Free plan. No credit card.

Start Free