ReactFlow Diagram Creator
Generate
files that encode meaning in shape, position, and connection — consumed by a ReactFlow-based viewer (pma-viewer) with a predefined catalog of custom node types.
Keep this entry file small. Load only the references needed for the current diagram.
Always-On Rules
- Isomorphism first: node layout and edge topology must mirror the concept's structure. If removing all labels still communicates the idea, the design is right.
- Use predefined node types only. Pull every node from . Never invent new types unless the user asks and the viewer supports them.
- Use predefined edge types only. Pull every edge from . Avoid raw unless no preset fits.
- Colors come from . Node styling is driven by the preset; override only when semantics require it.
- Grouping via parent-child, not by drawing a container rectangle. Use + on child nodes and a type parent.
- Every relationship needs an edge. Proximity alone is not a connection.
- No local render: the skill emits only. Rendering and export happen in pma-viewer (SPA). Quality must be enforced at JSON level — see .
- Build large diagrams section-by-section. Append nodes/edges per edit, namespace IDs by section prefix (, , ) to keep cross-section references readable.
Core Workflow
Step 1: Depth Assessment
- Simple / Conceptual — abstract node types (, , ), generic edges. For mental models and philosophies.
- Comprehensive / Technical — semantic node types (, , , ), nodes with real code/JSON, typed edges (, ). For real systems, protocols, tutorials.
Technical diagrams require research: look up actual specs, endpoints, event names, and data formats before writing JSON.
Step 2: Concept-to-Pattern Mapping
For each major concept pick the visual pattern that mirrors its behavior — fan-out, convergence, tree, timeline, cycle, assembly line, side-by-side, gap, cloud. No two major concepts should share the same pattern. Details in
.
Step 3: Layout Planning
Pick a layout template from
(vertical-flow, horizontal-pipeline, hub-and-spoke, swimlanes, timeline, matrix). Compute a grid of
values before emitting nodes. ReactFlow uses absolute pixel positions — consistency comes from a shared grid, not from an auto-layout pass.
Step 4: Pick Node & Edge Types
- Each discovered component → pick a node from the catalog.
- Each relationship → pick an edge that matches its semantics (flow, stream, callback, dependency, comparison).
- For technical diagrams, add nodes for real code snippets or data payloads.
Step 5: Emit JSON
Write the wrapper +
+
+
. Use predefined templates from
as starting points. Keep IDs descriptive (
,
).
Step 6: Validate & Hand Off
Run the pre-flight checklist in
(IDs unique, edges reference existing nodes,
refs valid,
/
match node contracts, no position collisions). Then tell the user to open the file in pma-viewer (see
). The agent cannot see the rendered result, so JSON-level discipline is mandatory.
Section-by-Section for Large Diagrams
- Write the wrapper (, , , ) and Section 1's + .
- Append one section per edit. Prefix IDs by section (, ) to keep later cross-section edges readable.
- When a new section's edge targets an earlier node, cite the exact existing node ID from the previous section.
- Namespace positions by section: reserve columns () or rows () per section so later edits don't collide with earlier ones.
- After all sections exist, re-read the full file once to check edge references and position overlaps before handing off.
Do not generate an entire comprehensive diagram in one response, hand-write a generator script, or delegate JSON emission to a coding sub-agent — each path produces worse output than section-by-section edits.
Output
- File:
docs/architecture/<name>.rfd.json
by default, or a path the user specifies. Extension marks the ReactFlow Diagram schema and keeps plain JSON tooling compatibility.
- Viewing: open in pma-viewer (ReactFlow-based SPA). PNG / SVG export and editing are handled there — covers the handoff.
- Embedding: four paths in
references/integration.md
:
- React / MDX sites → component
- Plain HTML → UMD +
- Interactive link → hosted viewer with query param
- Static image (GitHub README, email, PDF) →
GET /render.svg?src=<url>
server-rendered SVG endpoint
Reference Packs
-
Visual pattern library, evidence artifacts, multi-zoom architecture, concept-to-pattern mapping.
references/json-schema.md
File wrapper, / / structure, grouping rules, handles.
-
Preset custom node catalog with data-schema per type. Semantic, structural, and utility categories.
-
Preset edge catalog: flow, stream, callback, dependency, comparison, annotated. Handle positions, animation, labels.
-
Semantic color palette (default / AWS / Azure / GCP / K8s) and text hierarchy. Styled presets in node-types reference this file.
-
Layout templates (vertical flow, horizontal pipeline, hub-and-spoke, swimlanes, timeline, matrix) with grid math.
-
Copy-paste node / edge JSON and full starter diagrams (3-tier, microservices, event-driven, data pipeline, CI/CD).
-
Pre-flight algorithm, checklists, common bug recipes.
-
pma-viewer SPA contract, handoff format, in-viewer export, troubleshooting.
references/integration.md
How downstream consumers embed the diagram: MDX / React component, browser SDK, URL-loaded JSON with the hosted viewer, and server-rendered SVG endpoint (for GitHub READMEs, email, PDFs).
Quick Routing
- Designing from scratch: load , then .
- Picking node / edge types: load + .
- Writing JSON: load
references/json-schema.md
+ .
- Codebase-to-architecture extraction: load + .
- Validating before delivery: load .
- Telling the user how to open or export in pma-viewer: load .
- Embedding the diagram in docs (MDX / HTML / README / SVG): load
references/integration.md
.
If the project also uses
for workflow control, load
first, then
only when a diagram is required.