Choreo.Lab.DSL.Domain (Choreo v0.12.0)

Copy Markdown View Source

Experimental Livebook-friendly DSL for sketching DDD domain models.

This Lab DSL compiles to the stable, pipe-first Choreo.Domain builders and returns an ordinary %Choreo.Domain{}. It supports strategic context maps, tactical event-storming flows, Wlaschin-style workflow/type sketches, and named scenarios for Event Modeling projections.

Examples

iex> import Choreo.Lab.DSL.Domain
...> model = domain do
...>   checkout = context_boundary("Checkout")
...>   customer = actor("Customer")
...>   place_order = command("Place Order", cluster: checkout)
...>   order = aggregate("Order", cluster: checkout, invariants: ["Cannot place an empty order."])
...>   placed = event("Order Placed", cluster: checkout)
...>   summary = read_model("Order Summary", cluster: checkout)
...>
...>   customer ~> place_order |> initiates("starts")
...>   place_order ~> order |> handles("validates")
...>   order ~> placed |> emits("records")
...>   placed ~> summary |> projects_to("updates")
...> end
iex> Choreo.Domain.nodes(model).order.type
:aggregate

Strategic context maps can use context nodes and context-mapping relationships:

ordering = context("Ordering", subdomain: :core)
billing = context("Billing", subdomain: :supporting)
customer_supplier ordering ~> billing, "Invoice requests"

Tactical edges can use generic, typed, or pipe-modified forms:

actor ~> command |> initiates("submits")
command ~> aggregate |> handles("validates")
aggregate ~> event |> emits("records")
event ~> policy |> triggers("reacts")
event ~> read_model |> projects_to("updates")
edge upstream ~> downstream, translates_via: "ACL"

Summary

Functions

Builds a %Choreo.Domain{} from a compact Lab DSL block.

Returns the vocabulary supported by the domain DSL.

Compatibility alias for taxonomy/0.

Types

cluster_decl()

@type cluster_decl() :: %{id: String.t(), builder: atom(), opts: keyword()}

edge_decl()

@type edge_decl() :: %{
  from: Yog.node_id(),
  to: Yog.node_id(),
  opts: keyword(),
  builder: atom()
}

node_decl()

@type node_decl() :: %{id: Yog.node_id(), builder: atom(), opts: keyword()}

scenario_decl()

@type scenario_decl() :: %{name: atom(), opts: keyword()}

Functions

acl(arg1 \\ nil, arg2 \\ nil, opts \\ [])

actor(arg1 \\ nil, arg2 \\ nil, opts \\ [])

aggregate(arg1 \\ nil, arg2 \\ nil, opts \\ [])

anti_corruption(arg1 \\ nil, arg2 \\ nil, opts \\ [])

anti_corruption_layer(arg1 \\ nil, arg2 \\ nil, opts \\ [])

boundary(arg1 \\ nil, arg2 \\ nil, opts \\ [])

bounded_context(arg1 \\ nil, arg2 \\ nil, opts \\ [])

command(arg1 \\ nil, arg2 \\ nil, opts \\ [])

conformist(arg1 \\ nil, arg2 \\ nil, opts \\ [])

connects(arg1 \\ nil, arg2 \\ nil, opts \\ [])

context(arg1 \\ nil, arg2 \\ nil, opts \\ [])

context_boundary(arg1 \\ nil, arg2 \\ nil, opts \\ [])

context_cluster(arg1 \\ nil, arg2 \\ nil, opts \\ [])

customer_supplier(arg1 \\ nil, arg2 \\ nil, opts \\ [])

data_type(arg1 \\ nil, arg2 \\ nil, opts \\ [])

domain(list)

(macro)

Builds a %Choreo.Domain{} from a compact Lab DSL block.

domain(opts, list)

(macro)

domain_event(arg1 \\ nil, arg2 \\ nil, opts \\ [])

emits(arg1 \\ nil, arg2 \\ nil, opts \\ [])

entity(arg1 \\ nil, arg2 \\ nil, opts \\ [])

event(arg1 \\ nil, arg2 \\ nil, opts \\ [])

external(arg1 \\ nil, arg2 \\ nil, opts \\ [])

external_system(arg1 \\ nil, arg2 \\ nil, opts \\ [])

handles(arg1 \\ nil, arg2 \\ nil, opts \\ [])

initiates(arg1 \\ nil, arg2 \\ nil, opts \\ [])

notifies(arg1 \\ nil, arg2 \\ nil, opts \\ [])

open_host_service(arg1 \\ nil, arg2 \\ nil, opts \\ [])

policy(arg1 \\ nil, arg2 \\ nil, opts \\ [])

process(arg1 \\ nil, arg2 \\ nil, opts \\ [])

projection(arg1 \\ nil, arg2 \\ nil, opts \\ [])

projects_to(arg1 \\ nil, arg2 \\ nil, opts \\ [])

published_language(arg1 \\ nil, arg2 \\ nil, opts \\ [])

read_model(arg1 \\ nil, arg2 \\ nil, opts \\ [])

saga(arg1 \\ nil, arg2 \\ nil, opts \\ [])

scenario(arg1 \\ nil, arg2 \\ nil, opts \\ [])

shared_kernel(arg1 \\ nil, arg2 \\ nil, opts \\ [])

taxonomy()

@spec taxonomy() :: %{
  clusters: [atom()],
  nodes: [atom()],
  edges: [atom()],
  events: [atom()],
  modifiers: [atom()],
  options: [atom()]
}

Returns the vocabulary supported by the domain DSL.

iex> taxonomy = Choreo.Lab.DSL.Domain.taxonomy()
iex> :aggregate in taxonomy.nodes
true
iex> :context_boundary in taxonomy.clusters
true
iex> :emits in taxonomy.edges
true

translates_via(arg1 \\ nil, arg2 \\ nil, opts \\ [])

triggers(arg1 \\ nil, arg2 \\ nil, opts \\ [])

type(arg1 \\ nil, arg2 \\ nil, opts \\ [])

user(arg1 \\ nil, arg2 \\ nil, opts \\ [])

verbs()

@spec verbs() :: map()

Compatibility alias for taxonomy/0.

workflow(arg1 \\ nil, arg2 \\ nil, opts \\ [])