Skip to content

Shared Packages

Ankit Upadhyay edited this page Aug 25, 2026 · 3 revisions

Shared Packages

The packages/ workspaces hold code shared across apps, so a type or utility is defined once and imported everywhere. Changing a shared package ripples across the monorepo - see monorepo-ops for the build/validation order.

The packages

Package Purpose Notable consumers
database Prisma schema, migrations, the Postgres client, and schema-per-tenant provisioning (src/tenant.ts). The schema source of truth. backend, developer platform
fhir FHIR R4 converters and compatibility helpers - maps core entities to FHIR resources. backend, web, mobile
fhirtypes FHIR R4 type definitions. fhir, types, all apps
types Shared TypeScript form/domain types (appointments, invoices, companions, encounters, forms, and more) and FHIR-adjacent shapes. Published as @yosemite-crew/types. web, mobile, backend
lib Shared errors and reusable utilities. all apps
auth Shared auth helpers used across the auth boundary. backend, web, mobile
design-tokens Intended shared token layer, but unbuilt and unconsumed: its entry points target a dist/ no workflow builds, and no app source imports it (web declares it as an unused workspace devDependency). The live tokens are in apps/frontend/src/app/globals.css and apps/mobileAppYC/src/theme/colors.ts. A known cleanup item. none at runtime

Why these boundaries

  • One definition, many clients. FHIR resources and domain types are shared so the web, mobile, and backend can't drift apart on a shape. (The realtime event contract is documented in docs/guide/realtime-backend.md rather than a shared package.) See Realtime and Notifications and FHIR and Interoperability.
  • database is the schema authority. Keeping Prisma schema + migrations + client in one package makes ADR-0001's "Prisma Migrate is the source of truth" enforceable, and hosts the tenant primitive behind ADR-0004.
  • design-tokens never became the styling vocabulary. The package was meant to feed both design systems but has zero runtime consumers; each app's token layer is its own source of truth - see Design System and Tokens.

Gotchas

  • Mocking @yosemite-crew/types in frontend tests: spread jest.requireActual('@yosemite-crew/types') in the mock, or forms.ts crashes at load. See Frontend Testing.
  • Worktree validation: bare npx tsc / eslint fail in a fresh worktree because the Prisma client isn't generated - use pnpm --filter <ws> run type-check / lint. See Getting Started.

Related

Product & Domain
Architecture
Applications
Design & Accessibility
Engineering Handbook
Decisions (ADRs)
Design Docs & Plans
Roadmap
Operations
Meta

Canonical code & docs: main repo · Auto-generated companion: DeepWiki

Clone this wiki locally