Skip to content

feat: Export Chart Relationships to Graphviz DOT Format #579

Description

@mits87

Summary

Add support for extracting chart/diagram structures (nodes, edges, labels, and styling) into the Graphviz DOT format - graphiz_rust.

This would allow users to programmatically reconstruct diagrams, visualize relationships, and integrate with graph-based tooling.

Problem

Currently, when processing documents with diagrams (e.g. org charts, flowcharts, architecture diagrams), the extracted output lacks a structured representation of relationships between elements.

This makes it difficult to:

  • Reconstruct diagrams programmatically
  • Analyze relationships between entities
  • Visualize or export diagrams into other systems
  • Perform graph-based reasoning or transformations

Proposed Solution

Extend the extraction pipeline to detect and output diagram structures in DOT format.

The system should:

  1. Detect Nodes
  • Identify all diagram elements (boxes, shapes, entities) and node colors (if applicable).
  • Extract texts (eg. using OCR)
  1. Detect Edges (Connections)
  • Identify relationships between nodes (arrows, lines)
  • Extract:
    • Source node
    • Target node
    • Direction (if applicable)
    • Edge labels (if present)
  1. Capture Styling (Optional but valuable)
  • Node color / fill
  • Border styles
  • Edge styles (dashed, solid, etc.)
  1. Preserve Text Context
  • Text inside nodes
  • Text between nodes (e.g. relationship labels)

Expected Behavior

When a document contains a diagram:

  • The system outputs a DOT representation alongside existing extraction results

The output should be:

  • Deterministic
  • Clean (no duplicates)
  • Referencing consistent node IDs

Use Cases

  • Org chart extraction
  • System architecture diagrams
  • Process flows
  • Dependency graphs
  • Legal/entity relationship mapping

Why This Matters

This unlocks:

  • Graph-based processing (Neo4j, NetworkX, etc.)
  • Visualization pipelines (Graphviz, D3, Mermaid conversion)
  • Better explainability (traceable relationships vs flat text)
  • Stronger downstream automation (agents operating on graphs)

Example diagram output

digraph G {
  rankdir=TB;

  node1 [label="Node A" shape=box fillcolor="#a6cee3"];
  node2 [label="Node B" shape=diamond fillcolor="#b2df8a"];
  node3 [label="Node C" shape=box fillcolor="#fb9a99"];
  node4 [label="Node D" shape=ellipse fillcolor="#fdbf6f"];

  note1 [label="Some annotation" shape=note];

  node1 -> node2 [label="50%"];
  node2 -> node3 [label="relates"];
  node3 -> node4;
  node2 -> note1 [style=dashed arrowhead=none];
}

Scope / Notes

  • Should support extraction from both PDFs and images
  • The diagram output should be an additional structured extraction, included under content.diagram (without affecting existing outputs)
  • All detected nodes and edges must be traceable to source, including at minimum page reference and bounding box (for validation and debugging)

Examples

Image Image Image Image

Observation

Most of the Kreuzberg pipeline is there (rasterize pdf pages, OCR and text recognition, text coordinates etc.), the missing part is diagram / charts recognition (nodes and edges + text connection).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions