Skip to content

Examples

Real domain specifications and all seven artifact types Moment generates from them. Every output is deterministic — the same input always produces the same result.

.moment TypeScript Test Scaffold Gherkin Spec Doc AsyncAPI facet.json
What Moment derived:2 contexts2 aggregates3 commands3 events1 flow1 crossing
context "Ordering" [Core]

  aggregate "Order"
    identity orderId: UUID

    command PlaceOrder
      input customerId: UUID, items: OrderItem[]
      precondition orderNotPlaced: "Order has not already been placed"
      emits OrderPlaced

    command CancelOrder
      input orderId: UUID, reason: string
      precondition orderNotShipped: "Order must not have been shipped"
      emits OrderCancelled

    event OrderPlaced
      orderId: UUID
      customerId: UUID
      items: OrderItem[]
      placedAt: DateTime

    event OrderCancelled
      orderId: UUID
      reason: string
      cancelledAt: DateTime

  value-object OrderItem
    productId: UUID
    quantity: number
    unitPrice: Money

  invariant ORD-01 "Order must contain at least one item"
    scope Order

context "Fulfillment" [Supporting]

  aggregate "FulfillmentRequest"
    identity fulfillmentId: UUID

    command InitiateFulfillment
      input orderId: UUID, items: OrderItem[]
      emits FulfillmentInitiated

    event FulfillmentInitiated
      fulfillmentId: UUID
      orderId: UUID
      items: OrderItem[]
      initiatedAt: DateTime

  value-object OrderItem
    productId: UUID
    quantity: number
    unitPrice: Money

flow "order-placed"
  description "Order submission triggers fulfillment"

  lane ordering "Ordering" [Core]
  lane fulfillment "Fulfillment" [Supporting]

  moment "Order submission"
    ordering: PlaceOrder
    ordering: OrderPlaced crosses-to fulfillment via CustomerSupplier
      contract
        orderId: UUID [required]
        items: OrderItem[] [required]

  moment "Fulfillment initiation"
    fulfillment: InitiateFulfillment
      triggered-by OrderPlaced
    fulfillment: FulfillmentInitiated

Understanding the outputs

.moment

The domain specification you write — contexts, aggregates, flows, crossings, sagas, policies, and branches.

TypeScript

Generated interfaces with discriminated unions, readonly fields, aggregate contracts, and barrel exports.

Test Scaffold

Pre-populated Vitest files with crossing assertions, branch coverage stubs, and saga/policy test cases.

Gherkin

BDD scenarios with crossing contracts, branch paths, saga lifecycle, policy chains, and invariant violations.

Spec Doc

Markdown with Mermaid context maps, sequence diagrams, domain model reference, and crossing boundary tables.

AsyncAPI

Event-driven API contracts for crossing events in AsyncAPI 3.0 format with typed payload schemas.

facet.json

Facet-compatible simulation scenarios with synthetic events, causation chains, correlation tracking, and branch path resolution.