Visualising Software Architecture: Why It’s Important and How I Do It

My first introduction to programming was back in the ‘80’s with AmigaBASIC; the default programming language that came bundled with the Commodore Amiga. Throughout school and university, I learnt other languages such as Modula-2, before getting my first job where I started with COBOL and soon after ColdFusion. Luckily, I soon diversified to more mainstream technology, such as Java and .Net, before becoming a newly appointed “architect” at some point in the mid noughties.

In all the various career moves I have had over the years I found the progression from software engineer to architect to be one of the hardest. At the time I thought I was simply moving into a more senior version of my previous role, but in reality, it was the first time I was properly introduced to the business side of IT; either through the managers I was working alongside internally, or with the customers I was delivering to.

The thing I learnt most during this peroid was effective communication is critical for any successful architect.

Effective communication is a wide topic, including all manner of written and verbal channels, such as presentations, emails, bid responses etc. However, the thing I will talk about in this post — and the thing I believe is a critical skill for architects — is diagramming software architectures.

Why is this a critical skill?

1. It simplifies complexity: Software systems can be intricate, with multiple components and interactions. The role of an architect is to simplify this complexity. A good architect should be able to simplify all aspects of the software building process — from the pre-sales bid response they are working on, through to the software they are helping deliver to production. All stages of this journey will require an architect to communicate system complexity in a way that is easy to understand for both technical and business stakeholders. Visual representations play a key role in helping to break down this complexity, making it easier for teams to understand the design of the system and where it fits within the wider landscape.

2. It ensures consistency: Standardising the way we visualise software architectures ensures that everyone interprets the diagrams the same way, reducing miscommunication. Too often I see software architectures visualised using a confused mess of boxes and lines, with inconsistent notation (colour coding, shapes, line styles), ambiguous naming, unlabelled relationships, and mixed abstractions. Standardising how we deal with these concepts ensures diagrams are consistently drawn at the right level of detail, helping to improve understanding and minimise ambiguity.

3. It improves efficiency: A good diagram should be self-explanatory. How many times have you attended a meeting only for the first 30 minutes to be spent listening to someone walk through a diagram? There are occasions where this is a good use of time, but if we can create diagrams that are self-explanatory it ensures this doesn’t need to be the default mode of operation, allowing time to be spent on higher value activity.

4. It streamlines decision making: A clear visualisation aids in making informed decisions about changes, additions, or modifications to the system. Many teams use Architectural Decision Records (ADRs) or Open Design Proposals (ODPs) to capture and communicate important decisions. Not only can diagrams support this process, but if properly versioned they can also be linked to the ADR/ODP to provide context and history.

5. It accelerates onboarding of new team members: A visual representation can serve as an important reference for new team members, accelerating their onboarding process and helping them get up to speed more quickly.

Options for Visualising Software Architecture

There are numerous tools and standards available for visualising software architecture, including those listed below. Like many things, your choice may come down to personal preferences or taste — and there is no right or wrong answer.

1. Drawing Tools:

  • Draw.io: A web and desktop-based tool known for its simplicity and versatility in diagramming.
  • Lucidchart: A more advanced set of features when compared to Draw.io, including data, automation, and team collaboration.
  • OmniGraffle: A powerful diagramming application for Mac, known for its precision and wide range of styles.

2. Drawing Frameworks:

  • UML (Unified Modeling Language): A standardised modelling language that provides a general way to visualise the design of a system.
  • C4 (Context, Containers, Components, and Code): A framework that breaks down the architecture into different levels of granularity.
  • Archimate: An open standard for enterprise architecture modelling, that supports the description, analysis, and visualisation of architecture.

My Personal Approach: The C4 Model with PlantUML

Having used most of the tools and standards outlined above, where I’ve found success is with a particular combination: the C4 model visualised using PlantUML.

The C4 model breaks down the software system into the following levels, ensuring a thorough understanding, from a high-level system context to the intricacies of code.

  • System Context diagram — A System Context diagram is always where I start when visualising a new architecture. It forces you to step back and see the big picture, ensuring that your system is represented by a single box, surrounded by its users and the other systems that it interacts with. Detail isn’t important here as this is your zoomed out view showing a big picture of the system landscape. The focus should be on people and software systems rather than technologies, protocols, and other low-level details. It’s the sort of diagram that you could show to non-technical people. Here is an example System Context Diagram. I have used a script to generate this automatically from a CSV file (see below for details).

  • Container diagram — Once you understand how your system fits into the overall IT environment, a useful next step is to zoom-in to the system boundary with a Container diagram. A “container” is something like a server-side web application, single-page application, desktop application, mobile app, database schema, file system, etc. The Container diagram shows the high-level shape of the software architecture and how responsibilities are distributed across it. It also shows the major technology choices and how the containers communicate with one another. It’s a simple, high-level technology focussed diagram that is useful for software developers and support/operations staff alike.

  • Component diagram — Next you can zoom in and decompose each container further to identify the major structural building blocks and their interactions. The Component diagram shows how a container is made up of several “components”, what each of those components are, their responsibilities and the technology/implementation details.

  • Code diagram — Finally, you can zoom in to each component to show how it is implemented as code; using UML class diagrams, entity relationship diagrams or similar. This is an optional level of detail and is often available on-demand from tooling such as IDEs.

Note, you don’t need to use all four levels of diagram; only those that add value. In practice I find the System Context and Container diagrams to be the two I use the most.

You can create C4 diagrams using conventional drag-and-drop tools (such as Draw.io), but I have found these are difficult to maintain and manage. I prefer to express the C4 diagrams using PlantUML, which has the added benefit that diagrams can be expressed as code — see below for a Python script I use. This offers several advantages, including:

  • Version Control: The architecture diagrams can be stored as code and version controlled.
  • Collaboration: Changes and reviews can be managed like any other piece of code, fostering collaboration.
  • Automation: Diagrams can be automatically generated from the code, enabling quicker iterations and up-to-date representations.

It is important to note, there are scenarios where I don’t use C4 diagrams. Physical architecture diagrams are one example, and you may have other scenarios also. This is ok. The important thing is to use it for the scenarios that work best for you and your team.

In conclusion, visualising software architecture is not just about making pretty diagrams — it’s about clarity, understanding, and effective communication. While there are numerous tools and standards available, it’s essential to find what works for you and your team. For me, the C4 model with PlantUML, automated using python, strikes the perfect balance between clarity and efficiency.

Appendix 1 — How I setup up my MacBook to use C4 and PlantUML

There are a few pre-requisites for this to run locally. These are the steps I followed:

  • Install Java. You can download and install this directly from the Java website, or alternatively use a package manager such as Homebrew.
  • Next, install Graphviz from the Graphviz website. If you are a mac user there are options to use MacPorts or Homebrew. The Homebrew port didn’t work for me, so I used this MacPorts link.
  • Visual Studio Code — This is where you write the code for your architecture diagrams. VS Code doesn’t have out of the box support for PlantUML so you need to install a plug-in. If you don’t already have VS Code the download for this can be easily located via Google search. Once you have VSCode installed, go to the extensions view and search for “plantuml”. You may see a few options, but the one I use is provided by Jebbs.

You are now ready to create your first diagram. The best place to start is by following the Getting Started Section at the link below.

https://github.com/plantuml-stdlib/C4-PlantUML

Once you have written your first lines of code you hit option+D inside Visual Studio Code to visualise the diagram. It can take a while to get up and running, but I have found an investment in this learning curve to be well worth it.

Appendix 2 — Automated generation of System Context diagram from CSV file

I have created a simple Python tool for converting a CSV file into PlantUML C4 diagrams. The tool supports C4 system components, relationships, and boundaries. It also supports custom tagging of entities and relationships and automated generation of PNG diagram images. The script parses the CSV file to create a PUML file, and then uses this PUML file to create a PNG image. There are lots of ways this could be improved but it’s a good start and does most of what I need. Feel free to use and improve.

Instructions for using the script together with details on the CSV format are outlined on my GitHub page.


Originally published on Medium.