Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

99 lines (73 sloc) 4.01 KB


Structurizr for Java also includes a simple exporter that can create diagram definitions compatible with PlantUML. The following diagram types are supported:

  • System Landscape
  • System Context
  • Container
  • Component
  • Dynamic
  • Deployment

Simply create your software architecture model and views as usual, and use the PlantUMLWriter class to export the views. For example:

Workspace workspace = new Workspace("Getting Started", "This is a model of my software system.");
Model model = workspace.getModel();

Person user = model.addPerson("User", "A user of my software system.");
SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
user.uses(softwareSystem, "Uses");

ViewSet views = workspace.getViews();
SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");

Styles styles = views.getConfiguration().getStyles();

StringWriter stringWriter = new StringWriter();
PlantUMLWriter plantUMLWriter = new PlantUMLWriter();
plantUMLWriter.addSkinParam("rectangleFontColor", "#ffffff");
plantUMLWriter.addSkinParam("rectangleStereotypeFontColor", "#ffffff");
plantUMLWriter.write(workspace, stringWriter);

This code will generate and output a PlantUML diagram definition that looks like this:

title Software System - System Context
caption An example of a System Context diagram.

skinparam {
  shadowing false
  arrowColor #707070
  actorBorderColor #707070
  componentBorderColor #707070
  rectangleBorderColor #707070
  noteBackgroundColor #ffffff
  noteBorderColor #707070
  rectangleFontColor #ffffff
  rectangleStereotypeFontColor #ffffff
rectangle 2 <<Software System>> #1168bd [
  Software System
  My software system.
actor "User" <<Person>> as 1 #08427b
note right of 1
  A user of my software system.
end note
1 .[#707070].> 2 : Uses

If you copy/paste this into PlantUML online, you will get something like this:

A simple PlantUML diagram

Benefits of using PlantUML with Structurizr

The key benefit of using PlantUML in conjunction with the Structurizr client library is that you can create diagrams from a model of your software system. The model provides a set of rules that must be followed; related to elements, relationships, and how they are exposed using diagrams. This means:

  1. Rather than looking after a collection of disjointed PlantUML diagram definitions, you can create many PlantUML diagrams from a single model and keep them all up to date easily, especially if integrated with your continuous build server and build pipeline.
  2. The naming of elements and the definition of relationships between elements remains consistent across diagrams.
  3. The software architecture model at the component level can be created by extracting components from a codebase, using static analysis and reflection techniques.


Here are the PlantUML versions of the diagrams from the Spring PetClinic example.

You can’t perform that action at this time.