# hbmartin/graphviz2drawio architecture

> Architecture diagram of the GitHub repository hbmartin/graphviz2drawio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hbmartin/graphviz2drawio
- Repository: https://github.com/hbmartin/graphviz2drawio

## Overview

##### Main Components Structure

a. Input Layer:
- DOT file input handlers (file, stdin, string, PyGraphviz.AGraph)
- Support for multiple input methods

b. Core Processing Components:
- SVG Parsing Module (models/SvgParser.py)
- Coordinate Translation System (models/CoordsTranslate.py)
- Graph Object Processing (mx/GraphObj.py)

c. MX Generation Layer:
- Node Factory (mx/NodeFactory.py)
- Edge Factory (mx/EdgeFactory.py)
- Curve Factory (mx/CurveFactory.py)
- Style Processing (mx/Styles.py)

d. Output Generation:
- XML output formatting
- File/stdout handlers

##### Specific Implementation Details
Key architectural elements:

- [Input Sources] → [Arguments Parser] → [SVG Parser]
- ↘ [Coordinate Translator]
- ↓
- [Graph Object Processor] ← [MX Factory System] → [Style Processor]
- ↓
- [XML Output Generator]

##### Important Elements to Highlight
- The factory pattern implementation in the mx/ directory
- The model-based architecture in models/
- The separation between graph processing and output generation
- The utility functions and shared resources

##### Technical Details
- Python version compatibility
- External dependencies (PyGraphviz, svg.path)
- File format specifications (DOT → XML)
- Configuration options

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        DOT[DOT File Input]
        STDIN[STDIN Input]
        STR[String Input]
        PYGV[PyGraphviz Input]
        ARGS["Arguments Handler"]:::core
    end

    subgraph Core["Core Processing"]
        SVGP["SVG Parser"]:::core
        COORD["Coordinate Translator"]:::core
        GOBJ["Graph Object Processor"]:::core
    end

    subgraph Factory["MX Factory System"]
        NF["Node Factory"]:::factory
        EF["Edge Factory"]:::factory
        CF["Curve Factory"]:::factory
        SP["Style Processor"]:::factory
    end

    subgraph Components["Graph Components"]
        NH["Node Handler"]:::component
        EH["Edge Handler"]:::component
        CH["Curve Handler"]:::component
        SH["Shape Handler"]:::component
    end

    subgraph Utils["Utility Components"]
        CONST["Constants"]:::util
        BEZ["Bezier Utilities"]:::util
        GUTIL["General Utilities"]:::util
    end

    subgraph Main["Main Processing"]
        MXG["MX Graph Handler"]:::main
        CONV["Main Converter"]:::main
    end

    subgraph Output
        XML[XML Output]
        FILE[File Output]
        STDOT[STDOUT Output]
    end

    %% Input Flow
    DOT & STDIN & STR & PYGV --> ARGS
    ARGS --> SVGP

    %% Core Processing Flow
    SVGP --> COORD
    COORD --> GOBJ
    GOBJ --> MXG

    %% Factory System
    NF & EF & CF --> MXG
    SP -.-> NF & EF & CF

    %% Component Relations
    NH -.-> NF
    EH -.-> EF
    CH -.-> CF
    SH -.-> NF

    %% Utility Usage
    CONST -.-> MXG
    BEZ -.-> CF
    GUTIL -.-> MXG

    %% Output Flow
    MXG --> CONV
    CONV --> XML
    XML --> FILE & STDOT

    %% Click Events
    click ARGS "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/models/Arguments.py"
    click SVGP "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/models/SvgParser.py"
    click COORD "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/models/CoordsTranslate.py"
    click GOBJ "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/GraphObj.py"
    click NF "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/NodeFactory.py"
    click EF "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/EdgeFactory.py"
    click CF "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/CurveFactory.py"
    click SP "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/Styles.py"
    click NH "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/Node.py"
    click EH "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/Edge.py"
    click CH "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/Curve.py"
    click SH "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/Shape.py"
    click MXG "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/MxGraph.py"
    click CONV "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/graphviz2drawio.py"
    click CONST "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/MxConst.py"
    click BEZ "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/bezier.py"
    click GUTIL "https://github.com/hbmartin/graphviz2drawio/blob/master/graphviz2drawio/mx/utils.py"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef factory fill:#e67e22,stroke:#d35400,color:white
    classDef component fill:#9b59b6,stroke:#8e44ad,color:white
    classDef util fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef main fill:#2ecc71,stroke:#27ae60,color:white
```
