Mermaid scope
Zindex reads two kinds of Mermaid: flowchart (or graph) and erDiagram. It converts them with the official Mermaid parser, version 12.1.0, and no model, so the same text always gives the same diagram. Every other Mermaid type is refused.
Mermaid works wherever a scene does:
- Save, check or preview:
mermaidinstead ofsceneondiagram_create,diagram_validateanddiagram_render, or onPOST /v1/diagrams,/v1/diagrams/validateand/v1/diagrams/preview. Checking and previewing need no key. - Read:
view: "mermaid"ondiagram_get, or?view=mermaidonGET /v1/diagrams/{id}. - Edit:
mermaidondiagram_editorPOST /v1/diagrams/{id}/revisions(Edits).
The text can be up to 64 KB. If it holds fenced code blocks tagged mermaid, as a chat answer often does, the first one is the diagram. A title in front matter becomes the diagram’s title; other front matter is ignored.
What the conversion draws differently or leaves out comes back in warnings, each with a code and one line saying what happened, and doesn’t stop the save. A response lists at most 10 warnings, and the lines Zindex ignores (below) get none. Validation rules: Mermaid notes lists every code. The converted diagram is then checked like any scene: if it breaks a rule, such as more than 1,000 elements (edges included), nothing is saved and the answer is VALIDATION_FAILED. A flowchart with more than 1,000 edges gets the same answer as soon as the parser reaches the 1,001st, and its error says the scene has more than 1,000 elements without counting them.
IDs
A node’s ID is its Mermaid ID. An edge written with an ID, such as a e1@--> b, keeps it; any other edge gets an ID made from its ends, such as a--b. An ID Zindex can’t use as written (anything but letters, digits, ., _, : and -, or longer than 200 characters) becomes a readable slug with a short hash.
Flowcharts
A flowchart becomes an architecture diagram in the direction its text gives (TB, TD, BT, LR or RL; top to bottom when it gives none).
- Nodes keep their label. HTML or Markdown in a label is removed (
LABEL_MARKUP_REMOVED). Rectangles, rounded rectangles, stadiums (pill), circles (ellipse), hexagons, right-leaning parallelograms and clouds draw as written; a cylinder becomes adatabasenode, a diamond adecisionnode and a document shape adocumentnode. Every other shape, such assubroutine,trapezoid, a double circle or the asymmetric>], is drawn as the nearest shape and reported (SHAPE_APPROXIMATED). - Edges keep their label. Arrowheads, open links (
---), circle ends (--o), two-way arrows (<-->), dotted links (-.->, drawn dashed) and thick links (==>) carry over. A cross end (--x) is drawn as a bar (ARROW_APPROXIMATED). Invisible links (~~~) only steer Mermaid’s own layout, so they are left out with a note. linkStyleand accessibility lines are ignored. Aclickline counts as a style (STYLE_DROPPED).
Entity-relationship diagrams
An erDiagram becomes an entityRelationship diagram, laid out left to right whatever direction the text gives.
- Entities become tables with their columns: each column’s type and name,
PK,FKandUK(unique). An entity’s alias becomes its label. Column comments are kept but not drawn (COMMENT_NOT_SHOWN). - Relationships keep their label and the cardinality of each end. An identifying relationship (
--) draws solid and a non-identifying one (..) dashed, as in Mermaid. A cardinality Zindex can’t draw exactly is left for the engine to infer from the columns (CARDINALITY_APPROXIMATED).
Left out, with a warning
The diagram is saved without these, and each comes back in warnings:
| Mermaid | What happens | Code |
|---|---|---|
A flowchart subgraph | Left out; its nodes are kept | SUBGRAPH_DROPPED |
| An edge to or from a subgraph | Left out; connect it to a node in the subgraph to keep it | CONSTRUCT_DROPPED |
style, classDef, class and click | Left out; set styles on the elements instead | STYLE_DROPPED |
Zindex doesn’t draw Mermaid subgraphs, so a flowchart that relies on them for grouping loses that grouping. To group nodes, add frames with operations after saving (Operations: createFrame).
Refused
Nothing is saved, and the answer names the problem:
| Sent | Answer |
|---|---|
Any other Mermaid type, such as sequenceDiagram, classDiagram, stateDiagram or gantt | 422 UNSUPPORTED_DIAGRAM_TYPE |
| Text with a syntax error | 422 PARSE_ERROR, with line, and column counted from 0. Zindex never repairs the text |
| Text over 64 KB | 413 INPUT_TOO_LARGE. Over MCP, the tool’s input schema refuses it first |
| Text the parser takes more than 15 seconds on, or stops on | 422 IMPORT_TIMEOUT or IMPORT_FAILED; send shorter text, or a scene |
Empty text; both scene and mermaid, or neither; mermaid with ops or restoreRevision | 400 INVALID_REQUEST |
Reading as Mermaid
A read with view=mermaid writes the diagram as Mermaid you can edit and send back, with its title in front matter. Entity-relationship diagrams come back as an erDiagram, every other family as a flowchart. Sequence diagrams have no Mermaid view: the read answers VIEW_UNAVAILABLE. The read lists what the text leaves out or writes approximately: in notes over REST, on a note: line over MCP (Notes on a Mermaid view).
In a flowchart:
- The direction is the one the engine draws: left to right by default, top to bottom for org charts.
- Frames and groups are written as subgraphs, so the text reads like the diagram (
FRAMES_READ_ONLY). Text, image and guide elements have no Mermaid form and are left out, with a note. - Shapes Mermaid has no syntax for, such as
cloud,bucket,box3dandiconBox, are written as rectangles (SHAPE_APPROXIMATED). Edge IDs aren’t written. - An ID Mermaid can’t hold, such as
endor one with--in it, is written as an alias likezid1, with a%% zindex-idcomment that maps it back when the text returns. Keep those comments when you edit. - Positions, icons, constraints, edge ends other than arrows and circles, and line styles other than dotted and thick aren’t part of the text.
In an erDiagram:
- Each entity is named by its ID; a label that differs isn’t written (
LABEL_NOT_EXPORTED). Frames, groups, text, images and guides are left out. - Each relationship’s cardinality is written as drawn, inferred from the columns where none was set, and as one to zero-or-many where none can be inferred (
CARDINALITY_ASSUMED). Mermaid has no plainmany, somanyis written as zero or many (}ooro{).
Edits
Send the whole diagram as mermaid with baseRevision, usually text you read with view=mermaid and changed. Zindex compares it with the baseRevision version and applies only the differences, as operations, making the next version:
- Nodes are matched by ID, and edges by ID or by their ends, so everything you didn’t change keeps its ID and history. An edge whose ends change becomes a new edge, unless the text gives its ID (
a e1@--> b). A node keeps its type, such asservice, unless you change its Mermaid shape. - Nodes and edges missing from the text are deleted.
- A changed title in the front matter, and a changed flowchart direction, are applied. Text without a title leaves the diagram’s title as it is; to remove a title, send
{ "op": "updateScene", "title": "" }inops. - Frames, groups, text, images and guides never change through Mermaid. A changed subgraph comes back as a
FRAMES_NOT_CHANGEDwarning; change frames with operations. An edge to a subgraph that stands for a frame or group is an edge to that frame or group, changed like any other edge; an edge to any other subgraph is left out, with aCONSTRUCT_DROPPEDnote. In anerDiagram, a changed alias isn’t applied. - In an
erDiagram, a cardinality left as read keeps following the columns; one you change is saved as you wrote it. - Text sent back as read returns
noop: truewhen everything in the diagram has a Mermaid form. What the read wrote approximately comes back as written: a shape written as a rectangle becomes a plain rectangle, a bar end becomes an arrow, a dash pattern becomes Mermaid’s dotted line, and a line width becomes normal or thick. The edit’schangedlists those elements. Change such diagrams with operations. - Mermaid edits work on architecture and entity-relationship diagrams, the two families an import makes. An
erDiagramsent for an architecture diagram, a flowchart sent for an entity-relationship one, or a Mermaid edit of any other family is a 422,MERMAID_FAMILY_MISMATCH: change those diagrams with operations. - Retries with
requestIdand conflicts work as for any edit (Concepts: Edits).