Skip to content
Moment — Domain architecture for the AI era
Open Source · FSL-1.1-Apache-2.0

Test your domain
before you code.

Moment is the first toolchain that lets you model, simulate, and validate domain flows before writing a single line of implementation. Write a .moment specification, generate simulation scenarios, and visualize them with Facet — then generate typed TypeScript, tests, docs, and API contracts from the same source of truth.

Part of Complai: SDD Moment Facet Forge

DDD has a testing gap nobody talks about

0

You can't test domain flows before coding

In every other engineering discipline, you validate the design before building. In DDD and Event Sourcing, you go from whiteboard directly to implementation. There is no way to simulate event flows, validate crossing contracts, or test saga orchestration before writing code. Until now.

Domain knowledge scatters on contact with code

Your model lives in the wiki, the types, the tests, the docs, the API spec, and someone's head. Six representations that diverged on day two. No tool connects them.

0%

Cross-context flows are the untested frontier

You test individual commands. You test queries. But the temporal flows between bounded contexts — where events cross boundaries, contracts break, and sagas fail — are never tested.

Before and after Moment

One specification replaces seven manually maintained artifacts.

Without Moment
  • order.types.ts — hand-written interfacesmanual
  • order.aggregate.ts — manual aggregate classmanual
  • order.spec.ts — test stubs from scratchmanual
  • order.feature — Gherkin written by handmanual
  • order-spec.md — docs that driftdrifts
  • order-api.yaml — maintained separatelydrifts
  • facet.json — simulation scenariosn/a
  • 7 files · ~400 lines · always diverging · no simulation possible
With Moment
order.moment You write this — the single source of truth
$ moment generate --all $ moment simulate
  • order.types.ts — typed interfacesgenerated
  • order.aggregate.ts — aggregate contractsgenerated
  • order.spec.ts — crossing assertionsgenerated
  • order.feature — BDD with flowsgenerated
  • order-spec.md — Mermaid diagramsgenerated
  • order-api.yaml — AsyncAPI 3.0generated
  • facet.json — simulation scenariosgenerated
  • 7 files · ~400 lines · always in sync · test before you code
1 specification
6 artifact types
0 drift
100% deterministic

The Moment Pipeline

From specification to production-ready artifacts in four deterministic stages.

.moment
Specification

See it in action

Write your domain specification with flows and crossings. Moment generates typed code, tests, docs, and API contracts.

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
Nothing like this exists in DDD or Event Sourcing

Simulate and visualize your domain
before writing implementation code

Moment is the first tool that bridges specification and implementation with a simulation layer. Generate Facet-compatible scenarios from your .moment file, then visualize event flows, causation chains, and branch paths — all before you write a single aggregate class.

1

Specify

Write your .moment file with contexts, aggregates, flows, crossings, and branches.

.moment
2

Simulate

Run moment simulate to generate scenarios with synthetic events, causation chains, and branch paths.

facet.json
3

Visualize with Facet

See your domain flows rendered as interactive timelines. Validate event causation, crossing contracts, and saga states — before any implementation exists.

Facet
4

Generate & Implement

Now generate typed code, tests, and docs. Your implementation conforms to a domain model that's already been validated.

.ts .spec.ts .feature .md
This workflow doesn't exist anywhere else.

No tool in the DDD or Event Sourcing ecosystem lets you simulate and visually validate event flows, crossing contracts, and saga orchestration from a specification — before you write implementation code. Moment + Facet is the first.

Built for domain-driven teams

Every feature exists to close the gap between domain knowledge and running code.

Single Source of Truth

One .moment file drives your types, tests, documentation, and visualizations. No more scattered domain knowledge.

Automatic Test Derivation

Derive test topologies, simulation scenarios, and negative test cases directly from your specification — no manual test writing.

Drift Detection

AST-level diffing detects when your implementation diverges from the specification. Catch drift before it becomes a bug.

Schema Governance

Four-phase schema lifecycle — Active, Deprecated, End-of-Life, Removed — with consumption tracking and deprecation rules.

AI-Ready via MCP

Model Context Protocol server exposes all Moment capabilities as structured tools for Claude, Copilot, and Cursor.

Watch Mode

Auto-regenerate artifacts on specification changes. Deterministic output means clean git diffs every time.

Built on decades of domain-driven design

Moment stands on the shoulders of the DDD community — Evans, Young, Brandolini, Vernon, Tune, Khononov — and encodes their patterns into a toolchain that enforces what books can only recommend.

10
packages
core, derive, generate, emit-ts, sync, schema, viz, harness, mcp, cli
20+
CLI commands
parse, derive, generate, emit, watch, drift, reconcile, viz, and more
FSL
licensed
Source-available now, converts to Apache 2.0 after two years per version
MCP
AI-ready
Model Context Protocol server for Claude, Copilot, and Cursor integration

Get up and running

terminal
$ git clone https://github.com/mmmnt/mmmnt.git
$ cd mmmnt && pnpm install
$ pnpm turbo build
# Parse a .moment spec and generate all artifacts
$ moment parse spec.moment
$ moment derive
$ moment generate --all

Common questions

Does this lock me into Moment?

No. Generated artifacts are standard TypeScript, Gherkin, Markdown, and AsyncAPI. If you stop using Moment, your generated code still works. The .moment file is the only Moment-specific artifact.

What if the specification is wrong?

Moment includes drift detection (moment drift) that catches when your implementation diverges from the spec. Fix the spec or reconcile the implementation — either direction works.

Can I adopt incrementally?

Yes. Start with one bounded context. Moment generates artifacts alongside your existing code. You can adopt context by context, aggregate by aggregate.

How mature is this?

Moment is at milestone 3 (derivation + generation pipeline). The parser, type emitter, Gherkin generator, test scaffold emitter, and spec doc generator are all functional. Schema governance, viz, and MCP server are in active development.

Do I need to know DDD?

Basic familiarity with aggregates, commands, and events helps. But the .moment DSL is designed to be readable without DDD expertise — it reads like a domain description, not an academic paper.

What about the license?

FSL-1.1-Apache-2.0: source-available now with full read/use rights. Two years after each release, it converts to Apache 2.0 (fully permissive). The only restriction during the FSL period is competing commercial use.