# imge graph files: instructions for AI tools imge (https://kutaycoskuner.github.io/imge/) is a graph editor in the browser. A graph is one JSON file in the format below. The editor checks only the format name and version on load and then trusts the file: a missing field breaks it. Follow these rules exactly and answer with the JSON. ## 1. Output rules 1. One JSON object only: no comments, no trailing commas, no text inside it. Suggest a file name ending in `.json`. 2. Format version 7, and only the fields shown here; every field is required unless marked optional. 3. Ids: nodes `n1`, `n2` ...; links `l1`, `l2` ...; each unique in the file. 4. A link goes from a port of kind `out` (id `o1`) to a port of kind `in` (id `i1`) of nodes that exist. 5. Coordinates: `position` is the node's top-left corner; x grows to the right, **y grows UP** (further down the screen = more negative y). ## 2. Structure ```json { "metadata": { "format": "imge-graph", "version": 7, "direction": "left-to-right" }, "data": { "nodes": [], "links": [] } } ``` - `direction`: `left-to-right` (links leave a node on its right, enter on its left) or `top-to-bottom` (leave at the bottom, enter at the top). - A node: `{ "id": "n1", "type": "basic", "typeVersion": 2, "position": { "x": 0, "y": 0 }, "ports": [...], "content": {...} }`. `type` decides `typeVersion`, `ports` and the keys of `content` (table below). - A link: section 4. ## 3. Node types and versions Graph format: version **7**. Each node type has its own `typeVersion`: use exactly the one in the table (never invent versions). Older files are upgraded when they are opened; always write the current ones. Ports for every type that has them (basic, uml-class, image, table, graph): `"ports": [{ "id": "i1", "kind": "in", "type": "basic", "label": "Input" }, { "id": "o1", "kind": "out", "type": "basic", "label": "Output" }]` | type | typeVersion | ports | content | |---|---|---|---| | basic | 2 | i1, o1 | `{ "name": "Text", "color": null, "shape": "square" }` | | group | 3 | `[]` | `{ "name": "Area", "color": null, "children": ["n1", "n2"], "shape": "square", "width": 500, "height": 200 }` | | text | 1 | `[]` | `{ "text": "Title\nsecond line", "color": null, "scale": 1, "bold": false, "align": "left" }` | | table | 1 | i1, o1 | `{ "name": "Table", "showName": true, "color": null, "scale": 1, "cells": [["A", "B"], ["1", "2"]], "rowStyles": [{ "bold": true }, null], "colStyles": [null, null] }` | | uml-class | 2 | i1, o1 | `{ "name": "Shape", "color": null, "abstract": false, "attributes": ["- id: int"], "methods": ["+ area(): double"] }` | | image | 2 | i1, o1 | `{ "name": "R1", "src": "images/parts/resistor.svg", "width": 96, "height": 32, "scale": 1, "caption": "", "showCaption": true }` | | graph | 1 | i1, o1 | `{ "name": "Detail", "color": null, "scale": 1, "mode": "internal", "graph": null, "ref": null }` | - basic: a box with a name; `shape` `square` or `circle` (circle for a central idea). - group: a frame drawn behind the nodes listed in `children` (each node in at most one group); `width` / `height` optional (its start size); no ports, not linkable. - text: only text (titles, headings, notes); no ports. `align`: `left`, `center`, `right`. - table: `cells` are rows of text; `rowStyles` one entry per row, `colStyles` one per column, each `null` or a style `{ "size": 1, "opacity": 1, "bold": false, "italic": false, "underline": false, "align": "left", "color": null }` (only the keys you need). - uml-class: one member per line in UML notation (`- name: type`, `+ op(arg: type): type`, `{static} + count: int`, `+ {abstract} area(): double`). - image: `src` one of the library parts `images/parts/.svg`: and-gate, or-gate, not-gate, battery, capacitor, diode, ground, lamp, led, resistor, switch (sizes at scale 1: gates 96 × 64, others about 96 × 32 … 48). - graph: another graph shown small inside this one; `graph` is an embedded graph object in this same format (or `null`, empty); `ref` stays `null` (`mode` `internal`). ## 4. Links ```json { "id": "l1", "type": "basic", "name": "calls", "shape": "spline", "arrow": "forward", "line": "solid", "mark": "arrow", "route": "above", "source": { "node": "n1", "port": "o1" }, "target": { "node": "n2", "port": "i1" } } ``` | field | values | |---|---| | `name` (optional) | a label in the middle of the link | | `shape` | `spline` (curved), `line` (straight), `manhattan` (right angles; optional `"bend": 0.5`, 0 .. 1) | | `arrow` | `forward`, `backward`, `both`, `none` (where the mark is drawn) | | `line` | `solid`, `dashed`, `dotted` | | `mark` | `arrow`, `open-arrow`, `triangle` (hollow), `diamond` (hollow), `filled-diamond` | | `route` | `above` or `below`: the side a link takes when it must go around its nodes (cycles, self-loops) | ## 5. Customization (what the file can set) - Colour of basic, group, text, table, uml-class and graph nodes: `null` (the theme's default) or `"#rrggbb"`. A palette that reads well: `#0090ff` blue, `#30a46c` green, `#6e56cf` violet, `#f76b15` orange, `#e5484d` red, `#f5d90a` yellow, `#12a594` teal, `#8b8d98` grey. - Shape: basic and group `square` / `circle`. Size: text, table, image and graph nodes `scale` (0.25 .. 8); groups `width` / `height`. - Text: `bold`, `align`, several lines with `\n`; table rows and columns their own style; images a `caption`. - Links: every field of section 4. The whole graph: `direction`. - Not in the file (each viewer chooses in the editor): theme, dot grid, port look, link shape override, zoom. ## 6. Sizes: never overlap A node takes the box from (x, y) to (x + w, y − h). Sizes at scale 1, in world units: | node | w × h | |---|---| | basic | 194 × 60 (194 × 85 when the name wraps: more than about 20 characters) | | basic circle | about 117 × 117 | | text | about 8 per character × 21 per line; times `scale` | | table | about 65 per column × (30 per row + 40 for its name); times `scale` | | uml-class | 140 .. 270 (the longest member line) × (55 + 14 per member line) | | image | its `width` × `height` times `scale` (+ about 18 under it for a caption) | | graph node | about 240 × 210 times `scale` | - Leave at least 40 between any two node boxes, and 60 where a link runs between them (more for a link label). - left-to-right: columns about 260 apart (x), rows about 90 apart (y); top-to-bottom: rows about 150 apart (y), columns about 230 apart (x). - A group's frame grows to hold its children with 64 around them: put children at least 64 inside its top-left corner and size `width` / `height` to fit; groups never overlap each other. - Titles and notes: `text` nodes above or beside the diagram (title `scale` 1.8, `bold` true), clear of every box. - Lay out in reading order (start left or at the top, follow the links); avoid links that cross back. ## 7. Kinds of graphs (with the editor's example of each) | kind | how | example (Esc menu → Examples) | |---|---|---| | mind map / relation map | a circle in the middle, ideas around, spline links, `arrow` none | Trip planning, Feature map | | notes | coloured text and basic nodes, a group for definitions, dotted links to examples | Lecture notes | | flowchart / algorithm | top-to-bottom, manhattan links, `forward`; branches named `yes` / `no`; loops `route` around | Find the largest number | | process | steps left to right; rework dashed, drawn `above` / `below` | Release process | | tree / lattice | levels as rows, straight lines, no arrows | Binary search tree, Subsets of {a, b, c} | | architecture | services as coloured basic nodes in a group per tier, links named by protocol, async dashed with `open-arrow` | Web app architecture, Weather station | | UML class diagram | `uml-class` nodes; inheritance `triangle` forward from child to parent; realization the same `dashed`; aggregation `diamond`; composition `filled-diamond`; dependency `dashed` + `open-arrow` | Shapes (UML classes) | | sequence (sketch) | participants as coloured columns, messages numbered, replies dashed with `open-arrow` | Login sequence | | circuit | `image` nodes (library parts) linked, named by captions | LED circuit (symbols), Half adder | | math / calculation | numbers and operators as basic nodes, inputs left to right | Quadratic, Arithmetic test | | sets / functions | two groups as the sets, links as the mapping | Function f: A → B | | UI wireframe / screen flow | a screen is a group (e.g. 320 × 520); fields and buttons basic nodes inside, headings text nodes; links name the action ("tap") | Login screen, Dashboard layout, Ankara guide | | big relation graph | many basic nodes in layers | Package dependencies | ## 8. Using the result - **Open it**: save the JSON as `name.json` and drop it anywhere on the graph editor page (every browser); or put it in a folder and choose that folder in Esc menu → Config (its graphs are listed, a click opens one); Firefox / Safari also have Config → Open a single file…. - **Save in the browser**: Esc menu → Saved → Save in browser (under a name; open, rename, download or delete them there). - **Save on disk**: Chrome / Edge: choose a folder in Esc menu → Config, then Save (Ctrl+S) / Save as write into it; every browser: Download (Ctrl+Shift+S, or the toolbar's down arrow) saves a `.json`; the picture button exports PNG, JPG or SVG. - **Make it move**: Augment (top right) → Gravity lays the nodes out by their links (no groups); Arithmetic computes basic nodes named as numbers and operators. ## 9. Before answering, check - version 7; every node has id, type, the table's typeVersion, position, ports, content with all its keys; every link has all fields of section 4 - ids unique; each link's source is an existing node's `o1`, its target an existing node's `i1` (groups and text nodes have no ports) - group `children` are existing node ids, each node in at most one group - no two node boxes overlap (section 6), titles clear of the diagram - the JSON parses (no comments, no trailing commas) ## 10. Example ```json { "metadata": { "format": "imge-graph", "version": 7, "direction": "left-to-right" }, "data": { "nodes": [ { "id": "n1", "type": "text", "typeVersion": 1, "position": { "x": 0, "y": 100 }, "ports": [], "content": { "text": "Order flow", "color": null, "scale": 1.8, "bold": true, "align": "left" } }, { "id": "n2", "type": "basic", "typeVersion": 2, "position": { "x": 64, "y": -64 }, "ports": [{ "id": "i1", "kind": "in", "type": "basic", "label": "Input" }, { "id": "o1", "kind": "out", "type": "basic", "label": "Output" }], "content": { "name": "Web shop", "color": "#0090ff", "shape": "square" } }, { "id": "n3", "type": "basic", "typeVersion": 2, "position": { "x": 324, "y": -64 }, "ports": [{ "id": "i1", "kind": "in", "type": "basic", "label": "Input" }, { "id": "o1", "kind": "out", "type": "basic", "label": "Output" }], "content": { "name": "Orders API", "color": "#0090ff", "shape": "square" } }, { "id": "n4", "type": "group", "typeVersion": 3, "position": { "x": 0, "y": 0 }, "ports": [], "content": { "name": "Frontend and API", "color": "#0090ff", "children": ["n2", "n3"], "shape": "square", "width": 580, "height": 190 } }, { "id": "n5", "type": "basic", "typeVersion": 2, "position": { "x": 660, "y": -64 }, "ports": [{ "id": "i1", "kind": "in", "type": "basic", "label": "Input" }, { "id": "o1", "kind": "out", "type": "basic", "label": "Output" }], "content": { "name": "Database", "color": "#30a46c", "shape": "square" } } ], "links": [ { "id": "l1", "type": "basic", "name": "HTTPS", "shape": "spline", "arrow": "forward", "line": "solid", "mark": "arrow", "route": "above", "source": { "node": "n2", "port": "o1" }, "target": { "node": "n3", "port": "i1" } }, { "id": "l2", "type": "basic", "name": "SQL", "shape": "spline", "arrow": "forward", "line": "dashed", "mark": "arrow", "route": "above", "source": { "node": "n3", "port": "o1" }, "target": { "node": "n5", "port": "i1" } } ] } } ``` More: every example's file is in https://github.com/kutaycoskuner/imge/tree/main/static/data/examples; the format in detail: docs/graph-format.md in the same repository.