# nukleon84/pyflowsheet architecture

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

- Interactive diagram: https://gitdiagram.com/nukleon84/pyflowsheet
- Repository: https://github.com/nukleon84/pyflowsheet

## Overview

Pyflowsheet is a Python toolkit for constructing and rendering process-flow diagrams from code. The main workflow is to create a flowsheet, add unit operations and annotations, connect ports with streams, route those streams automatically or manually, then draw through a rendering context. The graph preserves the documented unit-operation, vessel-internals, and annotation capabilities. Relationships among unsampled specialized operations are shown as capability branches; detailed rendering and routing internals are represented only where supported by excerpts or README statements.

Main entry points: [`pyflowsheet/core/unitoperation.py`](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/unitoperation.py) (Unit operations), [`pyflowsheet/core/flowsheet.py`](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/flowsheet.py) (Flowsheet), [`pyflowsheet/backends/svgcontext.py`](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/backends/svgcontext.py) (SVG context), [`pyflowsheet/core/stream.py`](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/stream.py) (Stream)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Diagram model"]
  node_flowsheet["Flowsheet<br/>[flowsheet.py]"]
  node_unitbase["Unit operations<br/>[unitoperation.py]"]
  node_ports["Ports<br/>[port.py]"]
  node_enums["Enums and alignment<br/>[enums.py]"]
end

subgraph group_operations["Process equipment"]
  node_basicops["Basic process units"]
  node_vessel["Vessel<br/>[vessel.py]"]
  node_distillation["Distillation column<br/>[distillation.py]"]
  node_heatops["Heat exchangers<br/>[heatexchanger.py]"]
  node_platehex["Plate exchanger<br/>[platehex.py]"]
  node_internals["Vessel internals"]
end

subgraph group_routing["Streams and routing"]
  node_stream["Stream<br/>[stream.py]"]
  node_pathfinder["Pathfinder<br/>[pathfinder.py]"]
end

subgraph group_render["Rendering and annotations"]
  node_svg["SVG context<br/>[svgcontext.py]"]
  node_bitmap["Bitmap context<br/>[bitmapcontext.py]"]
  node_annotations["Text annotations<br/>[textelement.py]"]
  node_figure["Figure annotation<br/>[figure.py]"]
  node_table["Table annotation<br/>[table.py]"]
end

node_engineer(("Process engineer"))

node_engineer -->|"constructs"| node_flowsheet
node_engineer -->|"adds equipment"| node_basicops
node_engineer -->|"connects ports"| node_stream
node_flowsheet -->|"creates streams"| node_stream
node_flowsheet -->|"draws units"| node_unitbase
node_flowsheet -->|"draws annotations"| node_annotations
node_stream -->|"routes automatically"| node_pathfinder
node_stream -->|"reads endpoints"| node_ports
node_unitbase -->|"draws internals"| node_internals
node_vessel -->|"accepts internals"| node_internals
node_distillation -->|"accepts internals"| node_internals
node_basicops -->|"extends base"| node_unitbase
node_vessel -->|"extends base"| node_unitbase
node_distillation -->|"extends base"| node_unitbase
node_heatops -->|"extends base"| node_unitbase
node_platehex -->|"extends base"| node_unitbase
node_vessel -->|"defines ports"| node_ports
node_distillation -->|"defines ports"| node_ports
node_platehex -->|"defines ports"| node_ports
node_platehex -->|"uses flow pattern"| node_enums
node_flowsheet -->|"draws through context"| node_svg
node_flowsheet -.->|"draws through context"| node_bitmap
node_svg -.->|"renders text"| node_annotations
node_svg -.->|"renders figure"| node_figure
node_svg -.->|"renders table"| node_table

click node_flowsheet "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/flowsheet.py"
click node_unitbase "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/unitoperation.py"
click node_ports "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/port.py"
click node_enums "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/enums.py"
click node_basicops "https://github.com/nukleon84/pyflowsheet/tree/main/pyflowsheet/unitoperations"
click node_vessel "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/vessel.py"
click node_distillation "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/distillation.py"
click node_heatops "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/heatexchanger.py"
click node_platehex "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/platehex.py"
click node_internals "https://github.com/nukleon84/pyflowsheet/tree/main/pyflowsheet/internals"
click node_stream "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/stream.py"
click node_pathfinder "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/pathfinder.py"
click node_svg "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/backends/svgcontext.py"
click node_bitmap "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/backends/bitmapcontext.py"
click node_annotations "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/annotations/textelement.py"
click node_figure "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/annotations/figure.py"
click node_table "https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/annotations/table.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_flowsheet,node_unitbase,node_ports,node_enums toneBlue
class node_basicops,node_vessel,node_distillation,node_heatops,node_platehex,node_internals toneAmber
class node_stream,node_pathfinder toneMint
class node_svg,node_bitmap,node_annotations,node_figure,node_table toneRose
class node_engineer toneIndigo
```

## Components

### Diagram model

- [Flowsheet](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/flowsheet.py): `pyflowsheet/core/flowsheet.py`
- [Unit operations](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/unitoperation.py): `pyflowsheet/core/unitoperation.py`
- [Ports](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/port.py): `pyflowsheet/core/port.py`
- [Enums and alignment](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/enums.py): `pyflowsheet/core/enums.py`

### Process equipment

- [Basic process units](https://github.com/nukleon84/pyflowsheet/tree/main/pyflowsheet/unitoperations): `pyflowsheet/unitoperations`
- [Vessel](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/vessel.py): `pyflowsheet/unitoperations/vessel.py`
- [Distillation column](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/distillation.py): `pyflowsheet/unitoperations/distillation.py`
- [Heat exchangers](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/heatexchanger.py): `pyflowsheet/unitoperations/heatexchanger.py`
- [Plate exchanger](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/unitoperations/platehex.py): `pyflowsheet/unitoperations/platehex.py`
- [Vessel internals](https://github.com/nukleon84/pyflowsheet/tree/main/pyflowsheet/internals): `pyflowsheet/internals`

### Streams and routing

- [Stream](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/stream.py): `pyflowsheet/core/stream.py`
- [Pathfinder](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/core/pathfinder.py): `pyflowsheet/core/pathfinder.py`

### Rendering and annotations

- [SVG context](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/backends/svgcontext.py): `pyflowsheet/backends/svgcontext.py`
- [Bitmap context](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/backends/bitmapcontext.py): `pyflowsheet/backends/bitmapcontext.py`
- [Text annotations](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/annotations/textelement.py): `pyflowsheet/annotations/textelement.py`
- [Figure annotation](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/annotations/figure.py): `pyflowsheet/annotations/figure.py`
- [Table annotation](https://github.com/nukleon84/pyflowsheet/blob/main/pyflowsheet/annotations/table.py): `pyflowsheet/annotations/table.py`

### Other components

- **Process engineer**

## Connections

- Process engineer → Flowsheet: constructs
- Process engineer → Basic process units: adds equipment
- Process engineer → Stream: connects ports
- Flowsheet → Stream: creates streams (evidence: `pyflowsheet/core/flowsheet.py`)
- Flowsheet → Unit operations: draws units (evidence: `pyflowsheet/core/flowsheet.py`)
- Flowsheet → Text annotations: draws annotations (evidence: `pyflowsheet/core/flowsheet.py`)
- Stream → Pathfinder: routes automatically (evidence: `pyflowsheet/core/stream.py`)
- Stream → Ports: reads endpoints (evidence: `pyflowsheet/core/stream.py`)
- Unit operations → Vessel internals: draws internals (evidence: `pyflowsheet/core/unitoperation.py`)
- Vessel → Vessel internals: accepts internals
- Distillation column → Vessel internals: accepts internals (evidence: `pyflowsheet/unitoperations/distillation.py`)
- Basic process units → Unit operations: extends base (evidence: `pyflowsheet/unitoperations/blackbox.py`)
- Vessel → Unit operations: extends base (evidence: `pyflowsheet/unitoperations/vessel.py`)
- Distillation column → Unit operations: extends base (evidence: `pyflowsheet/unitoperations/distillation.py`)
- Heat exchangers → Unit operations: extends base (evidence: `pyflowsheet/unitoperations/heatexchanger.py`)
- Plate exchanger → Unit operations: extends base (evidence: `pyflowsheet/unitoperations/platehex.py`)
- Vessel → Ports: defines ports (evidence: `pyflowsheet/unitoperations/vessel.py`)
- Distillation column → Ports: defines ports (evidence: `pyflowsheet/unitoperations/distillation.py`)
- Plate exchanger → Ports: defines ports (evidence: `pyflowsheet/unitoperations/platehex.py`)
- Plate exchanger → Enums and alignment: uses flow pattern (evidence: `pyflowsheet/unitoperations/platehex.py`)
- Flowsheet → SVG context: draws through context
- Flowsheet → Bitmap context: draws through context
- SVG context → Text annotations: renders text
- SVG context → Figure annotation: renders figure
- SVG context → Table annotation: renders table
