MEL Domain Basics
A MEL domain names your state, derived values, and allowed actions.
MEL is the authoring format for Manifesto domains. It compiles to data the runtime can run the same way each time.
A Small Domain
mel
domain Counter {
type Label = {
text: string
}
state {
count: number = 0
label: Label = { text: "Counter" }
}
computed doubled = count * 2
action increment() {
onceIntent {
patch count = count + 1
}
}
}What Each Part Means
| Part | Purpose |
|---|---|
domain Counter | Names the domain model |
type Label | Defines a reusable MEL type |
state | Declares source-of-truth data and defaults |
computed | Declares values derived from current state |
action | Declares a typed transition that callers can request |
onceIntent | Makes the action body run once for one submitted action |
patch | Writes the next state through the runtime |
In Your App
typescript
import { createManifesto } from "@manifesto-ai/sdk";
import CounterMel from "./counter.mel";
const app = createManifesto(CounterMel, {}).activate();
await app.action.increment.submit();
const snapshot = app.snapshot();
console.log(snapshot.state.count); // 1
console.log(snapshot.computed.doubled); // 2Common Mistake
MEL is not executed like JavaScript. It defines the domain model. TypeScript code activates that model, submits actions, and reads Snapshots.
Next
Read MEL For App Developers for the small syntax set you need before wiring UI, routes, or agents. Then create the runtime in Creating an App and read it in Reading Snapshots. After that, learn what belongs in State and Computed Values. For full syntax, use the MEL Reference.