In residential PropTech, software security is physical security. If a multi-tenant flaw allows an administrator in Society A to view the financials or resident records of Society B, the platform has failed at its core engineering premise.
Database-Per-Tenant vs Discriminator Column Multi-Tenancy
When architecting Truegate for hundreds of housing societies and thousands of daily gate transactions, our engineering team evaluated two distinct multi-tenant paradigms:
| Dimension | Database-per-Tenant | Discriminator Column (Truegate) |
|---|---|---|
| Migration Velocity | Slow (running 500 migrations sequentially) | Instant (single atomic schema migration) |
| Database Connection Pooling | Exhausts server pool quickly | Optimized (high-efficiency connection pool) |
| Cross-Society Tenant Switching | Heavy connection switching overhead | Fast (swapping team context in memory) |
| Isolation Enforcement | Guaranteed by DB boundary | Guaranteed via Global Scopes & Foreign Keys |
How TrueGate Keeps Society Data Separate
Truegate enforces isolation through a strict 3-tier security pipeline:
- ActiveTenancy Middleware: On every incoming HTTP request,
ActiveSocietyMiddlewareresolves the authenticated user's active society context. Any attempt to query records from a foreignsociety_idtriggers an immediate403 Unauthorizedresponse. - Team-Scoped RBAC via Spatie: Truegate uses Spatie Laravel-Permission in teams mode. When an admin logs in,
setPermissionsTeamId($societyId)sets the authorization scope. An account that is anadminin Society #12 has zero permissions if they access Society #15. - Indexing by Society: Records are indexed by society so each query reads only that society's data efficiently.