Skip to main content

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-analyser sees 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.
  • Structureorphan_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diagram_analyser-0.3.0.tar.gz (138.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diagram_analyser-0.3.0-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file diagram_analyser-0.3.0.tar.gz.

File metadata

  • Download URL: diagram_analyser-0.3.0.tar.gz
  • Upload date:
  • Size: 138.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for diagram_analyser-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4a00164e4bd536d78a80706fd296e016c0acdd9c3030c092558a503a6ffc2e4d
MD5 320ca7d15af37a75c77cf21f4aabea8f
BLAKE2b-256 0401c6a058c30919f3fdd5b74a977de45b8951ff625496d4587ad5b5d3a43664

See more details on using hashes here.

File details

Details for the file diagram_analyser-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for diagram_analyser-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb662bb95fb129b2a2452ed56802e1c3ad0e0a9abb769f37245d6228b93fdb82
MD5 14324ed1df70939ec1eb05df6a57926e
BLAKE2b-256 27a6acf0eb7f729988ee352b5518b94c8d67b3400346b92964be0c039bd3f624

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page