Examples
Cloud architecture
AWS, Google Cloud and Kubernetes diagrams whose zones nest themselves.
Use it for: design reviews, onboarding docs, the "how it works" slide.
- Start with the systems and the arrows between them. Leave out the groups.
- Add icons:
icon="aws:s3",icon="gcp:cloud-run",icon="k8s:pod"(finding icons). - Wrap boxes in
with d.group(...)blocks, from the outside in: account, region, VPC, zone, subnet. - Number the request path with
step=and addd.add_legend().
Start small
"""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]
if __name__ == "__main__":
d.save("out/", formats=["svg", "png", "pptx"])
Three tiers across two zones
Subnets per tier in two Availability Zones, built with plain Python loops, with numbered steps and a legend.
aws_three_tier.py
Hub-and-spoke networking
A Transit Gateway hub with centralized inspection and egress, and hybrid connectivity.
aws_network_hub.py
Google Cloud
Anycast load balancing, GKE in two regions, Spanner and streaming analytics.
gcp_global_app.py
Kubernetes
A dark cluster canvas built only with CSS:
k8s_platform.py +
k8s.css.
Anatomy of a workload
Ingress to pods, autoscaling, config and stateful storage.
Service networking
Ingress to Service to pods, guarded by NetworkPolicy.
More: Python guide · Automatic layout · Annotations