Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Multi-Tenancy Model

Stitchd uses a four-level hierarchy: Tenant → Project → Environment → SDK Key.

Hierarchy Diagram

graph TD
    T[Tenant] -->|owns many| P[Project]
    P -->|has many| E[Environment\ne.g. prod, staging, dev]
    E -->|has many| SDK[SDK Keys]
    P -->|defines| FF[Feature Flag Definitions]
    P -->|defines| V[Variant Configurations]
    E -->|configures| R[Rules]
    E -->|configures| S[Segments]
    E -->|runs| EX[Experiments]

Scoping Rules

Project-scoped (shared across environments)

EntityNotes
Feature Flag DefinitionsThe flag key and type are project-level
Variant ConfigurationsWhich variants exist and their values

Sharing definitions across environments ensures flag keys are consistent when promoting from devstagingprod.

Environment-scoped

EntityNotes
RulesWhich users/segments see which variant, in which environment
SegmentsRule-based and list-based segment definitions
SDK KeysOne or more keys per environment for SDK authentication
ExperimentsA/B test and metric configurations

Each environment is fully independent — enabling a flag in prod does not affect staging.

SDK Key Isolation

An SDK key grants read access to exactly one project + environment combination. The SDK can only see:

  • Flag definitions for that project
  • Active rules for that environment
  • Segment definitions for that environment

It cannot read other environments’ rules or other tenants’ data.

Tenant Isolation

All database queries include a tenant_id predicate. Tenants are fully isolated at the query layer — there is no cross-tenant data leakage by design, and no shared-nothing partitioning is required at the database level.