spinagram

Introduction

Diagrams as code, delivered editable everywhere.

spinagram turns a few lines of Python into architecture diagrams you can keep editing: SVG, PNG, PowerPoint slides with native shapes, and Figma or FigJam nodes. Say what is connected to what; spinagram sizes, places and styles everything.

One source: Python or YAML, rendered by spinagram to SVG, PNG, PowerPoint and Figma

A diagram in Python

examples/quickstart.py
"""Automatic layout: no coordinates. Run `python examples/quickstart.py`, or
`spinagram render examples/quickstart.py -f svg,png,pptx -o out/`."""
from spinagram import Diagram

d = Diagram("Q01", "Web app on AWS", subtitle="No coordinates, laid out automatically")

users = d.box("Users", icon="aws:users")
with d.group("us-east-1", style="aws-region", direction="right"):
    with d.group("VPC", style="aws-vpc", direction="right"):
        lb = d.box("Load balancer", icon="aws:alb")
        api = d.box("API", text="FastAPI on ECS", icon="terrastruct:python")
        with d.group():  # no style: a light "soft" zone
            db = d.box("Orders DB", text="PostgreSQL", icon="terrastruct:postgres")
            cache = d.box("Cache", text="Redis", icon="terrastruct:redis")
    s3 = d.box("Uploads", text="S3 bucket", icon="aws:s3")

users.to(lb, "HTTPS") >> api
api.to(db, "SQL")
api >> [cache, s3]

diagram = d  # lets `spinagram render` and `spinagram serve` pick it up

if __name__ == "__main__":
    d.save("out/", formats=["svg", "png", "pptx"])
python examples/quickstart.py

Web app on AWS, laid out automatically

No coordinates, no sizes: boxes grow to fit their text and icon, groups wrap their children and a >> b draws an arrow. Prefer a data file? The same diagram in YAML renders identically.

Why spinagram

  • Editable output, not screenshots. PowerPoint gets native shapes with the text inside and connectors bound to the boxes: move a box and the arrows follow. Figma gets real frames and nodes.
  • Python that reads like the picture. users >> lb >> api, with d.group("VPC"):, lists fan out. It is plain Python, so loops, functions and imports build big diagrams from small parts.
  • Automatic layout. Four engines (flex, dot, elk, d2), nested groups such as an AWS Region, a VPC and its zones, and a way to freeze the result for hand-tuning.
  • Brand once, render anywhere. A theme directory holds colours, fonts, styles, icons and chrome.
  • Thousands of icons. AWS, GCP, Azure, Kubernetes, OCI, OpenStack and Terrastruct packs download on first use.
  • Built for reviews. spinagram check catches text overflow, spinagram serve previews live, and numbers can come from a facts file with their provenance in every render.

On this page