Skip to main content

c4-diagrams logo

A Python DSL for C4 model diagrams.

c4-diagrams

Release PyPI - Python Version Build status Maintainability Code Coverage License Ask DeepWiki

c4-diagrams is a Python DSL for defining C4 model architecture diagrams as code.

The package provides first-class abstractions for C4 entities — people, systems, containers, components, boundaries, and relationships — allowing you to describe software architecture in Python and render it into multiple diagram formats.

Features

  • Declarative Python DSL for C4 modeling
  • First-class C4 entities and relationships
  • Multiple rendering backends
  • Suitable for documentation, ADRs, and architecture reviews
  • Portable core DSL for the common C4 subset, with backend-specific features available through contrib extensions

Rendering backends

Currently supported backends:

Getting started

c4-diagrams requires Python 3.10 or higher.

pip install c4-diagrams

Example

Here’s an example of a system context diagram defined in Python:

# diagram.py
from c4 import (
    EnterpriseBoundary,
    Person,
    System,
    SystemContextDiagram,
    SystemExt,
)
from c4.contrib.plantuml import RelDown, RelRight


with SystemContextDiagram("Acme Shop Platform") as diagram:
    user = Person(
        "Customer",
        "A registered customer who browses products and places orders.",
    )

    with EnterpriseBoundary("Acme Corp"):
        web_app = System(
            "Web Application",
            "Customer-facing website for browsing products and placing orders.",
        )

        api_backend = System(
            "Backend API",
            "Handles authentication, order processing, and business logic.",
        )

    email_provider = SystemExt(
        "Email Provider",
        "Delivers transactional emails.",
    )

    user >> RelRight("Uses") >> web_app
    web_app >> RelRight("Calls API") >> api_backend
    api_backend >> RelDown("Sends emails via") >> email_provider

To export the diagram to a rendered artifact, run:

c4 export diagram.py > diagram.png

This generates the diagram below:

readme-diagram

diagram.png

For details (renderers, diagram types, API), see the documentation.

License

This project bundles files from the C4-PlantUML project. C4-PlantUML is licensed under the MIT License.

Contribution

Contribution guidelines for this project


Repository initiated with fpgmaas/cookiecutter-uv.

Metadata

Release files for c4-diagrams 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for c4-diagrams 0.7.1
File Size Uploaded
c4_diagrams-0.7.1.tar.gz 151.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for c4-diagrams 0.7.1
File Interpreter ABI Platform
c4_diagrams-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 346.5 kB

Release files / c4_diagrams-0.7.1.tar.gz

Download URL c4_diagrams-0.7.1.tar.gz
Size 151.4 kB
Tags Source
SHA-256 checksum
How to use checksums
25c47bd64e4d89cee391cccd504974edde20fe3941304345c94bf3832faa0cec
BLAKE2b-256 checksum
How to use checksums
b61cc69d6ad6c0925a6b8a0d14fcad72872071b560328852beb3490886dc4806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.

Transparency log

Release files / c4_diagrams-0.7.1-py3-none-any.whl

Download URL c4_diagrams-0.7.1-py3-none-any.whl
Size 195.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4009b5be59e8e9b179ecd82ee79aa9f1f77ad0fcbac6f00bb6ed73f6dda1845
BLAKE2b-256 checksum
How to use checksums
13de75c031f9ebd6ac6e3e331203a7534e666312c4fd5192f232a34a4d9377db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page