[Awsome Python] Diagrams: Lets you draw the cloud system architecture in Python code

Diagrams

Diagrams lets you draw the cloud system architecture in Python code.

It was born for prototyping a new system architecture without any design tools. You can also describe or visualize the existing system architecture as well.

Diagram as Code allows you to track the architecture diagram changes in any version control system.

Diagrams currently supports six major providers: AWS, Azure, GCP, Kubernetes, Alibaba Cloud and Oracle Cloud. It now also supports On-Premise nodes as well as Programming Languages and Frameworks.

Prerequisites

Python 3.6+ - https://www.python.org/

It requires Python 3.6 or higher, check your Python version first.

Graphviz - https://www.graphviz.org/

It uses Graphviz to render the diagram, so you need to install Graphviz to use diagrams. After installing graphviz (or already have it), install the diagrams.

1
2
3
4
5
# macOS
$ brew install graphviz

# Windows
$ choco install graphviz

Quick Start

1
2
3
4
5
6
7
8
# diagram.py
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

with Diagram("Web Service", show=False):
ELB("lb") >> EC2("web") >> RDS("userdb")

web_service_diagram

It will be saved as web_service.png on your working directory.

Examples

Here are some more examples.

Grouped Workers on AWS

1
2
3
4
5
6
7
8
9
10
11
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

with Diagram("Grouped Workers", show=False, direction="TB"):
ELB("lb") >> [EC2("worker1"),
EC2("worker2"),
EC2("worker3"),
EC2("worker4"),
EC2("worker5")] >> RDS("events")

grouped_workers_diagram

See Examples · Diagrams - https://diagrams.mingrammer.com/docs/getting-started/examples to learn more examples.

References

[1] Diagrams · Diagram as Code - https://diagrams.mingrammer.com/

[2] mingrammer/diagrams: Diagram as Code for prototyping cloud system architectures - https://github.com/mingrammer/diagrams

[3] Welcome to Python.org - https://www.python.org/

[4] Graphviz - https://www.graphviz.org/

[5] Installation · Diagrams - https://diagrams.mingrammer.com/docs/getting-started/installation

[6] Examples · Diagrams - https://diagrams.mingrammer.com/docs/getting-started/examples