What is Mermaid and “Graph as Code”?
Mermaid is a JavaScript-based diagramming and charting tool that lets you define flowcharts and diagrams using plain text syntax. It supports a wide array of diagram types—from flowcharts to Gantt charts—and integrates seamlessly with Markdown, static site generators, and developer tooling.
This idea of “Graph as Code” is part of a growing movement to bring diagrams into version-controlled environments. Instead of dragging shapes in GUI tools, you define nodes, edges, and relationships in declarative syntax. That means diffs, pull requests, CI validation, and automated documentation pipelines all become possible.
In the context of CLI reverse engineering and static code review, this is especially powerful: you can audit execution paths, track how user input flows through logic, and share insights visually—all without needing to boot the code.
Why This Exists
There’s no shortage of tools for static analysis, but I couldn’t find anything that:
- Parsed modern JavaScript and .mjs files reliably
- Detected CLI entry points declared with Commander.js
- Emitted Mermaid syntax, suitable for integration with markdown, docs-as-code pipelines, and in-browser previews
- Was happy to run entirely from the CLI in a pipenv
So I built one.
- It was designed to help during a project where deep static analysis was needed but runtime behaviour wasn’t accessible. Once the project wrapped, the tool was still useful enough to publish rather than let it rot on a private repo.