← Foundations

Foundation 02

Choose where data and authority belong

A tenant is an organization or account boundary. It tells the app which data, members, and permissions belong together.

Tenant
Parent / childMembershipRole inheritanceProfile relationship
Organization, user access, and business relationships use different links.

Use the relationship that matches the job

Tenant hierarchy, membership, and profile relationships answer different questions. Keeping them separate makes access rules easier to reason about.

  • Parent and child tenants describe organization: company, division, branch, or network member.
  • A membership gives one user access to one tenant through one role.
  • A profile relationship describes business meaning: supplier, client, partner, or representative.

Make inheritance a choice

A parent must allow permission cascading and the child must accept it. A role can separately allow descendant authority. Nothing widens access just because two tenants are related.

tenant-setup.ts
typescript
const network = await tenants.create({
  name: 'Northern Network',
  cascadePermissions: true
});

const chapter = await tenants.createChild(network.id, {
  name: 'Edmonton Chapter',
  inheritPermissions: true
});

Put tenant scope on the model

Required scope means every row belongs to a tenant. Optional scope allows shared rows as well as tenant rows. Global models remain outside tenant filtering. The request session establishes the authorized tenant context.