Tooling for the C4 Model: Structurizr Lite

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.

Structurizr

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 https://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!

Resources

Structurizr official site
Play with the DSL
Cloud Services (Hosted Structurizr)
Visual Studio Code extensions for text-based DSL
Code-based DSL for .Net

Picture of Rodrigo Juarez

Rodrigo Juarez

Rodrigo Juarez has over 25 years of experience in software development, specializing in Microsoft technologies. His mission is to solve complex problems for his clients, with a focus on results. He achieves this by applying the appropriate technology and using best practices to ensure the delivery of high-quality solutions. Over the past 6 years, Rodrigo has honed his skills in back-end development and in creating mobile applications, initially using Xamarin and now transitioning to .NET MAUI. He is a Lead Mobile Developer at Trailhead Technology Partners and the co-author, along with Jesse Liberty, of the book ".NET MAUI for C# Developers"

Free Consultation

Sign up for a FREE consultation with one of Trailhead's experts.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Related Blog Posts

We hope you’ve found this to be helpful and are walking away with some new, useful insights. If you want to learn more, here are a couple of related articles that others also usually find to be interesting:

The C4 Model for Visualizing Software Architecture

Introduction In this blog post, I will try to briefly condense my understanding of the work of Simon Brown, the creator of the C4 Model, a set of hierarchical diagrams that you can use to describe your software architecture. I will talk abo

Read More

Right-Sizing Your Front-End Tech Stack

Selecting the right tech stack can be a make-or-break decision for many projects. While some applications benefit from a complex stack, many others can thrive with a simpler, more streamlined setup. Choosing a lighter stack doesn’t just cut

Read More

Our Gear Is Packed and We're Excited to Explore With You

Ready to come with us? 

Together, we can map your company’s software journey and start down the right trails. If you’re set to take the first step, simply fill out our contact form. We’ll be in touch quickly – and you’ll have a partner who is ready to help your company take the next step on its software journey. 

We can’t wait to hear from you! 

Main Contact

This field is for validation purposes and should be left unchanged.

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the form below. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Thank you for reaching out.

You’ll be getting an email from our team shortly. If you need immediate assistance, please call (616) 371-1037.