Complete SEA™ DSL examples for common use cases.
@namespace "com.example.ecommerce"
@version "1.0.0"
// Entities
Entity "Customer" in ecommerce
Entity "Order" in ecommerce
Entity "Product" in ecommerce
Entity "Inventory" in ecommerce
// Resources
Resource "Money" USD in ecommerce
Resource "OrderItem" units in ecommerce
// Command Flows
Flow "PlaceOrder"
@cqrs { "kind": "command" }
@tx { "transactional": true }
@idempotency { "enabled": true, "key": "orderId" }
from "Customer" to "Order" quantity 1
Flow "ProcessPayment"
@cqrs { "kind": "command" }
@tx { "transactional": true }
from "Customer" to "Inventory"
// Event Flows
Flow "OrderPlaced"
@cqrs { "kind": "event" }
@outbox { "mode": "required" }
from "Order" to "EventBus"
// Query Flows
Flow "GetOrderHistory"
@cqrs { "kind": "query" }
@read_model { "name": "OrderProjection" }
from "QueryService" to "ReadStore"
// Policies
Policy order_must_have_items
per Constraint Obligation priority 10
@rationale "Empty orders are invalid"
as: forall o in entities where o.name = "Order": (o.items > 0)
Policy no_negative_payment
per Constraint Prohibition priority 10
as: forall f in flows where f.resource = "Money": (f.quantity >= 0)
// Metrics
Metric "daily_orders" as:
count(o in entities over last 24 "hours" where o.name = "Order": 1)
@window 24 "hours"
@threshold 100
@namespace "com.example.auth"
@version "1.0.0"
// Entities
Entity "User" in auth
Entity "Session" in auth
Entity "TokenStore" in auth
// Resources
Resource "Token" units in auth
Resource "Credential" units in auth
// Roles
Role "Admin" in auth
Role "User" in auth
// Flows
Flow "Login"
@cqrs { "kind": "command" }
@tx { "transactional": true }
from "User" to "Session" quantity 1
Flow "IssueToken"
@cqrs { "kind": "command" }
from "Session" to "TokenStore"
Flow "TokenIssued"
@cqrs { "kind": "event" }
@outbox { "mode": "required" }
from "TokenStore" to "EventBus"
Flow "ValidateToken"
@cqrs { "kind": "query" }
from "Session" to "TokenStore"
// Policies
Policy single_active_session
per Constraint Obligation priority 10
as: forall u in entities where u.name = "User":
count(s in entities where s.name = "Session" and s.userId = u.id: 1) <= 1
Policy token_expiry
per Constraint Obligation priority 10
as: forall t in resources where t.name = "Token": (t.expiresAt > now())
@namespace "com.example.finance"
@version "1.0.0"
// Dimensions and Units
Dimension "Currency"
Unit "USD" of "Currency" factor 1 base "USD"
Unit "EUR" of "Currency" factor 0.92 base "USD"
// Entities
Entity "Account" in finance
Entity "Ledger" in finance
Entity "AuditLog" in finance
// Resources
Resource "Money" USD in finance
// Flows
Flow "Transfer"
@cqrs { "kind": "command" }
@tx { "transactional": true }
@idempotency { "enabled": true, "key": "transferId" }
from "Account" to "Account"
Flow "TransferCompleted"
@cqrs { "kind": "event" }
@outbox { "mode": "required" }
from "Ledger" to "EventBus"
Flow "GetBalance"
@cqrs { "kind": "query" }
@read_model { "name": "AccountBalanceProjection" }
from "QueryService" to "Ledger"
// Relations
Relation "AccountDebited"
subject: "Account"
predicate: "was debited by"
object: "Transfer"
via: flow "Transfer"
// Policies
Policy no_overdraft
per Constraint Prohibition priority 10
@rationale "Account balance cannot go negative"
as: forall a in entities where a.name = "Account": (a.balance >= 0)
Policy transfer_audit
per Constraint Obligation priority 10
as: forall t in flows where t.name = "Transfer":
exists l in entities where l.name = "AuditLog": (l.transferId = t.id)
// Metrics
Metric "daily_volume" as:
sum(t in flows over last 24 "hours" where t.name = "Transfer": t.amount)
@unit "USD"
@threshold 1000000
@namespace "shared"
@version "1.0.0"
// Core infrastructure entities
Entity "CommandBus" in kernel
Entity "QueryBus" in kernel
Entity "EventBus" in kernel
Entity "UnitOfWork" in kernel
Entity "Repository" in kernel
Entity "OutboxPort" in kernel
// Resources
Resource "ExecuteCommand" units in kernel
Resource "ExecuteQuery" units in kernel
Resource "PublishEvent" units in kernel
Resource "ManageTransaction" units in kernel
// Flows
Flow "ExecuteCommand"
@cqrs { "kind": "command" }
from "CommandBus" to "CommandBus" quantity 1
Flow "ExecuteQuery"
@cqrs { "kind": "query" }
from "QueryBus" to "QueryBus" quantity 1
Flow "PublishEvent"
@cqrs { "kind": "event" }
from "EventBus" to "EventBus" quantity 1
Flow "ManageTransaction"
@cqrs { "kind": "command" }
from "UnitOfWork" to "UnitOfWork" quantity 1
// Architectural policy
Policy KernelIndependence
per Constraint Obligation priority 100
@rationale "Kernel must be runnable without shells (ADR-033)"
@tags ["kernel", "architecture"]
as: count(entities) >= 6
Last Updated: January 2026