(616) 371-1037

[email protected]

Tooling for the C4 Model: Structurizr Lite

December 6, 2021 - Rodrigo Juarez

No Comments

In a previous blog post, I did a brief introduction to Architecture Software Visualization using the C4 Model.

On this one, I want to show you some of the available tooling and give you a quick walkthrough on how to create our architecture models.


Simon Brown created Structurizr to build software architecture models as code (Diagrams as code 2.0).

It’s a Domain Specific Language (DSL) that you use to define your model, and then it can be visualized with some tooling.

The DSL uses the domain language of software architecture, check the documentation for the full language reference.

In Diagrams as code 2.0 you create and maintain a single model, and the tool generates and keep in sync multiple diagrams. Just for reference, with the first version, you would have to create and maintain the code for multiple diagrams and keep them all in sync.

Advantages of Diagrams as Code 2.0

  • Maintain a single model
  • Easier to create and collaborate on
  • Can be added to version control
  • Can be integrated into your CI/CD

Creating Our Model – DSL Basics

With Structurizr you can use different programming languages to create your model, or a text-based DSL, I will try to keep it simple, and we are going to use the text-based DSL version.

Here is a full sample (workspace) and some comments on the structure.

The first building block is the workspace (1), a wrapper for your model (2), views (4), and additional documentation.

Notice the naming of the views, systemContext, container, component, implement to the C4 Model, also the code view is not available in the DSL, because is not expected to be in our models.

Inside your model you will have the different elements that defines your architecture in the C4 Model, like softwareSystem, container or component along with the properties for every element, and the relations (3) between the different parts.

The theme and styles (5) section allow customization of your model.

Now that we have our model defined, let me show you how we can visualize it.

Structurizr Lite

This is a free version of Structurizr designed for developers and packaged as a Docker container. You can locally view your diagrams and export it as PNG files.

Install and Configure Structurizr Lite

To use Structurizr Lite on your local computer, you will need Docker installed.

After you have Docker running, you need to pull the Structurizr Lite image, and run the tool with the following command (I’m using Power Shell on a Windows PC)

docker pull structurizr/lite

docker run -it –rm -p 8080:8080 -v C:/architecture-demo:/usr/local/structurizr structurizr/lite

Structurizr will start and show the following message

Notice that we are setting a local folder (c:\architecture-demo) were our dsl file will be deployed, so, we take our example file, name it workspace.dsl, and copy it to that folder.

Now we can open any web browser and navigate to http://localhost:8080, accept the license, and see our model in the Diagram section.

The diagrams window has a navigation panel to the left, that you can use to access any of the views (1), the thumbnails will be created after you access the individual views.

In any diagram that you can zoom in, you will see a + sign that will navigate to that view (2). In the following screenshot, the plus sign will navigate to the container diagram.

Additional Content

This is just a quick overview, a lot of interesting topics are not covered here like exporting views, the cloud services to use Structurizr as a hosted app, extensions to work with text-based DSL on Visual Studio Code or code-based DSL with .NET.

Please check the resources section, and thanks for reading!


Structurizr official site

Play with the DSL

Cloud Services (Hosted Structurizr)

Visual Studio Code extensions for text-based DSL

Code-based DSL for .Net

Rodrigo Juarez

I'm a full-stack and Xamarin Certified Mobile Professional developer. My mission is to solve complex problems for my clients focusing on the results, applying the most adequate technology available and best practices to ensure a cost-effective and high-quality solution. I have 20+ years of experience in a wide variety of projects in the development of applications for web, desktop, and mobile using Microsoft technologies in areas such as management, services, insurance, pharmacy, and banks.

Leave a comment

Your email address will not be published. Required fields are marked *