zenuml
title Place an order
@Actor Client
@Boundary Api
@Entity Orders
Client->Api.place(cart) {
Api->Orders.create(cart) {
return order
}
return confirmation
}
A call that reaches storage
Each extra level of braces is another participant doing work before the outer call can return.
zenuml
title Save a draft
@Actor Author
@Boundary Editor
@Entity Drafts
Author->Editor.save(text) {
Editor->Drafts.upsert(text) {
return id
}
return id
}
Two sequential calls
Calls one after another, without nesting, are two messages in order. Nest only the work that happens inside a call.
zenuml
title Sign in
@Actor User
@Boundary Api
@Entity Directory
User->Api.login(email) {
Api->Directory.find(email) {
return user
}
return session
}
What is a ZenUML Diagram?
ZenUML is an alternate sequence syntax that Mermaid renders with the ZenUML diagram type. You still have actors and participants, but a message is a method call: Client->Api.place(order) { ... }. The braces are the work that happens before the call returns. return sends a value back. Annotations such as @Actor, @Boundary, and @Entity change how a participant is drawn. Use ZenUML when the interaction really is a call stack. Use a classic sequence diagram when you want arrows, notes, and alt/loop fragments.
When to use it
Use ZenUML for a service call tree you want to read like code. Use a sequence diagram when the interaction has branches, loops, or several independent replies. Use a class diagram when you need the types rather than one execution.
ZenUML is a sequence-diagram syntax that reads like method calls. Start the diagram with zenuml, declare participants, and write Caller->Callee.method() { } for each call.
Write return and the value inside the braces of the call that is returning. The return belongs to that call, so it sits before the closing brace.
They set the participant's stereotype before it is used. @Actor is a person, @Boundary is an entry point such as a controller, and @Entity is a thing that holds state. The names are the participants you call afterward.
Use ZenUML when the interaction is a nested call stack and you want it to look like code. Use sequenceDiagram when you need dashed replies, notes, autonumber, or alt and loop blocks.
No. A diagram is one syntax or the other. If you need ->> and alt, start the diagram with sequenceDiagram instead of zenuml.
Ready to create your own zenuml diagram?
Open the editor with this example pre-loaded and start customizing.