# aixpert-rug/flowextract architecture

> Architecture diagram of the GitHub repository aixpert-rug/flowextract, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aixpert-rug/flowextract
- Repository: https://github.com/aixpert-rug/flowextract

## Overview

FlowExtract turns maintenance-flowchart images into directed procedural graphs: YOLO detects symbols, OCR extracts node text, and line tracing reconstructs connections and labels. The CLI orchestrates these stages and saves intermediate/final artifacts; a separate evaluation workflow compares predictions with ground truth. The README documents the pipeline and evaluation capabilities, while the sampled excerpts show orchestration and key stage behavior; some stage internals and artifact-writing calls were not fully shown.

Main entry points: [`src/main.py`](https://github.com/aixpert-rug/flowextract/blob/main/src/main.py) (Pipeline CLI), [`src/pipeline/stage1_detector.py`](https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage1_detector.py) (YOLO detection), [`src/evaluate.py`](https://github.com/aixpert-rug/flowextract/blob/main/src/evaluate.py) (Graph evaluation), [`src/pipeline/stage2_ocr.py`](https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage2_ocr.py) (Text extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Workflow orchestration"]
  node_main["Pipeline CLI<br/>[main.py]"]
  node_config["Pipeline config"]
  node_graphfiles["Graph artifacts<br/>[main.py]"]
end

subgraph group_extraction["Graph extraction"]
  node_detector["YOLO detection<br/>[stage1_detector.py]"]
  node_ocr["Text extraction<br/>[stage2_ocr.py]"]
  node_connections["Connection derivation"]
end

subgraph group_shared["Shared utilities"]
  node_io["Config and file I/O<br/>[io_utils.py]"]
  node_visuals["Detection visualization<br/>[visualization.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluator["Graph evaluation<br/>[evaluate.py]"]
  node_groundtruth["Ground-truth annotations"]
end

node_operator(("Pipeline user"))
node_flowcharts["Flowchart images"]

node_operator -->|"runs"| node_main
node_flowcharts -->|"provides images"| node_main
node_main -->|"loads settings"| node_config
node_main -->|"loads config"| node_io
node_main -->|"runs detection"| node_detector
node_main -->|"runs OCR"| node_ocr
node_main -->|"derives links"| node_connections
node_detector -->|"saves detections"| node_io
node_detector -->|"draws boxes"| node_visuals
node_main -->|"requests arrow labels"| node_ocr
node_main -->|"passes detections and labels"| node_connections
node_main -->|"writes graph results"| node_graphfiles
node_operator -->|"runs evaluation"| node_evaluator
node_graphfiles -->|"provides predictions"| node_evaluator
node_groundtruth -->|"provides reference graphs"| node_evaluator

click node_main "https://github.com/aixpert-rug/flowextract/blob/main/src/main.py"
click node_config "https://github.com/aixpert-rug/flowextract/blob/main/configs/pipeline_config.yaml"
click node_detector "https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage1_detector.py"
click node_ocr "https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage2_ocr.py"
click node_connections "https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage3_connections.py"
click node_graphfiles "https://github.com/aixpert-rug/flowextract/blob/main/src/main.py"
click node_io "https://github.com/aixpert-rug/flowextract/blob/main/src/utils/io_utils.py"
click node_visuals "https://github.com/aixpert-rug/flowextract/blob/main/src/utils/visualization.py"
click node_evaluator "https://github.com/aixpert-rug/flowextract/blob/main/src/evaluate.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_config,node_graphfiles,node_operator toneBlue
class node_detector,node_ocr,node_connections toneAmber
class node_io,node_visuals toneMint
class node_evaluator,node_groundtruth toneRose
class node_flowcharts toneIndigo
```

## Components

### Workflow orchestration

- [Pipeline CLI](https://github.com/aixpert-rug/flowextract/blob/main/src/main.py): `src/main.py`
- [Pipeline config](https://github.com/aixpert-rug/flowextract/blob/main/configs/pipeline_config.yaml): `configs/pipeline_config.yaml`
- [Graph artifacts](https://github.com/aixpert-rug/flowextract/blob/main/src/main.py): `src/main.py`

### Graph extraction

- [YOLO detection](https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage1_detector.py): `src/pipeline/stage1_detector.py`
- [Text extraction](https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage2_ocr.py): `src/pipeline/stage2_ocr.py`
- [Connection derivation](https://github.com/aixpert-rug/flowextract/blob/main/src/pipeline/stage3_connections.py): `src/pipeline/stage3_connections.py`

### Shared utilities

- [Config and file I/O](https://github.com/aixpert-rug/flowextract/blob/main/src/utils/io_utils.py): `src/utils/io_utils.py`
- [Detection visualization](https://github.com/aixpert-rug/flowextract/blob/main/src/utils/visualization.py): `src/utils/visualization.py`

### Evaluation

- [Graph evaluation](https://github.com/aixpert-rug/flowextract/blob/main/src/evaluate.py): `src/evaluate.py`
- **Ground-truth annotations**

### Other components

- **Pipeline user**
- **Flowchart images**

## Connections

- Pipeline user → Pipeline CLI: runs (evidence: `README.md`)
- Flowchart images → Pipeline CLI: provides images (evidence: `README.md`)
- Pipeline CLI → Pipeline config: loads settings (evidence: `src/main.py`)
- Pipeline CLI → Config and file I/O: loads config (evidence: `src/main.py`)
- Pipeline CLI → YOLO detection: runs detection (evidence: `src/main.py`)
- Pipeline CLI → Text extraction: runs OCR (evidence: `src/main.py`)
- Pipeline CLI → Connection derivation: derives links (evidence: `src/main.py`)
- YOLO detection → Config and file I/O: saves detections (evidence: `src/pipeline/stage1_detector.py`)
- YOLO detection → Detection visualization: draws boxes (evidence: `src/pipeline/stage1_detector.py`)
- Pipeline CLI → Text extraction: requests arrow labels (evidence: `src/main.py`)
- Pipeline CLI → Connection derivation: passes detections and labels (evidence: `src/main.py`)
- Pipeline CLI → Graph artifacts: writes graph results (evidence: `README.md`)
- Pipeline user → Graph evaluation: runs evaluation (evidence: `README.md`)
- Graph artifacts → Graph evaluation: provides predictions (evidence: `README.md`)
- Ground-truth annotations → Graph evaluation: provides reference graphs (evidence: `README.md`)
