This document describes the package layering structure and naming conventions for Prisma 8, as defined in ADR 140.
The package structure encodes three orthogonal ideas:
- Domains (framework vs target families). The framework domain is target-agnostic; target families (SQL, document, etc.) are family-specific.
- Layers (responsibility-based layers). Layers express dependency direction: packages may depend on peers in the same layer (lateral relationships) and on layers closer to core (downward), but never "upward."
- Planes (migration vs runtime). Migration plane (authoring, tooling, targets) must not import runtime plane code. Runtime plane may consume artifacts (JSON/manifests) from migration, but not code imports.
This separation keeps the architecture flexible (per the original Clean Architecture guidance) while still making it obvious where SQL/document packages live and enforcing clear boundaries between migration and runtime concerns.
The repository uses numbered prefixes in directory names to make the hierarchy explicit:
packages/
1-framework/ # Domain 1: Framework (target-agnostic)
0-foundation/ # Layer 0: Foundation
1-core/ # Layer 1: Core
2-authoring/ # Layer 2: Authoring
3-tooling/ # Layer 3: Tooling
2-document/ # Domain 2: Document (placeholder)
2-mongo-family/ # Domain 2: Mongo family
2-sql-family/ # Domain 2: SQL family
1-core/ # Layer 1: Core
2-authoring/ # Layer 2: Authoring
3-tooling/ # Layer 3: Tooling
4-lanes/ # Layer 4: Lanes
5-runtime/ # Layer 5: Runtime
3-extensions/ # Domain 3: Extensions
3-targets/ # Domain 3: Targets, one folder per database (ADR 278)
postgres/ # 1-target, 2-adapter, 3-driver, 4-codec-testkit, 9-facade
sqlite/ # the same
mongo/ # 1-target, 2-adapter, 3-driver, 9-facade
mysql/
1-mysql/ # 1-target, 2-adapter, 3-driver, 9-facade
2-mariadb/ # 1-target, 2-adapter, 3-driver, 9-facade
3-live-tests/ # one test-only package that depends on both facades
The numbered prefixes serve two purposes:
- Visual hierarchy: Makes domain/layer relationships clear at a glance
- Dependency direction: Lower numbers can be imported by higher numbers, never the reverse
The direction rule exists to prevent cycles between packages. It adapts Clean Architecture's rule that dependencies point one way: if a package imports only from lower-numbered folders, no chain of imports can lead back to where it started. Numbers compare only between folders in the same parent.
Planes are a conceptual grouping recorded in architecture.config.json but do not appear as intermediate subdirectories.
The framework domain (packages/1-framework/) contains target-agnostic packages that work across all target families:
* 1-framework
|-- 0-foundation
| |-- contract/ → @internal/contract
|-- 1-core
| |-- config/ → @internal/config
| |-- errors/ → @internal/errors
| |-- framework-components/ → @internal/framework-components
| |-- operations/ → @internal/operations
|-- 2-authoring (migration plane)
| |-- contract/ → @internal/contract-authoring
| |-- psl-parser/ → @internal/psl-parser
|-- 3-tooling (migration plane)
|-- cli/ → @internal/cli
|-- emitter/ → @internal/emitter
|-- migration/ → @internal/migration-tools
The SQL domain (packages/2-sql-family/) contains SQL-specific packages organized by layer:
* 2-sql-family
|-- 1-core (shared plane)
| |-- contract/ → @internal/sql-contract
| |-- errors/ → @internal/sql-errors
| |-- operations/ → @internal/sql-operations
| |-- schema-ir/ → @internal/sql-schema-ir
|-- 2-authoring (migration plane)
| |-- contract-prisma7/ → @internal/sql-contract-prisma7
| |-- contract-psl/ → @internal/sql-contract-psl
| |-- contract-ts/ → @internal/sql-contract-ts
|-- 3-tooling (migration plane)
| |-- emitter/ → @internal/sql-contract-emitter
|-- 4-lanes (runtime plane)
| |-- relational-core/ → @internal/sql-relational-core
| |-- sql-builder/ → @internal/sql-builder
|-- 5-runtime (runtime plane)
|-- → @internal/sql-runtime
|-- 9-family (migration plane)
|-- → @internal/family-sql
The Mongo family domain (packages/2-mongo-family/) contains Mongo-specific packages organized by layer:
* 2-mongo-family
|-- 1-foundation (shared plane)
| |-- mongo-contract/ → @internal/mongo-contract
|-- 2-authoring (migration plane)
| |-- contract-psl/ → @internal/mongo-contract-psl
| |-- contract-ts/ → @internal/mongo-contract-ts
|-- 3-tooling (migration plane)
| |-- emitter/ → @internal/mongo-emitter
|-- 4-query (runtime plane)
| |-- query-ast/ → @internal/mongo-query-ast
|-- 5-query-builders (runtime plane)
| |-- orm/ → @internal/mongo-orm
| |-- query-builder/ → @internal/mongo-query-builder
|-- 6-transport (shared plane)
| |-- mongo-lowering/ → @internal/mongo-lowering
| |-- mongo-wire/ → @internal/mongo-wire
|-- 7-runtime (runtime plane)
| |-- → @internal/mongo-runtime
|-- 9-family (migration plane)
|-- → @internal/family-mongo
The targets domain (packages/3-targets/) holds one folder per database, for every family (ADR 278). Target, adapter, driver and facade stay separate packages, so an application can replace one of them; the folder keeps them together. Inside a database folder the numbers give dependency order: the adapter imports the target, the facade imports all three, the driver imports none of them. A package imports only from lower-numbered folders. Numbers compare only between folders in the same parent.
0-shared/ beside the database folders holds packages that several databases' packages share (ADR 314). Today that is @internal/type-implementations: value logic that more than one target's codecs, data types and now() generators use, depending on no database and no family; and @internal/target-package-config: what every target package's defineConfig shares, such as restating its target's and adapter's type declarations with its own module. Both are registered in the targets domain, plane shared, so the target packs, the adapters and the target packages can import them. The top-level packages/0-shared/ is a different folder: it holds repository tooling, such as the map of published packages, registered in the framework domain.
* 3-targets
|-- 0-shared
| |-- target-package-config → @internal/target-package-config (what every target package's defineConfig shares)
| |-- type-implementations → @internal/type-implementations (value logic several targets' type implementations share)
|-- postgres
| |-- 1-target → @internal/target-postgres (target pack: descriptor, codecs, data types, migrations)
| |-- 2-adapter → @internal/adapter-postgres (lowering, control adapter; multi-plane)
| |-- 3-driver → @internal/driver-postgres (connections and transport)
| |-- 4-codec-testkit → @internal/postgres-codec-testkit
| |-- 9-facade → @internal/postgres (source of @prisma/orm-postgres)
|-- sqlite (the same five)
|-- mongo
| |-- 1-target → @internal/target-mongo
| |-- 2-adapter → @internal/adapter-mongo
| |-- 3-driver → @internal/driver-mongo
| |-- 9-facade → @internal/mongo (source of @prisma/orm-mongo)
|-- mysql
|-- 1-mysql (1-target, 2-adapter, 3-driver, 9-facade; @internal/mysql is the source of @prisma/orm-mysql)
|-- 2-mariadb (1-target, 2-adapter, 3-driver, 9-facade; @internal/mariadb is the source of @prisma/orm-mariadb)
|-- 3-live-tests → @internal/mysql-live-tests (private, tests only: the ORM live suites run against MySQL and MariaDB, so it depends on both facades)
The extensions domain (packages/3-extensions/) contains ecosystem extensions and compatibility layers:
* 3-extensions
|-- sql-orm-client/ (runtime plane)
| |-- → @internal/sql-orm-client
|-- pgvector/ (multi-plane)
|-- → @internal/extension-pgvector
Clean Architecture layers for Prisma 8:
- Core – target-agnostic contracts, plan metadata, shared operations, runtime kernel.
- Authoring – PSL/TS authoring surfaces plus shared descriptor types that produce contracts.
- Targets – family-specific contract types and emitter hooks.
- Lanes – query DSLs/ORMs that produce AST plans.
- Runtime – per-family runtime implementations that extend
RuntimeCorefrom@internal/framework-components/runtime(core layer). - Adapters – database adapters/drivers and optional compat layers.
Dependencies flow downward (toward core); lateral dependencies within the same layer are permitted. Example: @internal/sql-builder lives in the Lanes layer, so it may use helpers from @internal/sql-relational-core in the same layer, but may not depend on Runtime or Adapters. Optional compat packages live at the edge alongside adapters; they can depend on inner layers but do not form a separate layer.
Core → Authoring → Targets → Lanes → Runtime → Adapters
(lateral deps allowed within each layer)
graph LR
Core[Core] --> Authoring
Authoring --> Targets
Targets --> Lanes
Lanes --> Runtime
Runtime --> Adapters
%% lateral relationships (same ring) shown as loops
Core --> Core
Authoring --> Authoring
Targets --> Targets
Lanes --> Lanes
Runtime --> Runtime
Adapters --> Adapters
Compat --> Compat
style Core fill:#e1f5ff,stroke:#01579b,stroke-width:2px
style Authoring fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
style Targets fill:#fff3e0,stroke:#e65100,stroke-width:2px
style Lanes fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px
style Runtime fill:#fce4ec,stroke:#880e4f,stroke-width:2px
style Adapters fill:#e0f2f1,stroke:#004d40,stroke-width:2px
The runtime ring is a single layer: RuntimeCore (the abstract base) lives on @internal/framework-components/runtime (core layer) and is extended directly by family runtimes (@internal/sql-runtime, @internal/mongo-runtime). See ADR 204.
Within a domain:
- Layers may depend laterally (same layer) and downward (toward core), never upward.
- Example:
@internal/sql-builderlives in the Lanes layer, so it may use helpers from@internal/sql-relational-corein the same layer, but may not depend on Runtime or Adapters.
Cross-domain:
- Cross-domain imports are forbidden except when importing framework packages.
- Example: SQL domain packages can import from framework domain packages, but not from other target families.
Plane boundaries:
- Migration plane (authoring, tooling, targets) must not import runtime plane code.
- Runtime plane may consume artifacts (JSON/manifests) from migration, but not code imports.
- Shared plane must not import from migration or runtime planes.
- Example:
@internal/sql-contract-ts(migration plane) cannot import from@internal/sql-builder(runtime plane).
Plane import constraints are enforced declaratively via planeRules in architecture.config.json. Each plane specifies which planes it can import from (allow) and which are forbidden (forbid), with optional exceptions for temporary refactoring needs.
The innermost layer containing target-family agnostic types and utilities.
packages/1-framework/0-foundation/contract/→@internal/contract- Core contract types + plan metadatapackages/1-framework/1-core/operations/→@internal/operations- Target-neutral operation registry + capability helperspackages/1-framework/1-core/framework-components/→@internal/framework-components- Component descriptors, control-plane types (./control), execution-plane types (./execution), emission SPI types (./emission)packages/1-framework/1-core/errors/→@internal/errors- CLI/runtime error factories and error types (./control)packages/1-framework/1-core/config/→@internal/config- Config authoring types and validation
Dependency Rules: Cannot import from any other layer.
Contract authoring surfaces for creating contracts programmatically.
Framework Domain (Migration Plane):
packages/1-framework/2-authoring/contract/→@internal/contract-authoring- shared target-neutral authoring descriptors (ColumnTypeDescriptor,IndexDef, FK metadata)packages/1-framework/2-authoring/psl-parser/→@internal/psl-parser- PSL parser + IR (future)
SQL Domain (Migration Plane):
packages/2-sql-family/2-authoring/contract-ts/→@internal/sql-contract-ts- SQL TS authoring surface, composed helper DSL, and lowering pipeline
Mongo Domain (Migration Plane):
packages/2-mongo-family/2-authoring/contract-psl/→@internal/mongo-contract-psl- PSL interpretation into Mongo contract inputpackages/2-mongo-family/2-authoring/contract-ts/→@internal/mongo-contract-ts- Mongo TS authoring surface fordefineContract(...)
Dependency Rules: Can import from core/* only. SQL authoring may also import from SQL tooling layer; Mongo authoring may also import from Mongo tooling layer.
Target-family specific emitter hooks and family-provided helpers for CLI assembly.
packages/2-sql-family/3-tooling/emitter/→@internal/sql-contract-emitter- SQL emitter hookpackages/2-sql-family/9-family/→@internal/family-sql- SQL family descriptor and authoring-time family packpackages/2-mongo-family/3-tooling/emitter/→@internal/mongo-emitter- Mongo emitter hookpackages/2-mongo-family/9-family/→@internal/family-mongo- Mongo family descriptor and authoring-time family packpackages/1-framework/3-tooling/cli/src/pack-assembly.ts- Generic assembly functions that loop over descriptors and delegate to family'sconvertOperationManifest()for conversion- Pack entrypoints: use
/controlfor control plane descriptors and helpers (no runtime),/runtimefor factories (runtime only). The app config imports from/controlto keep emit pure.
Dependency Rules: Can import from core/* and authoring/* only.
Lanes consume targets and relational-core helpers to produce AST plans. Packages in this layer may depend laterally on other lane utilities (e.g., shared relational helpers) and on inner layers, but not on runtime/adapter layers.
packages/2-sql-family/4-lanes/relational-core/→@internal/sql-relational-core– shared schema/column builders, operation attachment, AST factoriespackages/2-sql-family/4-lanes/sql-builder/→@internal/sql-builder– the SQL query builder and raw SQL lane
Per-family runtime implementations that extend the abstract RuntimeCore from @internal/framework-components/runtime (core layer). There is no separate target-agnostic runtime package; the kernel collapsed into framework-components per ADR 204.
SQL Domain (Runtime Plane):
packages/2-sql-family/5-runtime/→@internal/sql-runtime– SQL family runtime that extendsRuntimeCorefrom@internal/framework-components/runtimewith SQL adapters (future document runtimes will mirror this)
Mongo Domain (Runtime Plane):
packages/2-mongo-family/7-runtime/→@internal/mongo-runtime– Mongo family runtime that extendsRuntimeCorefrom@internal/framework-components/runtimewith the Mongo adapter
Dependency Rules: Family runtimes import the runtime SPI (RuntimeCore, RuntimeMiddleware, RuntimeExecutor, runWithMiddleware) from @internal/framework-components/runtime (core layer) and may also import from their family's lanes, transport, and adapter packages. There is no separate target-agnostic runtime package; per ADR 204, the runtime kernel collapsed into @internal/framework-components and family runtimes extend it directly.
A database's target pack, adapter and driver are separate packages in packages/3-targets/<db>/. Each spans planes through its entrypoints: src/exports/control.ts (migration), src/exports/runtime.ts (runtime), and shared code under src/core/.
packages/3-targets/postgres/1-target/→@internal/target-postgres- Postgres target pack: descriptor, codecs, data types, migration planner and runnerpackages/3-targets/postgres/2-adapter/→@internal/adapter-postgres- Postgres adapter: lowering, control adapterpackages/3-targets/postgres/3-driver/→@internal/driver-postgres- Postgres driver
In architecture.config.json the target pack and facade are registered in the extensions domain and the adapter, driver and codec testkit in the targets domain. They do not yet share one domain.
Key Principle: Published package name is the import specifier. Directory layout is for humans and guardrails.
- Use the published package name as the only import specifier
- Encode target family in the package name prefix (e.g.,
@internal/sql-...) - Collapse nested directories to hyphenated names (no slashes after scope)
- Keep conventional names for adapters/drivers (e.g.,
@internal/adapter-postgres,@internal/driver-postgres). They are separate packages (target, adapter, driver), grouped inpackages/3-targets/<db>/. - Layers constrain dependencies but don't generally appear in package names
| Directory | Published Package Name |
|---|---|
packages/1-framework/0-foundation/contract/ |
@internal/contract |
packages/1-framework/1-core/operations/ |
@internal/operations |
packages/1-framework/1-core/framework-components/ |
@internal/framework-components |
packages/1-framework/1-core/errors/ |
@internal/errors |
packages/1-framework/1-core/config/ |
@internal/config |
packages/1-framework/2-authoring/contract/ |
@internal/contract-authoring |
packages/1-framework/2-authoring/psl-parser/ |
@internal/psl-parser |
packages/1-framework/3-tooling/cli/ |
@internal/cli |
packages/1-framework/3-tooling/emitter/ |
@internal/emitter |
packages/2-mongo-family/1-foundation/mongo-contract/ |
@internal/mongo-contract |
packages/2-mongo-family/2-authoring/contract-psl/ |
@internal/mongo-contract-psl |
packages/2-mongo-family/2-authoring/contract-ts/ |
@internal/mongo-contract-ts |
packages/2-mongo-family/3-tooling/emitter/ |
@internal/mongo-emitter |
packages/2-mongo-family/4-query/query-ast/ |
@internal/mongo-query-ast |
packages/2-mongo-family/5-query-builders/orm/ |
@internal/mongo-orm |
packages/2-mongo-family/5-query-builders/query-builder/ |
@internal/mongo-query-builder |
packages/2-mongo-family/6-transport/mongo-lowering/ |
@internal/mongo-lowering |
packages/2-mongo-family/6-transport/mongo-wire/ |
@internal/mongo-wire |
packages/2-mongo-family/7-runtime/ |
@internal/mongo-runtime |
packages/2-mongo-family/9-family/ |
@internal/family-mongo |
packages/2-sql-family/1-core/contract/ |
@internal/sql-contract |
packages/2-sql-family/1-core/operations/ |
@internal/sql-operations |
packages/2-sql-family/1-core/schema-ir/ |
@internal/sql-schema-ir |
packages/2-sql-family/2-authoring/contract-ts/ |
@internal/sql-contract-ts |
packages/2-sql-family/3-tooling/emitter/ |
@internal/sql-contract-emitter |
packages/2-sql-family/9-family/ |
@internal/family-sql |
packages/2-sql-family/4-lanes/relational-core/ |
@internal/sql-relational-core |
packages/2-sql-family/4-lanes/sql-builder/ |
@internal/sql-builder |
packages/2-sql-family/5-runtime/ |
@internal/sql-runtime |
packages/3-targets/0-shared/target-package-config/ |
@internal/target-package-config |
packages/3-targets/0-shared/type-implementations/ |
@internal/type-implementations |
packages/3-targets/mongo/1-target/ |
@internal/target-mongo |
packages/3-targets/mongo/2-adapter/ |
@internal/adapter-mongo |
packages/3-targets/mongo/3-driver/ |
@internal/driver-mongo |
packages/3-targets/postgres/1-target/ |
@internal/target-postgres |
packages/3-targets/postgres/2-adapter/ |
@internal/adapter-postgres |
packages/3-targets/postgres/3-driver/ |
@internal/driver-postgres |
packages/3-targets/sqlite/1-target/ |
@internal/target-sqlite |
packages/3-targets/sqlite/2-adapter/ |
@internal/adapter-sqlite |
packages/3-targets/sqlite/3-driver/ |
@internal/driver-sqlite |
packages/3-targets/mysql/1-mysql/1-target/ |
@internal/target-mysql |
packages/3-targets/mysql/1-mysql/2-adapter/ |
@internal/adapter-mysql |
packages/3-targets/mysql/1-mysql/3-driver/ |
@internal/driver-mysql |
packages/3-targets/mysql/1-mysql/9-facade/ |
@internal/mysql |
packages/3-targets/mysql/2-mariadb/1-target/ |
@internal/target-mariadb |
packages/3-targets/mysql/2-mariadb/2-adapter/ |
@internal/adapter-mariadb |
packages/3-targets/mysql/2-mariadb/3-driver/ |
@internal/driver-mariadb |
packages/3-targets/mysql/2-mariadb/9-facade/ |
@internal/mariadb |
packages/3-targets/mysql/3-live-tests/ |
@internal/mysql-live-tests |
packages/3-extensions/sql-orm-client/ |
@internal/sql-orm-client |
packages/3-extensions/pgvector/ |
@internal/extension-pgvector |
- Within a domain, layers may depend laterally (same layer) and downward (toward core), never upward - This is enforced by directory structure and import validation
- Cross-domain imports are forbidden except when importing framework packages - SQL domain packages can import from framework domain, but not from other target families
- Migration plane must not import runtime plane code - Authoring, tooling, and targets (migration plane) cannot import from lanes, runtime, or adapters (runtime plane)
- Runtime plane may consume artifacts (JSON/manifests) from migration, but not code imports - Runtime packages can read contract.json and manifest.json files, but cannot import TypeScript code from migration plane packages
- Directory placement dictates allowed dependencies (domain + layer + plane); package name dictates how consumers import
core/*→ cannot import from any other layerauthoring/*→ can import fromcore/*only2-sql-family/3-tooling/*→ can import from1-core/*and2-authoring/*only2-mongo-family/3-tooling/*and2-mongo-family/9-family→ can import from1-core/*and2-authoring/*only2-sql-family/4-lanes/*→ can import from1-core/*,2-authoring/*,2-sql-family/3-tooling/*only2-sql-family/5-runtime→ can import from1-framework/1-core/framework-components(forRuntimeCore/RuntimeMiddleware/runWithMiddleware),2-sql-family/3-tooling/*, and2-sql-family/4-lanes/*only; it never imports a concrete database's packages2-mongo-family/4-query/*,5-query-builders/*,6-transport/*,7-runtime→ follow the same downward-only rule within the Mongo family plus allowed framework imports (notably1-framework/1-core/framework-componentsfor the runtime SPI)3-targets/<db>/2-adapter(SQL databases) → can import from2-sql-family/3-tooling/*and2-sql-family/5-runtimeonly3-targets/mongo/2-adapter→ can import from Mongo family shared/runtime layers, not SQL family packages
- Framework domain packages are target-agnostic and can be imported by any target family
- SQL domain packages can import from framework domain and their own SQL family packages
- Mongo domain packages can import from framework domain and their own Mongo family packages
- Family packages cannot import from other target families (e.g.,
sql/*cannot importmongo/*, andmongo/*cannot importsql/*) - SQL family packages use the
@internal/sql-...prefix and Mongo family packages use the@internal/mongo-...prefix for discoverability
Use curated subpath exports to keep public API stable across internal moves:
{
"name": "@internal/sql-builder",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./sql": {
"types": "./dist/exports/sql.d.ts",
"import": "./dist/exports/sql.js"
},
"./schema": {
"types": "./dist/exports/schema.d.ts",
"import": "./dist/exports/schema.js"
},
"./param": {
"types": "./dist/exports/param.d.ts",
"import": "./dist/exports/param.js"
}
},
"files": ["dist"]
}The pnpm-workspace.yaml includes patterns for all packages:
packages:
- packages/**
- examples/*
- test/**The numbered directory prefixes ensure packages appear in dependency order when browsing the filesystem.
Import dependencies are validated using Dependency Cruiser:
pnpm lint:depsDependency Cruiser:
- Scans all TypeScript files in
packages/ - Validates imports against domain, layer, and plane rules
- Reports violations with detailed context
- Can be run locally or in CI
- Supports incremental checks for lint-staged hooks
- Enforces the dependency direction:
core → authoring → targets → lanes → runtime → adapters
Implementation:
- Uses data-driven configuration from
architecture.config.json - Maps package directory globs to {domain, layer, plane} based on configuration
- Converts glob patterns to regex patterns in
dependency-cruiser.config.mjs - Uses TypeScript path resolution for accurate module resolution
- Allows same-layer imports (e.g.,
sql-buildercan import fromsql-relational-core) - Enforces cross-domain rules (only framework can be imported cross-domain)
- Enforces plane boundaries via declarative
planeRulesinarchitecture.config.json:- Shared plane cannot import from migration or runtime
- Migration plane cannot import from runtime
- Runtime plane cannot import from migration (with documented exceptions)
Status: Import validation checks imports between files of the same package. It does not yet see imports from one workspace package to another: those resolve to dist/, which is excluded. Plane rules are defined declaratively in architecture.config.json rather than hardcoded in the dependency cruiser config.
When adding a new package:
- Choose the correct domain (framework or target family like sql, or targets for extension packs)
- Choose the correct layer based on dependencies and purpose
- Choose the correct plane (migration, runtime, or shared)
- Follow naming conventions - use hyphenated names, encode family in prefix
- Add package mapping to
architecture.config.jsonwith domain/layer/plane- For multi-plane packages, add separate, non-overlapping globs for each plane (e.g.,
src/core/*.tsfor shared,src/core/migrations/**andsrc/exports/control.tsfor migration,src/exports/runtime.tsfor runtime). Every source file must match exactly one glob
- For multi-plane packages, add separate, non-overlapping globs for each plane (e.g.,
- Add project references to
tsconfig.base.json. - Add workspace pattern to
pnpm-workspace.yamlif needed - Create README.md documenting purpose, dependencies, and architecture with domain/layer/plane labels
- Run import check to verify no violations
Some packages span multiple planes (e.g., adapters that have both control plane entry points and runtime code). These packages use a structured layout:
src/core/*.ts: Shared plane code that can be imported by both migration and runtime planessrc/core/migrations/**: Migration plane code (planner, runner, operations)src/exports/control.ts: Migration plane entry point (control plane descriptors)src/exports/runtime.ts: Runtime plane entry point (runtime factories)
Example: @internal/adapter-postgres spans three planes:
packages/3-targets/postgres/2-adapter/src/core/*.ts→ domain:targets, layer:adapters, plane:sharedpackages/3-targets/postgres/2-adapter/src/exports/control.ts→ domain:targets, layer:adapters, plane:migrationpackages/3-targets/postgres/2-adapter/src/exports/runtime.ts→ domain:targets, layer:adapters, plane:runtime
Note: Target, adapter, and driver are separate packages, grouped in packages/3-targets/<db>/, so an application can replace one of them. The adapter package uses multi-plane entrypoints to support both control plane configuration (migration plane) and runtime usage (runtime plane) while keeping shared core code (shared plane) accessible to both.
This structure allows the same package to provide both control plane configuration (migration plane) and runtime implementation (runtime plane) while keeping shared code (core) accessible to both.
Directory Structure Status: ✅ Complete
The package layering structure uses numbered directory prefixes for visual hierarchy:
- All domain directories created with numbered prefixes (
1-framework/,2-sql-family/,2-document/,3-targets/,3-extensions/) - Each database's packages live in one folder under
3-targets/(ADR 278) - All layer directories created with numbered prefixes (e.g.,
1-core/,2-authoring/,3-tooling/,4-lanes/,5-runtime/) - Plane subdirectories removed (
shared/,migration/,runtime/intermediate directories flattened) - Workspace configuration updated (
pnpm-workspace.yaml) - TypeScript project references updated (
tsconfig.base.json) - Import validation configured (Dependency Cruiser with
dependency-cruiser.config.mjs) - Architecture configuration file updated (
architecture.config.json) pnpm lint:depsscript validates dependency direction
Package Layout:
packages/1-framework/- Framework domain (target-agnostic)packages/2-mongo-family/- Mongo family domainpackages/2-sql-family/- SQL family domainpackages/2-document/- Document family domain (placeholder)packages/3-targets/- Targets domain, one folder per database (target, adapter, driver, codec testkit, facade)packages/3-extensions/- Extensions domain (compat layers, extension packs)
The numbered prefixes ensure:
- Packages appear in dependency order when browsing the filesystem
- Visual reinforcement of the architecture hierarchy
- Lower numbers can be imported by higher numbers, never the reverse