Skip to Content
DocsHow Dawn worksArchitecture

Architecture

The generated repository inventory lists current applications, packages, internal dependencies, and public contracts. This page records ownership and constraints that cannot be derived from those registries.

Ownership

  • @dawn/foundation owns errors and result primitives.
  • @dawn/domain owns healthcare contracts, module definitions and runtime composition, repository ports, and functional services.
  • @dawn/db owns PostgreSQL schema, migrations, and repository adapters.
  • @dawn/capabilities owns transport-neutral operation metadata.
  • @dawn/api binds capabilities to endpoint schemas, envelopes, OpenAPI, and the transport-neutral client.
  • @dawn/api-client adapts OpenAPI operations to browser query state.
  • @dawn/api-runtime owns access resolution, CORS, route composition, workflows, and concrete dependencies.
  • @dawn/ui owns shared shadcn primitives. Applications own product composition and layout.

ESLint rejects imports against this dependency direction. Application source uses its @ alias for parent imports.

Runtime constraints

Domain services are functions receiving repository ports. They do not import Next.js, React, Drizzle, PostgreSQL, or provider SDKs. The API creates its database-backed runtime lazily, caches it for the process, and retains an explicit close path. Module-owned services are bound through createModuleRuntime; application runtimes do not instantiate those factories individually.

The workspace is the tenant boundary. Access tokens resolve a server-owned workspace and member-or-patient actor. Clients cannot select a workspace. Repository filters and composite foreign keys retain workspace scope.

Failure modes

  • A prohibited dependency fails lint.
  • A malformed access token fails before decoding or domain work.
  • A disabled or unavailable module fails at the endpoint policy.
  • Invalid path, query, or body data fails through the endpoint decoder.
  • A stale mutable-resource update fails with 409; callers reload before retrying.
  • Database failures remain result values and map to declared API problems.
Last updated on