Structurizr

The Structurizr DSL takes a different approach from every other language here: you define the model once, then declare views onto it. Change a relationship and every view that shows it updates.

That consistency is the whole reason to accept the extra structure.


#What it is good at

  • Architecture documentation with more than a handful of diagrams.

  • C4 done properly, where levels must stay consistent.

  • Teams treating architecture as code, reviewed alongside it.


#What it draws

Diagram

Syntax starts with

Model

model { ... } containing people, systems, containers

Views

views { systemContext ... container ... }

Relationship

a -> b "Uses" "HTTPS"

Styling

styles { element "Database" { shape Cylinder } }


#A worked example

One model, with a context view and a container view:

Structurizr

The source, which you can paste into a new diagram and edit:

workspace {
  model {
    customer = person "Customer"
    shop = softwareSystem "Online shop" {
      web = container "Web app" "React"
      api = container "API" "Node.js"
      db = container "Database" "PostgreSQL"
    }
    payments = softwareSystem "Payment provider" "External"

    customer -> web "Browses and orders"
    web -> api "Calls" "JSON/HTTPS"
    api -> db "Reads and writes" "SQL"
    api -> payments "Charges card"
  }

  views {
    systemContext shop { include * autolayout lr }
    container shop { include * autolayout lr }
  }
}

#A few things that catch people out

  • Define relationships once in the model, never per view. That is the whole benefit.

  • A view with no include shows nothing. include * is the usual starting point.

  • For a single diagram, C4-PlantUML is less setup for the same picture.



Learn one properly. Borrow the rest when you need them.