Structural analysis of mermaid / PlantUML / Graphviz / drawio diagrams (plus image diagrams via optional vision)
Project description
diagram-analyser
Structural analysis of diagrams — the lens-family member that reads diagrams as graphs (nodes + edges) rather than as raster images.
Supports four text formats out of the box:
| Format | Extensions |
|---|---|
| Mermaid | .mmd, .mermaid |
| PlantUML | .puml, .plantuml |
| Graphviz / DOT | .dot, .gv |
| drawio (XML) | .drawio |
Plus an optional [vision] path for image diagrams (.png/.jpg) via Anthropic Claude Vision —
explicit-only, since those extensions auto-route to image-analyser.
image-analysersees raster pixels; this one parses the diagram's structure — nodes, edges, orphans, cycles, depth, naming. Built for design-unit assessment (CS/IS architecture, ER, UML, flowcharts).
Install
pip install diagram-analyser # text formats — pure Python
pip install 'diagram-analyser[vision]' # adds image-diagram support
For the vision path, set one of:
export ANTHROPIC_API_KEY=sk-ant-...
Use
Python:
from diagram_analyser import DiagramAnalyser
result = DiagramAnalyser().analyse("architecture.mmd")
print(result.diagram_type) # "flowchart"
print(result.graph.node_count) # 7
print(result.structure.orphan_nodes) # []
print(result.structure.cycle_count) # 1
print(result.structure.is_dag) # False
# Image diagram (needs [vision] extra + ANTHROPIC_API_KEY):
result = DiagramAnalyser().analyse("diagram.png")
print(result.vision.raw_description)
CLI:
diagram-analyser flow.mmd # human summary
diagram-analyser model.puml --json # raw JSON
diagram-analyser arch.png # vision path (needs API key)
diagram-analyser serve # HTTP API on port 8013
diagram-analyser manifest # capability manifest
HTTP (diagram-analyser serve on port 8013):
curl -F file=@flow.mmd http://localhost:8013/analyse
curl http://localhost:8013/health
Signals
For every diagram (text or vision-extracted):
- Graph — nodes (id, label, kind), edges (source, target, kind, label), counts.
- Structure —
orphan_nodes(disconnected),cycle_count+ sample cycles,max_depth,is_dag,connected_components. - Naming quality — label coverage, average label length, suspiciously short labels.
- Diagram type — for mermaid:
flowchart/classDiagram/erDiagram/sequenceDiagram/stateDiagram; for PlantUML:uml/mindmap/wbs; for graphviz:digraph/graph; for drawio: best-effort from cell hints.
The family
Part of the lens analyser family.
| What you want | Use |
|---|---|
| Raster image (any kind) | image-analyser |
| Structured diagram (mermaid/UML/drawio/dot) | diagram-analyser (this) |
| Image of a diagram | image-analyser detects + auto-analyser cascades to here, or diagram-analyser file.png directly |
| Any file → right engine | auto-analyser |
Limits
- v1 text parsers are pragmatic — not full grammars. They get nodes, edges, and the diagram type for ~all realistic student diagrams; corner cases (subgraphs, deeply nested mermaid classes) may parse approximately.
- Vision path produces structure only as well as the LLM extracts it. We surface the raw description so you can verify.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file diagram_analyser-0.2.0.tar.gz.
File metadata
- Download URL: diagram_analyser-0.2.0.tar.gz
- Upload date:
- Size: 137.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e315f060f05516da22839d442c952f5e7e26b63fca7d0aff42aba77ffb2d535d
|
|
| MD5 |
4bec7241f9ff9093ba6b96d9c46ab52d
|
|
| BLAKE2b-256 |
0f0669d56c8911bffaddc6613ceb546da4c0a2580e8bfe270176da4b74e95f65
|
File details
Details for the file diagram_analyser-0.2.0-py3-none-any.whl.
File metadata
- Download URL: diagram_analyser-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
659a7f424ff4c0351ec7108a00fb06b8998c681a0c865e33ad01467550e1207a
|
|
| MD5 |
340804046adb236c27f4ef63314a6be8
|
|
| BLAKE2b-256 |
d76deee83df7ae57da9c63662dc46c218ca2c56aba91e017518725e9a7806f40
|