Repository navigation
Multi Tenancy and RBAC
Every clinic is a tenant, and almost every record is organization-scoped. Getting this boundary right is what keeps one clinic's financial and clinical data invisible to another.
Yosemite Crew uses row-level org scoping for the core product and schema-per-tenant for the developer platform.
- Core entities carry an
organisationId; queries and RBAC checks are scoped by it. Cross-tenant access is a bug class, not a feature — the boundary was hardened repo-wide in PR #1860 (merged 2026-07-18): tenant scope is now derived from the resource being accessed and permission checks were tightened. New cross-tenant findings are treated as security bugs as found. - An
Organizationmodel holds locale/currency (immutable after onboarding), country/regulatory config, feature flags, and appointment configuration. See the org model in the architecture guide.
-
packages/database/src/tenant.tsimplements schema-per-tenant provisioning: atenant_<key>Postgres schema per developer tenant plus apubliccontrol plane, with per-tenant Prisma client caching. -
registerTenant()records aregionon the control-plane row at provision time — the seam that makes future multi-region an additive change rather than a backfill (ADR-0004). - The v1 Developer Data API deliberately does not depend on this machinery yet; it scopes by
organisationIdrows.
Authorization is role-based and org-scoped. The model has seven roles, each carrying fine-grained permission strings checked per route/action:
| Role | Typical scope |
|---|---|
OWNER |
Full org control |
ADMIN |
Org administration |
SUPERVISOR |
Oversight across clinical + front desk |
VETERINARIAN |
Clinical: SOAP, prescriptions, vitals, discharge, controlled-substance logging |
TECHNICIAN |
Vitals, tasks, lab orders, SOAP view |
ASSISTANT |
Support tasks |
RECEPTIONIST |
Appointments, check-in, billing/invoices, triage view |
Permissions are strings like appointments:view:any, prescription:write, controlled-substances:log, billing:view:any, vitals:record. They travel in the session's org context claim (see Authentication and Identity) and are enforced server-side. This role structure was preserved across the SuperTokens migration.
flowchart LR
U[User] -->|session| S[OrgSessionClaim<br/>orgId + role + permissions]
S --> M{requireWebAuth / requireScope}
M -->|orgId match + permission| OK[Handler runs, scoped to orgId]
M -->|mismatch| DENY[403]
The developer platform layers a scope model on top: DeveloperApiKeys carry narrow scopes (config:read, config:draft:write, and the canonical :read scopes), enforced by requireScope. The AI editing agent is deliberately capped at config:draft:write and cannot publish — see ADR-0005.
Home · Architecture · ADRs · Plans · Roadmap · Contributing · Main repo · DeepWiki · Discord
Yosemite Crew is a product of DuneXploration UG (haftungsbeschränkt). This wiki mirrors the repository; where a page and the repo disagree, the repo wins. See the Wiki Style Guide.
Product & Domain
Architecture
Applications
- Backend — Overview
- Frontend / PIMS Web — Overview
- Mobile — Overview
- Desktop PIMS Shell
- Developer Portal
- SuperAdmin
Design & Accessibility
Engineering Handbook
Decisions (ADRs)
Design Docs & Plans
Meta
Canonical code & docs: main repo · Auto-generated companion: DeepWiki