01 · layer
Tenant isolation enforced by the database.
PostgreSQL Row-Level Security is enabled on every table. Application code never writes a WHERE tenantId — Prisma sets a session GUC that the policy reads. A bug that forgets to scope returns zero rows, never another tenant’s data.
- Postgres RLS enforced · a per-tenant policy on every tenanted table
- UUID v7 everywhere · no sequential increment
- Non-superuser application role — the database refuses the bypass even if the code has a bug
- Two-tenant isolation tests, run against a real database under the application role
illustration of the principle