Sequence: Nested Blocks With Notes

A loop nested in an alt branch, with notes inside the blocks: each block grows to hold its notes and the blocks nested in it, and nested header tabs stack instead of overlapping.

sequence-nested-blocks-with-notes.mmd
sequenceDiagram
  participant A
  participant B
  alt cache hit
    loop every retry
      A->>B: fetch
      Note right of B: waits for the upstream response
    end
  else cache miss
    opt warm up
      B->>B: rebuild
    end
    Note over A,B: done
  end
Output
Sequence diagram, Zombie Mermaid loop [every retry] opt [warm up] alt [cache hit] [cache miss] fetch rebuild waits for the upstream response done A B

More Sequence diagram examples