A developer has released Glyphic, a new open-source diagram engine that separates AI's descriptive strengths from the spatial layout problem. The system accepts typed JSON from an AI model and hands the geometric computation to ELK, a proven layout engine, avoiding the tangled edges and non-deterministic output that plague AI-generated SVG diagrams.
The project's creator, MS-Teja, tested the same 44-node architecture twice with the same frontier model. The first time, the model emitted raw SVG coordinates; the second time, it output plain JSON for a layout engine. While boxes rendered cleanly in both cases, the SVG version produced long diagonal edges that cut through unrelated nodes wherever the graph became dense. Worse, changing a single node forced a full regeneration of the coordinate layout, returning a different result each time.
The structural problem with AI-drawn diagrams
The author argues this is not a problem that better models will solve. Routing connectors around obstacles in a nested graph is global constraint optimization — exactly what layout engines like ELK are built for. A language model emitting SVG must commit to x/y coordinates token by token, with no ability to backtrack once the full picture emerges. "The failure is structural," the developer wrote, predicting that even future models will struggle with edge routing past a couple dozen nodes.
Glyphic's approach moves the boundary. The model describes the diagram's meaning in compact JSON, which is validated against a strict Zod schema before rendering. Errors return precise messages like "edges[2].target references unknown node 'paymentss'" — fixable on the next turn, unlike a DSL that crashes on a typo. The engine then uses ELK for layout and d3 for data types, with SVG rasterized to PNG natively in Rust via resvg.
No browser, cheap at scale
Glyphic's stack avoids the overhead of headless Chromium, which the developer says adds ~300MB and a cold-start tax to every invocation. Layout and rasterization are both native, allowing deployment to a Lambda, CI job, or agent loop as an ordinary Node dependency. Because the JSON is the source of truth, diagrams remain editable data — diffable, changeable, re-themable — rather than pictures that must be regenerated from scratch.
The system supports 18 diagram types, including architecture with nested VPCs, sequence diagrams, ERDs with crow's-foot notation, UML class, state machines, flowcharts, Gantt, timelines, Sankey, Git trees, mindmaps, C4, pie, quadrant, kanban, user journeys, treemaps, and a freeform canvas. Theming, Google Fonts, FontAwesome icons, and a hand-drawn sketch style are included.
Three ways to run it
Glyphic can be used as an MCP server — a 30-second setup via `claude mcp add glyphic -- npx -y @glyphicjs/mcp-server` — working in Cursor, Claude Desktop, VS Code, and Windsurf. It can also be installed as a library (`npm install @glyphicjs/core @glyphicjs/schema`) or self-hosted behind an HTTP endpoint. The schema and MCP server are MIT licensed; the core engine is FSL-1.1, which restricts resale as a competing hosted service and converts to Apache-2.0 after two years.
The developer invites testing of the method and feedback on the project, which is available at https://github.com/MS-Teja/Glyphic with a live playground at https://glyphic.web.app/generate.