Domain Designer Features and Usage
This document is the technical guide for all Domain Designer MVP capabilities inside:
apps/service-management/
It covers what each feature does and how to use it in practice.
1) Canvas and Navigation
Features:
- Domain rectangles (color-coded)
- Entity cards inside domains
- Pan, zoom, fit, reset
- Snap-to-grid
- Compact/full view
- Large-canvas performance mode
- Mini-map navigation
- Undo/redo
How to use:
- Create domains and entities from the left panel.
- Drag domain headers and entity headers to reposition.
- Use:
Ctrl/Cmd + mouse wheelfor zoomSpace + dragfor panningFitandReset Viewfor quick framing
- Turn on
Large Canvasfor high-density diagrams. - Use the mini-map to focus a domain quickly.
2) Relationship Design
Features:
- Form-based relationship creation (
from,to, cardinality) - Pick-on-canvas mode
- Anchor-to-anchor drag connectors
- Relationship reverse
- Auto FK generation
- Label offset controls (
x,y) - Bend path controls (
bendX,bendY) - Anchor behavior (
auto,center) - Routing style (
curved,orthogonal)
How to use:
- Select source and target entities and click
Connect. - Or click
Pick On Canvasand select entities directly. - For anchor-aware connections, drag from edge anchors (
top/right/bottom/left) between entities. - Select a relationship in the list and tune:
- label offset
- bend points
- anchor behavior
- Click
Save Relationship.
3) Domain Context Metadata
Per-domain metadata:
- Ubiquitous language
- Owner team
- Upstream dependencies
- Downstream dependencies
- Integration channel
- Package dependencies
- Shared value objects
How to use:
- Select a domain.
- Fill values in
Bounded Context. - Click
Save Context.
These fields are persisted in the designer state and exported through JSON/package flows.
4) Entity Editing and Templates
Entity-level features:
- Rename, move, duplicate, delete
- Aggregate root flag
- Invariants editor
- Field CRUD with OpenAPI-aligned metadata
- Field templates (
tenantRef,auditTrail,softDelete,contactPack) - Entity templates:
crudAggregateeventSourcedreferenceDatatenantOwned
How to use:
- Select an entity.
- Use Entity Inspector for rename/move/rules.
- Add fields manually or apply field templates.
- Apply entity templates from
Entitiespanel.
5) RBAC Policy Mapping
Per-entity action policy, aligned with the tenant RBAC authorization contract
(TENANT-RBAC-AUTHORIZATION-CONTRACT.md, JUM-477):
- Actions:
listgetByIdcreateupdatedelete
- Role toggles (the contract’s normalized roles):
superadminadminuser
- Tenant scope: derived from the selected roles, not a free flag. The
runtime (
Rbac.ts/TenantAuthorizationPolicy.ts) constrainsadminanduserprincipals to their own organization and givessuperadmina global boundary — there is no independent tenant-scope knob to honour, so the editor displays the derived value as a read-only checkbox. Stored policies are repaired to the derived value on load. - Legacy direct scopes (
read_user,create_organization, …) remain runtime-supported and survive import/export, but are not editable in the inspector; validation accepts them as contract-expressible. - A role outside the contract vocabulary is rejected at save time with an
actionable message, and model validation reports any such stored role as an
errorso the export quality gate blocks it instead of dropping it.
How to use:
- Select entity and action.
- Mark allowed roles; the tenant-scope indicator follows the roles.
- Click
Save RBAC Rule. - Review generated matrix in the RBAC list.
6) Message Contract Designer
Supported contract types:
eventcommandrequestresponse
Contract fields:
- name
- type
- channel/topic
- version
- payload schema (JSON editor)
How to use:
- Select entity.
- Fill contract name/type/channel/version.
- Click
Add Contract. - Use
payloadbutton to edit schema JSON.
Exports include these contracts in:
- OpenAPI extension (
x-message-contracts) - AsyncAPI export
7) OpenAPI Advanced Composition
Per-entity controls:
oneOf,allOf,anyOf- schema refs list
- external
$reflist - discriminator property
How to use:
- Select entity.
- Choose composition mode.
- Add schema refs and optional external refs.
- Define discriminator if needed.
- Save composition.
8) Validation, Quality Gate, and Diff
Features:
- Model checks with severity:
errorwarninfo
- Configurable minimum severity filter
- Export block on critical issues
- Schema baseline save/clear
- Schema diff and migration hints
How to use:
- Click
Validate Model. - Adjust severity filter if needed.
- Enable
block export on critical issuesto enforce quality gate. - Save a baseline, then run diff to detect changes.
9) Example and Code Generation
Generated outputs:
- Request/response payload examples
- Code skeleton preview:
- model
- repository port
- use case
- controller
- handler
How to use:
- Select an entity for focused output, or keep none selected for full-canvas output.
- Click:
Generate ExamplesCode Preview
10) Export and Import Targets
Export:
- JSON model
- OpenAPI 3.1
- Markdown
- JSON Schema
- AsyncAPI
- Boilerplate bundle
- Domain package
Import:
- JSON model
- OpenAPI 3.1
- Domain package
How to use:
- Use export buttons in
Exportpanel. - Use import buttons for JSON/OAS/package.
- For package export, selected domain is used as source package.
10.1) OAS 3.1 export contract (Requirement 036, JUM-474)
The OpenAPI 3.1 export produces a document compliant with Requirement 036 and
the route-resolution check (ci-cd/check-oas-route-resolution.js):
- Every operation carries a unique
operationIdon the canonicalspec/1.0.0.ymlverb scheme (getAll*,create*,get*ById,update*,delete*), qualified by the schema name (getAllBilling_Invoice). - Request bodies reference
RequestCreate<Schema>/RequestUpdate<Schema>port input objects via$ref; 2xx responses reference the entity schema, its<Schema>ArrayOfwrapper orResourceDeleteResponse. No inline request/response schemas, and every referenced schema has a description. - Port input/output wrappers are marked
'x-port-object': trueand skipped on OAS import, so a round-trip creates no phantom entities. - Error responses use the canonical
ERROR-CONTRACTS-AND-RESPONSEScodes (400/401/403/404/409). - Entities whose names collapse to the same OAS schema name or route path
(for example
Foo BarvsFoo-Bar) fail the export quality gate instead of silently overwriting each other in the document.
10.2) Lossless OAS round-trip (JUM-478)
The OAS crossing is a contract between the exporter and the importer: what
OAS cannot express natively crosses as agreed x- extensions and is
normalized back into entity.meta on import, so export → import → export
reaches a fixed point with an empty model-level loss list (asserted by
designerRoundTrip.test.ts).
x-aggregate-rootandx-invariantscarry the aggregate declaration and invariants when set.x-rbaccarries the entity’s normalized RBAC policy, emitted only when it diverges from the designer default (an absentx-rbacnormalizes back to the default policy, withtenantScopedderived from the roles per the tenant RBAC contract).x-fieldless: truekeeps an entity’s empty field set across the crossing (an unmarked schema without properties still gets the importer’s defaultid/createdAt/updatedAtfields).x-field-flags: { pk, fk, unique }carries a field’s flags only when they diverge from the importer’s name heuristic (id→ PK/unique,*Id→ FK).x-relationsrows carry{ name, fromSchema, toSchema, fromCardinality, toCardinality }— schema names, not model ids — and the importer restores relationships re-keyed to the recomputed entity ids, dropping rows whose endpoints did not import.- Foreign documents without designer markers (the canonical
spec/1.0.0.yml) are recognized by the same port-object conventions:Request<Action>*and*ArrayOfnames,ResourceDeleteResponse, “Port input/output object” descriptions that are not<Name> resourceentity contracts, and non-object schemas never become entities. - Named remaining losses for foreign documents:
example/default/minItems/maxItemsfacets and array item$reflinkages (value-object references flatten to theitemsTypevocabulary), domain bounded-context blocks, canvas positions, and legacy (non-canonical) operationIds.
11) Smoke Coverage
Service Management smoke tests:
apps/backend-template/test/integration/ServiceManagement/domainDesigner.smoke.test.tsapps/service-management/test/unit/mvp.roadmap.features.test.ts
Run:
bun run test:integration:service-management
NODE_ENV=dev bun x jest apps/service-management/test/unit/mvp.roadmap.features.test.ts --runInBand