|
| 1 | +# OpenFlowKit - Diagram as Code Engine |
| 2 | + |
| 3 | +> OpenFlowKit is an open-source, local-first Diagram-as-Code engine built for modern workflows. |
| 4 | +> It allows users to write simple text (DSL) and instantly get beautiful, presentation-ready diagrams. |
| 5 | + |
| 6 | +## App Name & Branding |
| 7 | +- App Name: OpenFlowKit |
| 8 | +- Main Repository: https://github.com/Vrun-design/openflowkit |
| 9 | +- Architecture: React (Vite), ReactFlow, Zustand, TailwindCSS |
| 10 | + |
| 11 | +## OpenFlow DSL V2 Syntax Rules |
| 12 | +If a user asks you to "Generate a diagram" or "Draw a flowchart for OpenFlowKit", you MUST output the exact syntax described below. Do NOT use Mermaid syntax unless explicitly asked. |
| 13 | + |
| 14 | +Wrap your output in standard markdown code blocks, but use `openflow` as the language trigger (e.g., `\`\`\`openflow`). |
| 15 | + |
| 16 | +### 1. Metadata (Optional, must be at the top) |
| 17 | +You can define global diagram properties using `key: value`. |
| 18 | +```openflow |
| 19 | +direction: TB |
| 20 | +theme: light |
| 21 | +``` |
| 22 | +- `direction`: "TB" (Top to Bottom), "LR" (Left to Right), "RL", "BT" |
| 23 | + |
| 24 | +### 2. Nodes |
| 25 | +Format: `[type] id: Label { attributes }` |
| 26 | +- `[type]`: The visual shape/style of the node. |
| 27 | +- `id`: Unique identifier (no spaces). If omitted, the label is used as the ID. |
| 28 | +- `Label`: The text displayed inside the node. |
| 29 | +- `{ attributes }`: Optional JSON-like string of extra properties. |
| 30 | + |
| 31 | +**Supported Node Types (MUST use exactly one of these):** |
| 32 | +- `[start]` / `[end]`: Rounded pill shapes for entry/exit points. |
| 33 | +- `[process]`: Standard rectangle. |
| 34 | +- `[decision]`: Diamond shape for logic branching. |
| 35 | +- `[system]`: Hexagon shape. |
| 36 | +- `[note]`: A sticky note appearance. |
| 37 | +- `[browser]`: A window frame that looks like a web browser. |
| 38 | +- `[mobile]`: A frame that looks like an iPhone. |
| 39 | +- `[button]`: A UI wireframe button. |
| 40 | +- `[input]`: A UI wireframe text input. |
| 41 | +- `[placeholder]`: An image wireframe block. |
| 42 | + |
| 43 | +**Examples:** |
| 44 | +```openflow |
| 45 | +[start] start1: User Opens App |
| 46 | +[browser] web: E-Commerce Store |
| 47 | +[decision] checkAuth: Is Logged In? |
| 48 | +[process] db: Query Database { icon: "database" } |
| 49 | +``` |
| 50 | + |
| 51 | +### 3. Edges |
| 52 | +Format: `source -> target` or `source ->|Label| target { attributes }` |
| 53 | +- `source` / `target`: Must match the `id` of a defined node. If the node is not defined, it is created implicitly as a `[process]` node. |
| 54 | +- `->`: Standard solid arrow. |
| 55 | +- `-->`: Curved/smoothstep arrow. |
| 56 | +- `..>`: Dashed line arrow. |
| 57 | +- `==>`: Thick line arrow. |
| 58 | +- `|Label|`: Text to display on the edge. |
| 59 | + |
| 60 | +**Examples:** |
| 61 | +```openflow |
| 62 | +start1 -> checkAuth |
| 63 | +checkAuth ->|yes| web |
| 64 | +checkAuth ..>|no| loginPage { styleType: "dashed" } |
| 65 | +``` |
| 66 | + |
| 67 | +### 4. Groups |
| 68 | +Format: `group "Label" { ...nodes and edges... }` |
| 69 | +Groups create visual bounding boxes around nodes. |
| 70 | + |
| 71 | +**Example:** |
| 72 | +```openflow |
| 73 | +group "Authentication Service" { |
| 74 | + [process] auth: Auth Gateway |
| 75 | + [process] token: Token Generator |
| 76 | + auth -> token |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +## Complete Example |
| 81 | +When generating a diagram, combine the rules above: |
| 82 | + |
| 83 | +```openflow |
| 84 | +direction: LR |
| 85 | + |
| 86 | +[start] start: App Launched |
| 87 | +[browser] ui: Dashboard UI |
| 88 | + |
| 89 | +group "Backend Services" { |
| 90 | + [process] api: API Gateway |
| 91 | + [decision] cache: Check Redis |
| 92 | + [process] db: Postgres Database |
| 93 | +} |
| 94 | + |
| 95 | +start -> ui |
| 96 | +ui ->|fetch data| api |
| 97 | +api --> cache |
| 98 | +cache ->|hit| ui |
| 99 | +cache ..>|miss| db |
| 100 | +db ==>|return data| cache |
| 101 | +``` |
| 102 | + |
| 103 | +## Important Notes for LLMs |
| 104 | +- ALWAYS use the `[type]` prefix for nodes. If you aren't sure, use `[process]`. |
| 105 | +- Attributes inside `{ }` must be comma-separated like a JS object: `{ key: "value", number: 123 }`. Quotes around string values are optional but recommended. |
| 106 | +- Do NOT use hyphens `-` or spaces in Node IDs. Use camelCase or snake_case. |
0 commit comments