Skip to main content

AI-friendly architecture diagrams with grid-based positioning

Project description

diagrams-for-ai

CI PyPI

AI-friendly architecture diagrams with grid-based positioning.

diagrams-for-ai is a Python library that renders beautiful cloud architecture diagrams without Graphviz. Nodes are placed on a simple grid using row and col coordinates, making it trivial for an AI to generate diagrams programmatically.

Why diagrams-for-ai?

  • Grid-based positioning -- Place nodes with row and col. No fighting with Graphviz layout.
  • AI-friendly -- Explicit coordinates are easy for language models to produce and reason about.
  • Real icons -- Leverages the diagrams package for hundreds of icons across AWS, GCP, Azure, Kubernetes, and more.
  • Beautiful connections -- Four line styles: curved (bezier), straight, orthogonal, and step.
  • SVG & PNG output -- Portable SVG with embedded icons, or raster PNG via Pillow.
  • Familiar syntax -- Use >>, <<, and - operators to connect nodes, just like the original diagrams library.

Installation

uv add diagrams-for-ai

Or with pip:

pip install diagrams-for-ai

The diagrams package (which provides the icons) is installed automatically as a dependency.

Quick example

from diagrams_for_ai import Diagram, Node

with Diagram("Hello", rows=2, cols=2, outformat="png", show=False):
    a = Node("Service A", icon="aws/compute/ec2", row=0, col=0)
    b = Node("Service B", icon="aws/database/rds", row=1, col=1)
    a >> b

Full example

from diagrams_for_ai import Cluster, Diagram, Edge, LineStyle, Node

with Diagram("AWS Web Service", rows=5, cols=7, outformat=["svg", "png"], show=False):

    with Cluster("Public Subnet", row=0, col=1, width=5, height=2,
                 bg_color="#FFF3E0", border_color="#FFB74D"):
        users = Node("Users", icon="aws/general/users", row=0, col=3)
        cdn = Node("CloudFront", icon="aws/network/cloudfront", row=1, col=3)

    with Cluster("Private Subnet", row=2, col=0, width=7, height=3,
                 bg_color="#E8F5E9", border_color="#81C784"):
        lb = Node("ALB", icon="aws/network/elastic-load-balancing", row=2, col=3)
        web1 = Node("Web 1", icon="aws/compute/ec2", row=3, col=1)
        web2 = Node("Web 2", icon="aws/compute/ec2", row=3, col=5)
        db = Node("Aurora", icon="aws/database/aurora", row=4, col=3)

    users >> cdn >> lb
    lb >> [web1, web2]
    web1 >> db
    web2 >> Edge(style="dashed", line_style=LineStyle.ORTHO) >> db

Features

Connection styles

Style Usage Description
Curved a >> b Smooth bezier curves (default)
Straight a >> Edge(line_style=LineStyle.STRAIGHT) >> b Direct lines
Orthogonal a >> Edge(line_style=LineStyle.ORTHO) >> b Right-angle routing
Step a >> Edge(line_style=LineStyle.STEP) >> b Horizontal-then-vertical

Edge customization

a >> Edge(label="HTTPS", color="#2ECC71", style="dashed") >> b

Clusters

with Cluster("VPC", row=0, col=0, width=4, height=3,
             bg_color="#E8F4FD", border_color="#B0C4DE"):
    # nodes inside the cluster
    ...

Icon providers

AWS, GCP, Azure, Kubernetes, on-premises, and 13 more providers -- all from the diagrams package.

Node("Server", icon="aws/compute/ec2", row=0, col=0)
Node("Pod", icon="k8s/compute/pod", row=0, col=1)
Node("Postgres", icon="onprem/database/postgresql", row=0, col=2)

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Serve docs locally
uv run mkdocs serve

License

MIT -- see LICENSE for details.

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

diagrams_for_ai-0.0.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

diagrams_for_ai-0.0.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file diagrams_for_ai-0.0.1.tar.gz.

File metadata

  • Download URL: diagrams_for_ai-0.0.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for diagrams_for_ai-0.0.1.tar.gz
Algorithm Hash digest
SHA256 010ddf621feee3b078f1516dc459454595648aaaae4609a7cb377aca91188a7f
MD5 ebe68868cd14e716e5c178c5814477d6
BLAKE2b-256 8b233f4c1c3f5bc2faf53a6c10cbe4d2eb09627fcb7b7d5671de968d266d782a

See more details on using hashes here.

Provenance

The following attestation bundles were made for diagrams_for_ai-0.0.1.tar.gz:

Publisher: publish.yml on tomascorrea/diagrams-for-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diagrams_for_ai-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for diagrams_for_ai-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7cd6cdc9fe12130e31e3dd18c50772be1f211c4437ee674b90332dd1107f237f
MD5 ddc5f7cff4a53f4a010c85b4bb1c796d
BLAKE2b-256 86161c77fb51433a5cbc05a18009c4ae42339f054bc213ccce572e2d59d40315

See more details on using hashes here.

Provenance

The following attestation bundles were made for diagrams_for_ai-0.0.1-py3-none-any.whl:

Publisher: publish.yml on tomascorrea/diagrams-for-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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