Skip to main content

Structurizr for the `buildzr`s 🧱⚒️

Project description

Structurizr for the buildzrs 🧱⚒️

buildzr is a Structurizr authoring tool for Python programmers. It allows you to declaratively or procedurally author Structurizr models and diagrams.

If you're not familiar with Structurizr, it is both an open standard (see Structurizr JSON schema) and a set of tools for building software architecture diagrams as code. Structurizr derive its architecture modeling paradigm based on the C4 model, the modeling language for describing software architectures and the relationships.

In Structurizr, you define architecture models and their relationships first. And then, you can re-use the models to present multiple perspectives, views, and stories about your architecture.

Head over to ROADMAP.md to get a good high-level sense of what has been implemented in buildzr.

Quick Start 🚀

Installation

You can use pip to install the buildzr package:

pip install buildzr

Creating a workspace

The module buildzr.dsl contains all the classes you need to create a workspace containing all the architecture models.

Below is an example, where we:

  1. Create the models (Person, SoftwareSystems, the Containers inside the SoftwareSystem, and the relationships -- >> -- between them)
  2. Define multiple views using the models we've created before.
from buildzr.dsl import (
    Workspace,
    SoftwareSystem,
    Person,
    Container,
    SystemContextView,
    ContainerView,
    desc,
    Group,
)

with Workspace('w') as w:
    with Group("My Company"):
        u = Person('Web Application User')
        webapp = SoftwareSystem('Corporate Web App')
        with webapp:
            database = Container('database')
            api = Container('api')
            api >> ("Reads and writes data from/to", "http/api") >> database
    with Group("Microsoft"):
        email_system = SoftwareSystem('Microsoft 365')

    u >> [
        desc("Reads and writes email using") >> email_system,
        desc("Create work order using") >> webapp,
    ]
    webapp >> "sends notification using" >> email_system

    SystemContextView(
        software_system_selector=webapp,
        key='web_app_system_context_00',
        description="Web App System Context",
        auto_layout='lr',
        exclude_elements=[
            u,
        ]
    )

    ContainerView(
        software_system_selector=webapp,
        key='web_app_container_view_00',
        auto_layout='lr',
        description="Web App Container View",
    )

    w.to_json('workspace.json')

Here's a short breakdown on what's happening:

  • In the with Workspace('w') as w: block, we've created a Workspace named w.
  • Inside this block, we're in the context of the w workspace, so any models, relationships, and views we declared in this block will belong to that workspace. We've declared a few models: Person, the SoftwareSystems, their Containers, and their relationships with each other. Oh, we've separated them into different Groups, too!
  • Showing the who's and the what's in an architecture model is good, but an architecture model is incomplete without the arrows that describes the relationships between the systems. In buildzr, we can define relationships with the >> operator.
  • Once we have all the models and their relationships defined, we use (and re-use!) the static models to create multiple views to tell different stories and show various narrative to help document your software architecture. In this case, we've created one SystemContextView and one ContainerView for the webapp.
  • Finally, we write the workspace definitions into a JSON file, which can be consumed by rendering tools, or used for further processing.

The JSON output can be found here. You can also try out https://structurizr.com/json to see how this workspace will be rendered.

Why use buildzr?

✅ Uses buildzr's declarative DSL syntax to help you create C4 model architecture diagrams in Python concisely.

✅ Uses buildzr's DSL APIs to programmatically create C4 model architecture diagrams. Good if you need to automate things!

✅ Write Structurizr diagrams more securely with extensive type hints and mypy support.

✅ Stays true to the Structurizr JSON schema standards. buildzr uses the datamodel-code-generator to automatically generate the "low-level" representation of the Workspace model. This reduces deprecancy between buildzr and the Structurizr JSON schema.

✅ Writing architecture models and diagrams in Python allows you to integrate programmability and automation into your software architecture diagramming and documentation workflow. For example, you might want to programmatically automate the creation of architecture models from metadata pulled from your IT asset management system, but still want to declaratively define how to present them.

✅ Uses the familiar Python programming language and its rich toolchains to write software architecture models and diagrams!

Contributing

Interested in contributing to buildzr?

Please visit CONTRIBUTING.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildzr-0.0.20.tar.gz (57.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

buildzr-0.0.20-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file buildzr-0.0.20.tar.gz.

File metadata

  • Download URL: buildzr-0.0.20.tar.gz
  • Upload date:
  • Size: 57.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for buildzr-0.0.20.tar.gz
Algorithm Hash digest
SHA256 7d7e1ec5ca4b53f40e859fab8670518dbdb770b6e596f9d502a6ab8e8df46810
MD5 e69b08c60ce38a5a54005136871d61da
BLAKE2b-256 88cc6b0d2d259e7aa1b69086353ada55a91bf1fdab56786d07689c32af8dfde8

See more details on using hashes here.

File details

Details for the file buildzr-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: buildzr-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for buildzr-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 b4a0ab01c5c26882ddcd187521a7aff5d1bcde456fbbf1996082e00dd7186d1f
MD5 0ce85bc22d6f148640fc1cd47caf10f4
BLAKE2b-256 a150d2e67b37c3102525bdcb41a720209ca96e8884cc3f58684384e78bb7ef0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page