Magic flows
A C4 diagram shows what exists. A Magic flow shows what happens: one request or one journey, hop by hop, through the elements and connections of the model. You build it from steps, play it on the diagram, keep it checked against the model, and turn it into a sequence diagram when you need one.
Play a flow on the diagram
- Open Instruments in the bar at the top left and choose Magic flows. The flow manager opens.
- Pick a flow in the list on the left and press Play above its steps.
- The editor goes to the level the flow lives on. The player sits in the top left corner: the flow name, the step number (for example 2 / 3), the current hop with its two ends, and Previous and Next. On the diagram, the two elements of the hop and the connection between them light up and the rest dims.
The arrow keys step back and forth, A toggles the whole flow, and Esc closes the player.
What the player does at each kind of step:
- Plain step. One hop. Next goes on.
- OR. Exactly one branch happens. The player says Choose a branch and lists the branches with their first step. Click one to play it; Change branch goes back to the choice. A branch can be several steps long: the card says how many.
- A fork inside a branch. When a branch has its own fork, the player asks again once you reach it. Step numbers show the depth:
2a.1is the first step of branchaof stage 2,2a.2bis branchbof a fork inside it. - Parallel. All branches happen together. The player shows every hop of the stage at once and lights all of them up.
- Link to another flow. Playback moves to the linked flow and goes on there; the player shows that flow's name. A link in the middle of a flow offers Play on into this flow.
The buttons on the right of the player:
- Show the whole flow lights up every step of the flow on the current level at once. The player then reads Whole flow on this level and the number of steps. Back to the current step returns.
- Play on a board of its own (see below).
- Compare this flow opens the comparator on this flow (see Versions and branches).
- Close ends playback and returns to where you pressed Play.
You can also start a flow from the diagram: a block that takes part in flows has a flow badge ("2 Magic flow(s) — open list"). Click it for the list of flows that pass through that element.
Play on a board of its own
On a busy diagram the participants of a flow can be far apart or on different levels. Play on a board of its own draws a separate board with only the elements the flow touches, laid out in the order the flow visits them, including elements of other systems. Playback works the same way: Next, OR choices, parallel stages. Play on the diagram switches back.
Build a flow
Create a flow
- In the flow manager, press the plus on the Magic flows row of the list (New Magic flow).
- Give it a Name and, if you like, a Description.
- Add steps with Add step under the list of steps.
- Press the save button in the manager's bar. If you leave with unsaved changes, the manager asks whether to save them.
The list groups flows by the system they run through and can be searched, sorted and filtered by status.
Set up a step
Select a step. Its Properties are on the right:
- Step name and What happens on this hop.
- From and To: press Pick a participant. You can pick a system or a container from this project, or from another project in a shared domain. Reverse direction swaps the two ends.
- Connections on this hop: which connection between the two ends the hop uses.
- Endpoints on this hop and Channels on this hop: the API endpoints and broker channels involved, when the ends have them.
A step with an end still empty shows a warning: "Nothing picked for … yet", and the player cannot show it on the diagram.
Parallel steps, OR and forks inside a branch
Every step has a … menu (Step actions). What it offers depends on where the step is:
- Add parallel branch: a hop that runs at the same time as this one. The step and the new one become a parallel stage ("These hops play together — async or fan-out").
- Add OR branch: an alternative to this step. Exactly one of them plays ("Exactly one of these hops plays — exclusive choice").
- Add a step to this branch: makes a branch longer than one step.
- Parallel fork inside this branch and OR fork inside this branch: a fork within a branch, for questions like "if the card is charged, the payment is either approved or declined".
- Make sequential: takes the step out of its branch.
- Add documentation to this step: a Markdown page that belongs to this one step. In the player, a step with documentation has a button to open it.
- Delete step.
Steps can also be moved up and down. The graph to the left of the steps shows the shape of the flow: a line for each branch, and the numbers 1, 2a.1, 2a.2b, 3b.2 for where each step sits.
Link to another flow
A flow can hand playback to another flow, so a long journey can be split into parts: Checkout, then Delivery. Add a step of the kind Link to another flow and pick the project and the flow to continue into. The step reads Continues into and the name of that flow. When playback reaches the link, it continues in that flow.
Documents and sequence diagrams of a flow
The manager has two side panels next to the properties: Documentation and Sequences. In each, Attach links an existing documentation page or sequence diagram of the project to the flow.
Check a flow against the model
The model changes after a flow is written: elements get renamed, connections change, things get deleted. Each flow remembers what it relied on when someone last confirmed it, and shows a status in the list and above its steps:
| Status | What it means |
|---|---|
| not checked | Nobody has confirmed the flow yet. Nothing it uses is missing. |
| checked | Confirmed, and nothing it uses has changed since. |
| needs a look | Something it uses has changed since the check: a connection's technology, an endpoint, a channel. |
| broken | It points at something that is no longer in the model, so it cannot play as drawn. |
To check a flow:
- Open it in the manager. The filters at the top of the list show how many flows are in each status.
- Expand Issues above the steps. Each line names what moved and how: "changed since the last check" with the old and the new value, "renamed since the last check", "no longer in the model — used by N steps", "no connection between these two in the model", or "nothing picked for …" for an empty end.
- Fix the steps, or, if the flow is still right, press Still valid (Mark checked for a flow that was never checked). The status becomes checked.
A flow with an empty end in any step cannot be marked checked until both ends of every step are filled in. Participants from another project are listed as "lives in another project — cannot be checked from here".
Make a sequence diagram from a flow
- In the flow manager, open the Sequences panel on the right (Show sequences panel).
- Press Make magic sequence.
Viaduct writes a PlantUML sequence diagram from the steps: the participants in the order they appear, one message per hop, par for parallel stages and alt for OR. It is attached to the first container or component of the flow (a service is preferred over a database) and listed in the panel, where Expand shows it larger. It also appears in the sequence diagram manager.
When the steps change, the button becomes Regenerate magic sequence. Regenerating overwrites the generated diagram only. Diagrams you wrote yourself and attached with Attach are left alone.