Skip to content

Architecture

plantuml.rs preserves the architecture of the Java original, mapping Java packages to Rust crates in the workspace.

Source text
BlockUmlBuilder Splits input into @start/@end blocks
BlockUml One per @start/@end block. Lazy: TimLoader
│ preprocesses (!include, !define, variables)
PSystemBuilder createPSystem() dispatches to the
│ diagram-type factory (Sequence, Class,
│ Activity, UseCase, etc.)
Diagram object The in-memory diagram model
Diagram.exportDiagram() Renders via FileFormat-specific StringBinder
│ to SVG / PNG / PDF / LaTeX / EPS / etc.
Output bytes
Java Package(s)Rust CrateResponsibility
klimtplantuml-klimt2D graphics: shapes, geometry, fonts, StringBounder, UGraphic, TextBlock
com.plantuml.ubrexplantuml-regexCustom regex engine
preproc / timplantuml-preprocPreprocessor: !include, !define, variables, conditionals
commandplantuml-commandCommand / CommandFactory parsing framework
abel / cucadiagramplantuml-modelEntity/relationship model: Entity, Link, LeafType
sequencediagramplantuml-sequenceSequence diagram
skin / style / themeplantuml-skinSkin / style / theme system
realplantuml-real1D constraint solver for layout positioning
svgplantuml-svgSVG rendering backend
root (partial)plantuml-engineBlockUml, BlockUmlBuilder, PSystemBuilder, SourceStringReader, unified render API
root (partial)plantuml-coreDiagram, TextBlock, StringBounder, FileFormat, FileFormatOption
plantuml-ffiC FFI shared library for language bindings
plantuml-wasmWASM module (wasm-bindgen) for TypeScript binding

The Rust port preserves the key design patterns from the Java original:

  1. Factory + RegistryPSystemBuilder dispatches to per-type *DiagramFactory implementations via a trait-based registry.
  2. Command pattern — Each source-line parser is a Command registered in a CommandFactory; mapped to a Command trait with implementations.
  3. StrategyFileFormat selects the rendering backend; layout backend selection (Graphviz vs ELK) is also a strategy, using trait objects or enums.
  4. Lazy initializationBlockUml.getDiagram() builds the model on demand via OnceCell<T> or explicit build() calls.
  5. Template methodTitledDiagram / Diagram define base behavior extended by subclasses; mapped to traits with default methods and composition.
plantuml.rs/
├── crates/
│ ├── plantuml-core/ # Diagram, TextBlock, StringBounder, FileFormat
│ ├── plantuml-klimt/ # 2D graphics: shapes, geometry, fonts
│ ├── plantuml-regex/ # Custom regex engine
│ ├── plantuml-preproc/ # Preprocessor: !include, !define, variables
│ ├── plantuml-command/ # Command / CommandFactory parsing framework
│ ├── plantuml-model/ # Entity/relationship model
│ ├── plantuml-engine/ # Top-level pipeline and unified render API
│ ├── plantuml-svg/ # SVG rendering backend
│ ├── plantuml-skin/ # Skin / style / theme system
│ ├── plantuml-real/ # 1D constraint solver for layout
│ ├── plantuml-sequence/ # Sequence diagram
│ ├── plantuml-ffi/ # C FFI shared library
│ └── plantuml-wasm/ # WASM module (wasm-bindgen)
├── bindings/
│ ├── plantuml-java/ # Java binding (JNI)
│ └── plantuml-ts/ # TypeScript binding (WASM)
└── Cargo.toml # Workspace manifest