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.1.0.tar.gz (18.4 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.1.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: diagram_analyser-0.1.0.tar.gz
  • Upload date:
  • Size: 18.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 02511585682bae97f09af009b5fe8466382d25d39bb7a8397dcd0c72ce4e4a44
MD5 2491802cd984074efa395aa4bb7e7b19
BLAKE2b-256 4883f79fb0e474e3f90a61f6f8166468228b207e004a9494ff73a7873ce40019

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diagram_analyser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ae4f04419ed97081c475b7e6a5273fcc4da129b615449f0ea479fcb8b9fcda0
MD5 e539def3c26091d6619f42581eca04eb
BLAKE2b-256 3a6e0b2aa1db6806ca5a583701ca371bfd175e35ac82d7474f2fe0447d5e5be6

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