NeuralFlow — complete guide

NeuralFlow is the diagram language built into the MD Dashboard engine. You write a fenced ```neuralflow block in any Markdown file the engine serves, and it renders as an SVG diagram — labels in SF Pro Display, all $…$ math in KaTeX.

It draws three families well: - Structure charts — network / architecture / status topologies (groups, status colours, routed links). - Flow diagrams — neural nets and pipelines with math in the nodes. - Flowcharts / decision charts — one flowchart line and the whole layout (sizes, lanes, elbows, yes/no colours) is derived; see §6.

Everything below is live: each example is a real block, so open this file in the dashboard to see it rendered.


1. Anatomy of a block


<div class="neuralflow" data-neuralflow-source="direction LR              ← diagram options (optional; sensible defaults)&#10;node A [Hello | world]    ← nodes&#10;node B [Next]&#10;A --&gt; B : link label      ← edges"></div>

2. Nodes

node ID [Title | Detail] OPTION=VALUE OPTION=VALUE …

Node options

Option Values Meaning
status= ok warn err crit off info Semantic colour (green/yellow/pink/red/gray/blue).
shape= box (default) diamond circle Node shape.
fill= any CSS colour Background colour (overrides status).
stroke= any CSS colour Border/accent colour (alias: color=).
w= integer px Fixed width (else auto).
h= integer px Fixed height (else auto).
level= integer Pin the node to a specific column (LR) / row (TB).
push= signed px Offset this node along the flow axis — positive pushes it further along (longer incoming lines, shorter outgoing), negative pulls it back. Per-line length control that layergap (whole column) can't give; put it on a fan-out leaf to set that one line's length. Node keeps its column for edge routing.
type= input operation activation output bias Neural-diagram styling (line/shape only).

3. Edges

FROM --> TO                       solid link (present / working)
FROM ..> TO                       dotted link (missing / logical / not-established)
FROM --> TO : label               with a label
FROM --> TO {options} : label     with colour and/or label position

The { … } options (after the target)

Token Meaning
a bare colour tint the line and its label — {blue}, {#ff8800}, {rgb(37,99,235)}
at=0…1 label position along the link: 0=source, 1=target — {at=0.8}

Combine them: A --> B {blue at=0.25} : N2 SCTP 38412.

Tip: labels are auto-nudged apart if they'd collide with each other or a node, so at= is a strong hint rather than an absolute pin.


4. Groups (containers)

group ID "Title" [fill=… stroke=…]
  node A [ … ]
  node B [ … ]
end

5. Diagram options

Put these on their own line, anywhere in the block.

Option Default Meaning
direction LR | TB LR Flow left→right or top→bottom.
gap N 34 Spacing between nodes within a column (px).
layergap N 104 Spacing between columns = the length of the links (moves the whole column; for one line's length use per-node push=).
edges ortho | curved | straight ortho for structure charts, else curved Connector style.
labelat 0…1 0.5 Default label position for all links (per-edge at= overrides).
shape circle | box box Default shape for every node.
size W H (auto) Force all nodes to a fixed size (per-node w/h overrides).
layerlabels A \| B \| C A shaded band + caption per column (neural-net style).
flowchart off Flowchart mode — derive sizes, lanes, routing and yes/no colours. See §6.

6. Flowchart mode

A decision chart wants different things from a neural net: every box the same size, a dead-straight main path, branches that peel off downwards, and labelled yes/no lines. Building that by hand means size W H, a level= on every node, invisible spacer nodes to stop single-node columns floating to the middle, and push= to buy room for a label. flowchart derives all of it. Write the logic; the drawing is the renderer's problem.

That is the whole source — no size, no level=, no spacers, no colours.

What it derives

Uniform sizing One size per shape class, measured from the widest/tallest member: every box matches every box, every diamond every diamond (a rhombus gets the extra room its geometry needs). Per-node w=/h= still win.
Lanes A node's first outgoing link continues its own lane — that is the spine, and it stays dead straight. Every further link peels off into the next free lane below. Lanes replace spacer nodes entirely.
Routing Same lane → a plain straight run. A branch leaves through the source's bottom face (the bottom vertex of a diamond, as drawn by hand), drops to its target's lane and turns in. If that run would cross a node already sitting in that lane, it takes the empty channel beside the lane instead and enters from the top.
Shapes A node whose label ends in ?, or that hands out a yes-and-no pair of exits, becomes a diamond. Everything else stays a box.
Colours A link labelled yes/true/ok/pass goes green, no/false/fail/reject amber; the label matches its line. Everything else stays neutral slate.
Fit If the chart is wider than the content column it is scaled down (to a readable floor of 0.55x) instead of overflowing into a horizontal scrollbar.
Spacing The column gap is sized from the widest label that has to sit on a spine segment, so no — high variance never crowds its line.

Options

flowchart takes optional key=value settings on the same line:

Option Default Meaning
fit=auto | off | <px> auto Scale to the content column, don't scale at all, or scale to a fixed width.
shapes=auto | manual auto Auto-diamond decisions, or use only explicit shape=.
colors=auto | off auto Colour yes/no links, or leave every link neutral.

Everything else still applies

direction TB, status=, fill=/stroke=, $…$ math, \n line breaks, groups, and explicit {colour} on a link all work as usual and override what the mode derived. So do gap (lane spacing), layergap (column spacing) and level= — set one and that part stops being automatic. edges curved (or straight/ortho) opts back out of the flow router entirely.

Feedback loops still don't route. The layout is layered — a node's column is its distance from a source — so a back edge (RETRAIN --> TRAIN) makes that ill-defined and tangles the chart. Put the return in the node's text (Bigger network \n → retrain) or end with a ↺ back to … node, and describe the cycle in the caption.


7. Colours

Anywhere a colour is accepted ({…} on links, fill=/stroke= on nodes and groups) you can use:

No spaces inside a fill=/stroke= value (a space ends the option): write rgb(16,185,129), not rgb(16, 185, 129). Inside a link's {…}, spaces are OK.

Status vs custom: status= is the quick semantic set (6 presets, includes the right background, border, and text colour). fill/stroke are for anything else and override status.


8. Sizing

Nodes auto-size to their content by default. Override per node:


9. How layout & routing work

Understanding this helps you get clean diagrams.

Levers when a chart is busy

  1. edges curved / edges straight — change connector style.
  2. layergap (longer links / more room) and gap (more vertical space).
  3. Colour links by plane/family with {colour}.
  4. at= on a link (or labelat) to reposition labels.
  5. level=N on a node to pin its column.
  6. w=/h= to size specific nodes.

10. Fonts & math


11. Recipes

Troubleshooting tree (diamonds)

More full recipes (site topology, healthy, interface map) live in neuralflow-showcase.md.


12. Cheat sheet

BLOCK        ```neuralflow …  ```
DIRECTION    direction LR | direction TB
FLOWCHART    flowchart [fit=auto|off|NN] [shapes=auto|manual] [colors=auto|off]
             (decision charts: uniform sizes, branch lanes, elbows, yes/no colours)
CONNECTORS   edges ortho | curved | straight        (ortho = default for structure)
SPACING      gap 20 (within a column)    layergap 150 (line length between columns)
GROUP        group ID "Title" [fill=… stroke=…]  …  end     (nestable)
NODE         node ID [Title | Detail]              (math: $ … $  → KaTeX)
  status     status=ok | warn | err | crit | off | info
  shape      shape=box | diamond | circle
  colour     fill=…  stroke=…   (name · #hex · rgb() · hsl())
  size       w=NN  h=NN          (px; auto by default)
  pin        level=N
MULTILINE    [line1 \n line2]
LINK         A --> B  (present)      A ..> B  (missing / logical)      (one per line)
LINK OPTS    A --> B {colour at=0.3} : proto port
LABEL POS    per-edge {at=0…3} ; diagram-wide `labelat 0…1`
COMMENT      # …

13. Gotchas & troubleshooting