Quick Notes about Structurizr - Part 1

For the past few months, I have been using Structurizr Lite for documenting my architectures as code. While doing this, I have had to find out some things. This is just a collection of these things.

In general, note that the documentation is excellent – it’s just a matter of figuring out what you are looking for and more often than not, you will end up on their own website… as you will see below. This is mostly a collection of links for me to list stuff that I have already searched and found, but will likely forget and need to search again.

Connecting a Container to another Container

In the C4 model, the diagrams are hierarchical. So, you see a number of items at the Context level and when you click through to the next level of any one diagram, you see the structure for that one. So, you might step into one system’s Container diagram. Typically, when there are connections from the container, you would connect from one of the containers to an external system. Sometimes, though, you want to show that this container has a connection to a container in another system.

To do this, look here: https://docs.structurizr.com/dsl/cookbook/container-view-multiple-software-systems/

I really don’t want to just make a copy of this page, so do read it, but in short:

  • Model the connection, e.g., c1 -> c2 outside the systems
  • Add a container view that mentions/ includes all the containers you want to show, e.g., include c1 c2


You can change the shape that is used for a diagram element. See https://docs.structurizr.com/ui/diagrams/notation#shapes for the full list of shapes and the names that are supported. I find it useful to use Cylinder, Folder, RoundedBox and Box.

The way you use it is to specify the shape name after shape in the style for the element, as below.

            element "Database" {
                background #808080
                color #ffffff
                shape Cylinder


While you’re on that page, look at the notation also to see what else can be styled and changed, specifically how to change the styling of arrows (e.g., to have different styles for incoming and outgoing data) or how groups are shown, or how icons are added.

Remove the metadata for an Element

Sometimes, you don’t want to see things like [SoftwareSystem] or [Person] in the diagram. To do this, add metadata false to the style of that element, as shown in the example below:

            element "Person" {
                shape person
                metadata false

The code and the idea is from the discussion here: https://github.com/structurizr/lite/discussions/111#discussioncomment-8036042

Nested Groups

At some point, you will end up nesting groups and discover that it does not work! The solution is shown when you first encounter the error, but basically you need to specify "structurizr.groupSeparator" "/" in your DSL for the model. This will look something like below:

    model {
        properties {
            "structurizr.groupSeparator" "/"

This, and much more useful stuff, including how to style nested groups is at: https://docs.structurizr.com/dsl/cookbook/groups/

Play with Structurizr Online

Remember that you can always play with the syntax online at: https://structurizr.com/dsl

Feel free to share the post (you can start a conversation or tag me as @onghu on Twitter or on Mastodon as @onghu@ruby.social ) or leave a comment below.

comments powered by Disqus