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
Metadata
Release files for diagram-analyser 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diagram_analyser-0.3.0.tar.gz | 138.0 kB | Without provenance | Details for diagram_analyser-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diagram_analyser-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for diagram_analyser-0.3.0-py3-none-any.whl |
Total release size: 160.2 kB
Release files / diagram_analyser-0.3.0.tar.gz
| Download URL | diagram_analyser-0.3.0.tar.gz |
|---|---|
| Size | 138.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a00164e4bd536d78a80706fd296e016c0acdd9c3030c092558a503a6ffc2e4d
|
|
BLAKE2b-256 checksum How to use checksums |
0401c6a058c30919f3fdd5b74a977de45b8951ff625496d4587ad5b5d3a43664
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / diagram_analyser-0.3.0-py3-none-any.whl
| Download URL | diagram_analyser-0.3.0-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb662bb95fb129b2a2452ed56802e1c3ad0e0a9abb769f37245d6228b93fdb82
|
|
BLAKE2b-256 checksum How to use checksums |
27a6acf0eb7f729988ee352b5518b94c8d67b3400346b92964be0c039bd3f624
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Security for diagram-analyser 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.