Skip to main content
All models live in backend/prisma/schema.prisma, which is the source of truth for exact fields and constraints. This page covers the core domain models.

Organization models

Client

A retail organisation using MUZE (for example Boxer, Clicks).

Region

Geographic grouping of stores within a client. Unique on [clientId, code].

Store

A retail location. Requires a client and a region.

Department

Organisational unit within a client, used as entitlement criteria. Unique on [clientId, code].

Access models

User

A staff portal account (better-auth user).

UserRole

Links a user to a role with optional scope. A user can hold multiple roles.

Session

better-auth session storage.

Catalog models

UniformCategory

Groups employees who share entitlement rules. Each employee belongs to exactly one category. Client-scoped.

Product

An individual uniform item available for ordering. Unique on [clientId, code].

Employee models

Employee

A uniform recipient. Employees have no portal login; userId is a legacy link kept for technical-debt removal (Phase 11.9).

EmployeeSizeProfile

One per employee (employeeId unique).

Entitlement models

EntitlementRuleSet

Defines entitlements for a uniform category. Client-scoped.

EntitlementRuleItem

One allocated product within a rule set.

EntitlementRuleCriteria

One criteria row for matching employees to a rule set.

EntitlementPeriod

One allocation cycle for one employee against one rule set. Consumption is tracked through the period’s order items.

EntitlementOpeningBalance

What an employee already received OUTSIDE the system before MUZE went live, recorded at onboarding (decision D-31). Counts as consumed for the employee’s CURRENT allocation phase only, so opening balances for a past phase never affect a balance. Unique on [employeeId, productCode, phase], so re-imports overwrite the recorded quantity instead of duplicating it.

Order models

Order

A uniform order for one employee, placed by a staff user.

OrderItem

One product line within an order.

OrderStatusHistory

Audit trail of status changes.

StoreOrder

Groups the orders from one submission into a batch, tied to a single store.

System models

Notification

In-app and email notification records, linked to a recipient user.

EmailLog

Audit record of every email attempt, including provider response and errors.

AuditLog

ImportBatch

Tracking record for each bulk import: kind, file name, total/success/error row counts, and per-row errors.

SystemSetting

Key-value configuration (key unique), grouped by concern. Includes ORDER_NUMBER_PREFIX, STORE_ORDER_NUMBER_PREFIX, and notification toggles.

NumberSequence

Persistent counter backing order and store-order number generation.

Supporting models

Account and Verification (better-auth), NotificationTemplate, and InventoryStockLevel complete the schema. See schema.prisma for their fields.