DEV Community

Simon Brown
Simon Brown

Posted on • Edited on

Getting started with the Structurizr DSL

Now that we've looked at diagramming vs modelling, and some of the tooling choices, let's see how to get started with the Structurizr DSL. This open source project defines a text-based domain specific language (DSL) that can be used to create software architecture diagrams based upon the C4 model.

Defining a model and view

Let's imagine that we want to create a System Context diagram showing a user using a software system. This can be described with the DSL as follows.



workspace {

    model {
        user = person "User" "A user of my software system."
        softwareSystem = softwareSystem "Software System" "My software system."

        user -> softwareSystem "Uses"
    }

    views {
        systemContext softwareSystem {
            include *
            autoLayout
        }
    }

}


Enter fullscreen mode Exit fullscreen mode

This DSL definition:

  • creates a person named "User"
  • creates a software system named "Software System"
  • creates a relationship between the person and the software system
  • creates a System Context view for the software system (including all applicable elements, with auto-layout enabled)

Rendering the diagram

To render the diagram, we need some additional tooling in the form of the Structurizr CLI, but we'll look at that in the next blog post. For now, there's a demo page that we can use to try out the DSL. If you browse to structurizr.com/dsl and copy the above DSL into the textbox, you should see something like the following when you click the "Refresh" button. Alternatively, clicking this link will do that for you.

Structurizr DSL demo

This demo page shows you how the diagram is rendered with the Structurizr tooling, plus it provides diagram definitions for PlantUML and Mermaid.

For more information

If you're interested in learning more about the DSL, take a look at the following links:

Summary

The Structurizr DSL is an open source project defining a text-based domain specific language (DSL) that can be used to create software architecture diagrams based upon the C4 model. The next blog post will show how to use the DSL in conjunction with the Structurizr CLI.

Top comments (1)

Collapse
 
der_gopher profile image
Alex Pliutau

Great write up. Structurizr is great. Made a video about it recently - youtube.com/watch?v=ySW7Jo9SyW0