Skip to main content

Data Model

This page explains the core entities and how permissions are applied.

Core Entities​

EntityDescription
TenantLogical partition for users and roles
UserAccount identity; belongs to one or more tenants
RoleNamed role scoped to a tenant (or global for platform roles)
FeatureA capability domain (e.g., USER_MGMT)
PermissionBoolean map for a feature: read, create, update, delete, restore; optional extraActions
PermissionAssignmentAssigns a Permission to a subject (usually a Role). Unique key: (permissionId, subjectType, subjectId)
FeatureFlagToggle for features at runtime for a subject (user/role/tenant)
ConsentUser consents; see DTOs under the backend
Session & LoginAttemptSession management and auditing

Relationships​

  • Users link to Tenants via userTenant join
  • Users have Roles within a Tenant via userRole join
  • Roles receive capability via PermissionAssignments
  • Permissions refer to a Feature; Features are the canonical capability keys

Uniques & Idempotency​

EntityUnique Constraint
FeaturesUnique on name
RolesUnique on name (per namespace)
PermissionUnique on (featureId)
PermissionAssignmentComposite unique (permissionId, subjectType, subjectId)

Seed scripts use upserts on these uniques to remain idempotent (see libs/prisma/access-control-client/prisma/SEEDS.md).