PlantUML

Master this essential documentation concept

Quick Definition

An open-source text-based tool for generating UML diagrams from plain text definitions, commonly used in technical documentation for sequence, component, and class diagrams.

How PlantUML Works

Understanding PlantUML

An open-source text-based tool for generating UML diagrams from plain text definitions, commonly used in technical documentation for sequence, component, and class diagrams.

Key Features

  • Centralized information management
  • Improved documentation workflows
  • Better team collaboration
  • Enhanced user experience

Benefits for Documentation Teams

  • Reduces repetitive documentation tasks
  • Improves content consistency
  • Enables better content reuse
  • Streamlines review processes

Turn Videos into Data, AI & Analytics Documents

Use Docsie to convert training videos, screen recordings, and Zoom calls into ready-to-publish data, ai & analytics templates. Download free templates below, or generate documentation from video.

See how Docsie helps with plantuml documentation

Looking for a better way to handle plantuml in your organization? Docsie's PlantUML Documentation solution helps teams streamline their workflows and improve documentation quality.

Real-World Documentation Use Cases

Documenting Microservice Authentication Flows for Onboarding Engineers

Problem

New backend engineers spend days reverse-engineering OAuth2 token flows by reading scattered code across multiple microservices, because no up-to-date sequence diagram exists and hand-drawn Visio files are months out of date.

Solution

PlantUML sequence diagrams stored alongside source code in Git allow developers to update the authentication flow diagram in the same pull request as the code change, keeping documentation perpetually accurate.

Implementation

['Create an `auth-flow.puml` file in the `/docs` folder of the authentication service repository, defining actors like `Client`, `API Gateway`, `Auth Service`, and `Token Store`.', 'Use PlantUML `sequenceDiagram` syntax with `autonumber` to map each OAuth2 step: authorization request, token issuance, token validation, and refresh cycles.', 'Add a CI pipeline step using the `plantuml` Docker image to auto-generate PNG/SVG outputs on every merge to main and publish them to the team wiki via the Confluence REST API.', 'Add a PR checklist item requiring diagram updates whenever auth-related code changes, enforced by a CODEOWNERS rule pointing to the docs team.']

Expected Outcome

Onboarding time for understanding the auth flow drops from 2–3 days to under 2 hours, and diagram drift incidents are eliminated because diagrams live in version control alongside the code they describe.

Generating Class Diagrams from Domain Models in a DDD Codebase

Problem

Domain-Driven Design teams struggle to communicate aggregate boundaries and entity relationships to stakeholders because manually maintaining class diagrams in tools like Lucidchart diverges from the actual codebase within weeks of a sprint.

Solution

PlantUML class diagram syntax can be generated directly from code annotations or written manually to reflect the bounded context, then rendered in MkDocs or Sphinx as part of the living documentation site.

Implementation

['Install `pyreverse` (part of Pylint) or `plantuml-parser` for Java/Kotlin to auto-generate `.puml` class diagram stubs from existing domain model source files.', 'Refine the generated `.puml` file to highlight aggregate roots with `<>` stereotypes and mark value objects with `<>`, removing infrastructure-layer noise.', 'Embed the diagram in MkDocs using the `mkdocs-plantuml` plugin so that `!include domain-model.puml` renders inline within the architecture decision records (ADRs).', 'Schedule a weekly CI job to regenerate stubs and open a draft PR if the generated output differs from the committed `.puml` file, alerting the domain team to review.']

Expected Outcome

Stakeholder review sessions require 40% less time clarifying model boundaries, and the domain model diagram is consistently accurate within one sprint cycle rather than drifting for months.

Mapping AWS Infrastructure Component Dependencies for Incident Response Runbooks

Problem

During production incidents, on-call engineers waste critical minutes tracing which Lambda functions, SQS queues, and RDS instances are involved in a degraded service path because component dependency documentation exists only as outdated PowerPoint slides.

Solution

PlantUML component diagrams using the `C4Context` or standard component notation can represent AWS service dependencies in a text file that is version-controlled, searchable, and embeddable directly in runbook pages in Confluence or PagerDuty.

Implementation

['Define each AWS service as a PlantUML component with technology labels, e.g., `[Order Processor Lambda] <>` and `[Order Queue] <>`, grouping them into packages by VPC or service boundary.', 'Use directed arrows with labels like `triggers`, `reads from`, and `writes to` to make data flow unambiguous for engineers unfamiliar with the system.', 'Render the diagram to SVG and embed it at the top of each service runbook page in Confluence using the PlantUML Confluence macro or a pre-rendered image attachment updated by CI.', 'Tag each component with an `note` block containing the on-call Slack channel and primary runbook link so the diagram itself is an actionable reference during incidents.']

Expected Outcome

Mean time to identify the blast radius of an incident decreases by approximately 15 minutes per event, and new on-call engineers report significantly higher confidence navigating the infrastructure during their first pages.

Visualizing State Machine Transitions for an E-Commerce Order Lifecycle

Problem

Product managers, QA engineers, and backend developers have conflicting mental models of valid order state transitions (e.g., whether a `SHIPPED` order can move to `CANCELLED`), leading to bugs, missed test cases, and lengthy specification debates in Jira.

Solution

A PlantUML state diagram committed to the product specification repository serves as a single source of truth for all valid and invalid order state transitions, readable by both technical and non-technical stakeholders.

Implementation

['Create `order-lifecycle.puml` using PlantUML `@startuml` with `stateDiagram-v2` compatible state syntax, defining states like `PENDING`, `PAYMENT_CONFIRMED`, `FULFILLING`, `SHIPPED`, `DELIVERED`, `CANCELLED`, and `REFUNDED`.', 'Use `[*] --> PENDING` for the initial transition and annotate each arrow with the triggering business event, e.g., `PAYMENT_CONFIRMED --> FULFILLING : payment.webhook.received`.', 'Add `note right of CANCELLED` blocks to document business rules, such as which roles can trigger a cancellation and within what time window.', 'Publish the rendered diagram to the product spec Confluence page and link it from the Jira epic, requiring sign-off from product, QA, and engineering leads before any state transition logic is merged.']

Expected Outcome

QA test coverage for order state transitions increases from ad-hoc to systematic, catching three previously undetected invalid transition bugs in the first sprint after adoption, and specification debates in planning meetings are resolved by referencing the diagram rather than opinion.

Best Practices

Store `.puml` Files in the Same Repository as the Code They Document

Keeping PlantUML source files co-located with application code in Git ensures that diagram updates are reviewed in the same pull request as the code changes they reflect. This eliminates the most common cause of documentation drift: diagrams living in a separate wiki that no one remembers to update during a refactor.

✓ Do: Place `sequence-auth.puml` inside `/docs/architecture/` within the service repo and add a CODEOWNERS rule so the docs or architecture team is automatically requested as a reviewer on any PR that modifies it.
✗ Don't: Do not store PlantUML diagrams exclusively in Confluence or Notion pages disconnected from version control, as they will become stale within weeks and cannot be diffed or rolled back alongside code changes.

Use `!include` Directives to Share Common Styles and Skin Parameters

PlantUML supports `!include` to pull in shared style definitions, color palettes, and component stereotypes from a central `.iuml` file. Defining a shared style library prevents each diagram from having its own inconsistent color scheme and ensures a uniform visual language across all documentation.

✓ Do: Create a `corporate-theme.iuml` file defining `skinparam` values for fonts, colors, and arrow styles, then begin every `.puml` file with `!include ../shared/corporate-theme.iuml` to inherit the standard appearance.
✗ Don't: Do not copy-paste `skinparam` blocks into every individual `.puml` file, as a branding change or accessibility fix will require updating dozens of files manually instead of one shared include.

Automate Diagram Rendering in CI/CD to Produce Versioned SVG Artifacts

Running the PlantUML JAR or Docker image as a CI step ensures that rendered diagram images are always in sync with the latest committed `.puml` source. Publishing SVGs rather than PNGs preserves vector quality for high-DPI displays and allows text within diagrams to remain searchable and copyable.

✓ Do: Add a GitHub Actions step using `docker run plantuml/plantuml -tsvg docs/**/*.puml` that commits rendered SVGs back to the repo or uploads them to an artifact store, triggered on every push to main.
✗ Don't: Do not manually export and commit PNG files from a local PlantUML IDE plugin, as this creates binary files that cannot be meaningfully diffed in pull requests and will frequently be forgotten or out of sync.

Apply `autonumber` and Participant Aliases in Sequence Diagrams for Maintainability

Using `autonumber` in PlantUML sequence diagrams automatically numbers each message, making it easy for reviewers to reference a specific step by number in comments or bug reports without ambiguity. Defining short aliases for long participant names with `participant "Order Processing Service" as OPS` keeps the diagram source readable while preserving descriptive labels in the rendered output.

✓ Do: Write `autonumber` at the top of every sequence diagram and define aliases like `participant "Inventory Management API" as IMA` so that interaction lines read as `OPS -> IMA : reserveStock(orderId)` rather than repeating the full name.
✗ Don't: Do not use cryptic abbreviations as participant names without a full-name alias, and do not skip `autonumber` in diagrams with more than five steps, as referencing specific interactions in code reviews or incident postmortems becomes imprecise.

Limit Diagram Scope to a Single Bounded Context or Interaction Scenario

PlantUML diagrams become unreadable when they attempt to show an entire system in one file. A sequence diagram with more than 15 participants or a class diagram with more than 20 entities loses its communicative value and becomes a maintenance burden. Splitting diagrams by bounded context or user scenario keeps each one focused and actionable.

✓ Do: Create separate `.puml` files for each major user journey or service boundary, such as `checkout-payment-flow.puml` and `inventory-reservation-flow.puml`, and link between them using `note` blocks with cross-references rather than merging them into one giant diagram.
✗ Don't: Do not attempt to represent the entire microservice architecture or full domain model in a single PlantUML file, as the resulting diagram will be too dense to render legibly, too slow to load in wikis, and too broad to be useful for any specific documentation task.

How Docsie Helps with PlantUML

Build Better Documentation with Docsie

Join thousands of teams creating outstanding documentation

Start Free Trial