Quick Start: SEA™ DSL in 15 Minutes

Learn the essentials of SEA™ DSL and write your first domain model.


1. File Structure

Every SEA™ DSL file follows this structure:

@namespace "com.example.domain"   # Scope declarations
@version "1.0.0"                  # File version

import * as Std from "std:core"   # Optional imports

Entity "Name" in domain           # Declarations
Resource "Thing" units in domain
Flow "Action" from "A" to "B"
Policy rule as: (expression)

2. Core Declarations (5 Minutes)

Entity

Domain concepts—things that exist:

Entity "Customer" in sales
Entity "Order" in orders
Entity "Product" in catalog

Resource

Things that flow between entities:

Resource "Money" USD in finance
Resource "Token" units in auth
Resource "OrderItem" units in orders

Flow

Movement or transformation between entities:

Flow "Payment"
  @cqrs { "kind": "command" }
  @tx { "transactional": true }
from "Customer" to "Vendor" quantity 100

CRITICAL: Every Flow requires @cqrs annotation!

Policy

Business rules and constraints:

Policy no_negative_amount
  per Constraint Prohibition priority 10
  @rationale "Amounts cannot be negative"
as: (amount >= 0)

3. Required Annotations (3 Minutes)

Annotation Required On Example
@cqrs Every Flow @cqrs { "kind": "command" }
@namespace File @namespace "com.example.sales"

CQRS Kinds

# Command - changes state
Flow "CreateOrder" @cqrs { "kind": "command" }

# Query - reads state
Flow "GetOrders" @cqrs { "kind": "query" }

# Event - notification
Flow "OrderCreated" @cqrs { "kind": "event" }

4. Your First Complete Model (5 Minutes)

@namespace "com.example.ecommerce"
@version "1.0.0"

// Entities
Entity "Customer" in ecommerce
Entity "Order" in ecommerce
Entity "Inventory" in ecommerce

// Resources
Resource "Money" USD in ecommerce
Resource "OrderItem" units in ecommerce

// 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"

Flow "OrderPlaced"
  @cqrs { "kind": "event" }
  @outbox { "mode": "required" }
from "Order" to "EventBus"

// Policies
Policy order_requires_payment
  per Constraint Obligation priority 10
  @rationale "Orders must be paid before fulfillment"
as: forall o in flows where o.name = "PlaceOrder": 
    exists p in flows where p.name = "ProcessPayment"

5. Validate (2 Minutes)

1
2
3
4
5
6
7
8
# Validate syntax
just sea-validate docs/specs/ecommerce/ecommerce.sea

# Parse to AST
just sea-parse docs/specs/ecommerce/ecommerce.sea

# Lint for @cqrs
python tools/flow_lint.py --strict docs/specs/ecommerce/ecommerce.sea

Next Steps

  1. Declarations deep-dive: Declarations.md
  2. Expressions and policies: Expressions.md
  3. Idioms and patterns: Idioms.md
  4. Domain examples: Domains/

Last Updated: January 2026