pma-draw
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReactFlow Diagram Creator
ReactFlow图表生成器
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.
.rfd.jsonKeep this entry file small. Load only the references needed for the current diagram.
生成以形状、位置和连接来编码语义的.rfd.json文件,供基于ReactFlow的查看器(pma-viewer)使用,该查看器拥有预定义的自定义节点类型目录。
保持入口文件精简,仅加载当前图表所需的引用资源。
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
type. Never invent new types unless the user asks and the viewer supports them.references/node-types.md - Use predefined edge types only. Pull every edge from
type. Avoid rawreferences/edges.mdunless no preset fits.default - Colors come from . Node styling is driven by the preset; override only when semantics require it.
references/colors.md - Grouping via parent-child, not by drawing a container rectangle. Use +
parentNodeon child nodes and aextent: "parent"type parent.group - 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
.rfd.json.references/validation.md - Build large diagrams section-by-section. Append nodes/edges per edit, namespace IDs by section prefix (,
ingest__,process__) to keep cross-section references readable.deliver__
- 同构优先:节点布局和边拓扑必须与概念结构一致。如果移除所有标签仍能传达核心思想,说明设计是合理的。
- 仅使用预定义节点类型:所有节点均来自
type。除非用户明确要求且查看器支持,否则不得创建新类型。references/node-types.md - 仅使用预定义边类型:所有边均来自
type。除非没有合适的预设,否则避免使用原生references/edges.md类型。default - 颜色取自:节点样式由预设驱动,仅在语义需要时才进行覆盖。
references/colors.md - 通过父子关系分组,而非绘制容器矩形。对子节点使用+
parentNode配置,并使用extent: "parent"类型的父节点。group - 每个关系都需要一条边:仅靠位置接近不代表存在连接。
- 不支持本地渲染:本工具仅输出.rfd.json文件。渲染和导出操作在pma-viewer(SPA)中完成。必须在JSON层面保证质量——详见。
references/validation.md - 分模块构建大型图表:每次编辑添加节点/边,通过为ID添加模块前缀(如、
ingest__、process__),使跨模块引用更易读。deliver__
Core Workflow
核心工作流程
Step 1: Depth Assessment
步骤1:复杂度评估
- Simple / Conceptual — abstract node types (,
process,start), generic edges. For mental models and philosophies.end - Comprehensive / Technical — semantic node types (,
backend,database,queue),ainodes with real code/JSON, typed edges (evidence,stream). For real systems, protocols, tutorials.callback
Technical diagrams require research: look up actual specs, endpoints, event names, and data formats before writing JSON.
- 简单/概念型——使用抽象节点类型(、
process、start)和通用边,适用于心智模型和理念展示。end - 全面/技术型——使用语义化节点类型(、
backend、database、queue)、包含真实代码/JSON的ai节点,以及带类型的边(evidence、stream),适用于真实系统、协议和教程。callback
技术型图表需要调研:在编写JSON前,需查阅实际规范、端点、事件名称和数据格式。
Step 2: Concept-to-Pattern Mapping
步骤2:概念到模式映射
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 .
references/design.md为每个核心概念选择与其行为匹配的视觉模式——扇出、汇聚、树形、时间线、循环、流水线、并排、间隔、云。任意两个核心概念不应使用相同模式。详情见。
references/design.mdStep 3: Layout Planning
步骤3:布局规划
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.
references/layouts.mdposition从中选择布局模板(垂直流、水平流水线、中心辐射、泳道、时间线、矩阵)。在输出节点前计算值的网格。ReactFlow使用绝对像素位置——一致性来自共享网格,而非自动布局。
references/layouts.mdpositionStep 4: Pick Node & Edge Types
步骤4:选择节点与边类型
- Each discovered component → pick a node from the catalog.
type - Each relationship → pick an edge that matches its semantics (flow, stream, callback, dependency, comparison).
type - For technical diagrams, add nodes for real code snippets or data payloads.
evidence
- 每个已识别的组件→从目录中选择对应的节点。
type - 每个关系→选择与其语义匹配的边(flow、stream、callback、dependency、comparison)。
type - 对于技术型图表,添加包含真实代码片段或数据负载的节点。
evidence
Step 5: Emit JSON
步骤5:输出JSON
Write the wrapper + + + . Use predefined templates from as starting points. Keep IDs descriptive (, ).
nodes[]edges[]viewportreferences/templates.mdapi-serveredge__api-to-db编写包装结构 + + + 。以中的预定义模板为起点。使用描述性ID(如、)。
nodes[]edges[]viewportreferences/templates.mdapi-serveredge__api-to-dbStep 6: Validate & Hand Off
步骤6:验证与交付
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.
references/validation.mdparentNodesourceHandletargetHandlereferences/render.md执行中的预检清单(ID唯一、边引用存在的节点、引用有效、/匹配节点约定、无位置冲突)。然后告知用户在pma-viewer中打开文件(详见)。本工具无法查看渲染结果,因此必须严格遵守JSON层面的规范。
references/validation.mdparentNodesourceHandletargetHandlereferences/render.mdSection-by-Section for Large Diagrams
大型图表的分模块构建
- Write the wrapper (,
schema,type,viewport) and Section 1'smetadata+nodes.edges - Append one section per edit. Prefix IDs by section (,
ingest__source) to keep later cross-section edges readable.ingest__queue - 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 (
x) per section so later edits don't collide with earlier ones.y - 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.
- 编写包装结构(、
schema、type、viewport)以及第1模块的metadata+nodes。edges - 每次编辑添加一个模块。为ID添加模块前缀(如、
ingest__source),使后续跨模块边引用更易读。ingest__queue - 当新模块的边指向早期节点时,需引用前一模块中该节点的确切ID。
- 为模块划分位置命名空间:为每个模块预留列()或行(
x),避免后续编辑与早期内容冲突。y - 所有模块完成后,重新通读整个文件,检查边引用和位置重叠,再交付给用户。
请勿一次性生成完整的全面型图表、手写生成脚本或委托编码子代理输出JSON——这些方式的输出质量均不如分模块编辑。
Output
输出
- File: by default, or a path the user specifies. Extension
docs/architecture/<name>.rfd.jsonmarks the ReactFlow Diagram schema and keeps plain JSON tooling compatibility..rfd.json - Viewing: open in pma-viewer (ReactFlow-based SPA). PNG / SVG export and editing are handled there — covers the handoff.
references/render.md - Embedding: four paths in :
references/integration.md- React / MDX sites → component
<PmaViewer src="..." /> - Plain HTML → UMD
pma-viewer+<script>PmaViewer.mount(...) - Interactive link → hosted viewer with query param
?src=<url> - Static image (GitHub README, email, PDF) → server-rendered SVG endpoint
GET /render.svg?src=<url>
- React / MDX sites →
- 文件:默认路径为,或用户指定的路径。
docs/architecture/<name>.rfd.json扩展名标记该文件遵循ReactFlow图表 Schema,同时保持与普通JSON工具的兼容性。.rfd.json - 查看:在基于ReactFlow的SPA——pma-viewer中打开。PNG/SVG导出和编辑操作在该工具中完成——涵盖交付说明。
references/render.md - 嵌入:中提供四种方式:
references/integration.md- React / MDX 站点→使用组件
<PmaViewer src="..." /> - 纯HTML→引入UMD
pma-viewer+ 调用<script>PmaViewer.mount(...) - 交互式链接→通过托管查看器的查询参数加载
?src=<url> - 静态图片(GitHub README、邮件、PDF)→使用服务端渲染SVG端点
GET /render.svg?src=<url>
- React / MDX 站点→使用
Reference Packs
参考资源包
- Visual pattern library, evidence artifacts, multi-zoom architecture, concept-to-pattern mapping.
references/design.md - File wrapper,
references/json-schema.md/nodes/edgesstructure,viewportgrouping rules, handles.parentNode - Preset custom node catalog with data-schema per type. Semantic, structural, and utility categories.
references/node-types.md - Preset edge catalog: flow, stream, callback, dependency, comparison, annotated. Handle positions, animation, labels.
references/edges.md - Semantic color palette (default / AWS / Azure / GCP / K8s) and text hierarchy. Styled presets in node-types reference this file.
references/colors.md - Layout templates (vertical flow, horizontal pipeline, hub-and-spoke, swimlanes, timeline, matrix) with grid math.
references/layouts.md - Copy-paste node / edge JSON and full starter diagrams (3-tier, microservices, event-driven, data pipeline, CI/CD).
references/templates.md - Pre-flight algorithm, checklists, common bug recipes.
references/validation.md - pma-viewer SPA contract, handoff format, in-viewer export, troubleshooting.
references/render.md - How downstream consumers embed the diagram: MDX / React component, browser
references/integration.mdSDK, URL-loaded JSON with the hosted viewer, and server-rendered SVG endpoint (for GitHub READMEs, email, PDFs).<script>
- 视觉模式库、证据工件、多缩放架构、概念到模式映射。
references/design.md - 文件包装结构、
references/json-schema.md/nodes/edges结构、viewport分组规则、句柄配置。parentNode - 预设自定义节点目录,包含每种类型的数据Schema,分为语义、结构和工具类。
references/node-types.md - 预设边目录:flow、stream、callback、dependency、comparison、annotated。包含句柄位置、动画、标签配置。
references/edges.md - 语义调色板(默认/AWS/Azure/GCP/K8s)和文本层级。节点类型引用中的样式预设均基于此文件。
references/colors.md - 布局模板(垂直流、水平流水线、中心辐射、泳道、时间线、矩阵)及网格计算方法。
references/layouts.md - 可直接复制的节点/边JSON片段和完整入门图表(三层架构、微服务、事件驱动、数据流水线、CI/CD)。
references/templates.md - 预检算法、检查清单、常见错误示例。
references/validation.md - pma-viewer SPA约定、交付格式、查看器内导出功能、故障排查。
references/render.md - 下游消费者嵌入图表的方式:MDX/React组件、浏览器
references/integration.mdSDK、通过URL加载JSON的托管查看器、服务端渲染SVG端点(适用于GitHub README、邮件、PDF)。<script>
Quick Routing
快速指引
- Designing from scratch: load , then
references/design.md.references/layouts.md - Picking node / edge types: load +
references/node-types.md.references/edges.md - Writing JSON: load +
references/json-schema.md.references/templates.md - Codebase-to-architecture extraction: load +
references/node-types.md.references/layouts.md - Validating before delivery: load .
references/validation.md - Telling the user how to open or export in pma-viewer: load .
references/render.md - 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.
/pma/pma/pma-draw- 从零开始设计:加载,再加载
references/design.md。references/layouts.md - 选择节点/边类型:加载+
references/node-types.md。references/edges.md - 编写JSON:加载+
references/json-schema.md。references/templates.md - 从代码库提取架构:加载+
references/node-types.md。references/layouts.md - 交付前验证:加载。
references/validation.md - 告知用户如何在pma-viewer中打开或导出:加载。
references/render.md - 在文档中嵌入图表(MDX/HTML/README/SVG):加载。
references/integration.md
如果项目同时使用进行工作流控制,请先加载,仅当需要图表时再加载。
/pma/pma/pma-draw