skillfed

pystructurizr

A Python DSL inspired by Structurizr, intended for generating C4 diagrams

pystructurizr v0.1.3 93.3K downloads/30d#13,391 on PyPI149
Permissive license MIT DORMANT released

What it is and what it does

PyStructurizr is a Python library that lets you define C4 software architecture diagrams using Python code instead of Structurizr's custom DSL language. It translates Python model definitions—persons, software systems, containers, and their relationships—into diagrams that can be viewed, exported, or uploaded to cloud storage. The package includes a CLI with three main modes: dump (convert Python to Structurizr DSL), dev (live preview in a browser), and build (generate SVG and upload to cloud providers like google-cloud-storage or boto3).

The library's main appeal is that it lets you use Python's full expressiveness—imports, functions, loops, version control—to manage architecture diagrams as code, rather than dealing with a custom language's syntax and primitive file-inclusion mechanisms. It depends on watchdog for file monitoring, click for CLI commands, httpx for HTTP requests, and cloud storage SDKs for upload functionality. The package is in alpha status and has been dormant since mid-2023, so active development has stalled.

Use it for:

  • Define C4 architecture diagrams in Python and export them to Structurizr DSL format for sharing or further editing
  • Generate live previews of architecture diagrams while editing Python model code in a development workflow
  • Convert Python-defined architecture models to SVG and automatically upload them to cloud storage for embedding in documentation
  • Organize large architecture models using Python's import and module system instead of Structurizr DSL's limited file inclusion
  • Version-control architecture diagrams as Python code alongside application source code for team collaboration

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyStructurizr provides a Python DSL for defining C4 software architecture diagrams programmatically, with CLI tools to convert to Structurizr DSL, generate SVG output, and preview diagrams live in a browser.

Yes, if you need to define C4 diagrams programmatically and prefer Python over Structurizr DSL syntax. The low install friction and permissive license make it accessible. However, proceed with caution: the package is in alpha, dormant since 2023, and has no known vulnerabilities but also no recent maintenance. It's suitable for personal projects or teams comfortable maintaining a stalled dependency, but risky for production systems requiring active support.

Install

pystructurizr on PyPI

pip

pip install pystructurizr

uv

uv add pystructurizr

poetry

poetry add pystructurizr

Installing pystructurizr

Before you install

Low install friction with a pure-Python wheel and eight runtime dependencies including watchdog, click, httpx, and cloud storage libraries (google-cloud-storage, boto3). Maintenance is dormant—last release was 2023-07-27 and last commit 2024-03-06, though the repository remains active and unarchived.

License in practice

MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions, making it suitable for both open-source and commercial projects.

Quickstart

pip install pystructurizr

from pystructurizr.dsl import Workspace

with Workspace() as workspace:
    with workspace.Model(name="model") as model:
        user = model.Person("User")
        with model.SoftwareSystem("System") as sys:
            app = sys.Container("App")
    user.uses(app, "Uses")

Verify before relying

  • Whether the package works reliably with Python versions beyond 3.8, given classifiers list only up to 3.8
  • Current state of kroki.io integration and whether the online diagram rendering service remains stable
  • Whether dormant maintenance status affects bug fixes or compatibility with recent Structurizr DSL changes

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 8 — watchdog, click, httpx, aiofiles, httpwatcher, google-cloud-storage, boto3, setuptools
Maintenance dormant — 1,114 days since the last release
Last repo commit
First released
Downloads 93,341/month — #13,391 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pystructurizr-0.1.3-py3-none-any.whl

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8

Tags

C4 diagram generation Pythonarchitecture diagram as codeStructurizr Python DSLsoftware architecture visualizationdiagram code to SVGlive diagram previewcloud storage diagram upload
architecture-as-codediagram-generationc4-model

More Software Development packages