# mozman/ezdxf architecture

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

- Interactive diagram: https://gitdiagram.com/mozman/ezdxf
- Repository: https://github.com/mozman/ezdxf

## Overview

ezdxf is a Python library for creating, reading, editing, validating, and writing DXF drawings while preserving unfamiliar third-party data. The principal workflow runs from a programmer’s API call through file loading and tag handling into a document of entities and layouts, then back to serialized DXF output. Separate branches provide querying, recovery, rendering, and documented extensions. Source excerpts are limited, so some subsystem links are documented by the README rather than verified in implementation; unsampled add-on internals are represented at their exact directories.

Main entry points: [`src/ezdxf/filemanagement.py`](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/filemanagement.py) (File management), [`src/ezdxf/__init__.py`](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/__init__.py) (Public API), [`src/ezdxf/document.py`](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/document.py) (Drawing document), [`src/ezdxf/addons/drawing/pipeline.py`](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/drawing/pipeline.py) (Render pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Document model"]
  node_api["Public API<br/>[__init__.py]"]
  node_document["Drawing document<br/>[document.py]"]
  node_entities["DXF entities<br/>[dxfentity.py]"]
  node_layouts["Layouts<br/>[layout.py]"]
end

subgraph group_format["DXF format I/O"]
  node_tagger["Tag parsing<br/>[tagger.py]"]
  node_tags["Tag collections<br/>[tags.py]"]
  node_validator["DXF validation<br/>[validator.py]"]
  node_fileio["File management<br/>[filemanagement.py]"]
  node_filewriter["DXF writing<br/>[tagwriter.py]"]
end

subgraph group_processing["Document processing"]
  node_recovery["File recovery<br/>[recover.py]"]
  node_query["Entity queries<br/>[query.py]"]
  node_geometry["Geometry tools"]
end

subgraph group_visual["Rendering"]
  node_drawing["Render pipeline<br/>[pipeline.py]"]
  node_backend["Render backends<br/>[backend.py]"]
  node_fontmanager["Font management<br/>[font_manager.py]"]
end

subgraph group_addons["Extensions"]
  node_streaming["Large-file iteration<br/>[iterdxf.py]"]
  node_importer["Document importer<br/>[importer.py]"]
  node_r12writer["Direct R12 writer<br/>[r12writer.py]"]
  node_hpgl["HPGL/2 converter"]
  node_dwg["DWG interface<br/>[odafc.py]"]
end

node_programmer(("Programmer"))

node_programmer -->|"calls API"| node_api
node_api -->|"reads or creates"| node_fileio
node_fileio -.->|"loads tags"| node_tagger
node_tagger -->|"produces tags"| node_tags
node_fileio -->|"validates input"| node_validator
node_fileio -->|"loads drawing"| node_document
node_document -->|"holds entities"| node_entities
node_document -->|"provides layouts"| node_layouts
node_api -->|"writes drawing"| node_fileio
node_fileio -.->|"serializes tags"| node_filewriter
node_api -->|"recovers files"| node_recovery
node_programmer -->|"selects entities"| node_query
node_programmer -->|"requests rendering"| node_drawing
node_drawing -->|"sends render data"| node_backend
node_drawing -->|"resolves fonts"| node_fontmanager
node_programmer -->|"iterates modelspace"| node_streaming
node_programmer -->|"imports document data"| node_importer
node_programmer -->|"writes R12 stream"| node_r12writer
node_programmer -->|"converts plot files"| node_hpgl
node_programmer -->|"reads or writes DWG"| node_dwg

click node_api "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/__init__.py"
click node_document "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/document.py"
click node_entities "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/entities/dxfentity.py"
click node_layouts "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/layouts/layout.py"
click node_tagger "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/tagger.py"
click node_tags "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/tags.py"
click node_validator "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/validator.py"
click node_fileio "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/filemanagement.py"
click node_filewriter "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/tagwriter.py"
click node_recovery "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/recover.py"
click node_query "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/query.py"
click node_geometry "https://github.com/mozman/ezdxf/tree/master/src/ezdxf/math"
click node_drawing "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/drawing/pipeline.py"
click node_backend "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/drawing/backend.py"
click node_fontmanager "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/fonts/font_manager.py"
click node_streaming "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/iterdxf.py"
click node_importer "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/importer.py"
click node_r12writer "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/r12writer.py"
click node_hpgl "https://github.com/mozman/ezdxf/tree/master/src/ezdxf/addons/hpgl2"
click node_dwg "https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/odafc.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_api,node_document,node_entities,node_layouts toneBlue
class node_tagger,node_tags,node_validator,node_fileio,node_filewriter toneAmber
class node_recovery,node_query,node_geometry toneMint
class node_drawing,node_backend,node_fontmanager toneRose
class node_streaming,node_importer,node_r12writer,node_hpgl,node_dwg,node_programmer toneIndigo
```

## Components

### Document model

- [Public API](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/__init__.py): `src/ezdxf/__init__.py`
- [Drawing document](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/document.py): `src/ezdxf/document.py`
- [DXF entities](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/entities/dxfentity.py): `src/ezdxf/entities/dxfentity.py`
- [Layouts](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/layouts/layout.py): `src/ezdxf/layouts/layout.py`

### DXF format I/O

- [Tag parsing](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/tagger.py): `src/ezdxf/lldxf/tagger.py`
- [Tag collections](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/tags.py): `src/ezdxf/lldxf/tags.py`
- [DXF validation](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/validator.py): `src/ezdxf/lldxf/validator.py`
- [File management](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/filemanagement.py): `src/ezdxf/filemanagement.py`
- [DXF writing](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/lldxf/tagwriter.py): `src/ezdxf/lldxf/tagwriter.py`

### Document processing

- [File recovery](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/recover.py): `src/ezdxf/recover.py`
- [Entity queries](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/query.py): `src/ezdxf/query.py`
- [Geometry tools](https://github.com/mozman/ezdxf/tree/master/src/ezdxf/math): `src/ezdxf/math`

### Rendering

- [Render pipeline](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/drawing/pipeline.py): `src/ezdxf/addons/drawing/pipeline.py`
- [Render backends](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/drawing/backend.py): `src/ezdxf/addons/drawing/backend.py`
- [Font management](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/fonts/font_manager.py): `src/ezdxf/fonts/font_manager.py`

### Extensions

- [Large-file iteration](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/iterdxf.py): `src/ezdxf/addons/iterdxf.py`
- [Document importer](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/importer.py): `src/ezdxf/addons/importer.py`
- [Direct R12 writer](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/r12writer.py): `src/ezdxf/addons/r12writer.py`
- [HPGL/2 converter](https://github.com/mozman/ezdxf/tree/master/src/ezdxf/addons/hpgl2): `src/ezdxf/addons/hpgl2`
- [DWG interface](https://github.com/mozman/ezdxf/blob/master/src/ezdxf/addons/odafc.py): `src/ezdxf/addons/odafc.py`

### Other components

- **Programmer**

## Connections

- Programmer → Public API: calls API
- Public API → File management: reads or creates (evidence: `src/ezdxf/__init__.py`)
- File management → Tag parsing: loads tags
- Tag parsing → Tag collections: produces tags (evidence: `src/ezdxf/lldxf/tagger.py`)
- File management → DXF validation: validates input (evidence: `src/ezdxf/__init__.py`)
- File management → Drawing document: loads drawing
- Drawing document → DXF entities: holds entities
- Drawing document → Layouts: provides layouts
- Public API → File management: writes drawing (evidence: `src/ezdxf/__init__.py`)
- File management → DXF writing: serializes tags
- Public API → File recovery: recovers files (evidence: `src/ezdxf/__init__.py`)
- Programmer → Entity queries: selects entities (evidence: `src/ezdxf/query.py`)
- Programmer → Render pipeline: requests rendering
- Render pipeline → Render backends: sends render data (evidence: `src/ezdxf/addons/drawing/pipeline.py`)
- Render pipeline → Font management: resolves fonts (evidence: `src/ezdxf/addons/drawing/pipeline.py`)
- Programmer → Large-file iteration: iterates modelspace
- Programmer → Document importer: imports document data
- Programmer → Direct R12 writer: writes R12 stream
- Programmer → HPGL/2 converter: converts plot files
- Programmer → DWG interface: reads or writes DWG
