Aller au contenu

Diagrams

Quelques notes pour la prise en main de Diagrams (diagrams.mingrammer.com) qui s'appuie sur Graphviz pour générer des schémas d'architecture.

Installation

sudo apt install graphviz
pip install --user diagrams

Usage

Conversion d'un fichier

Il suffit d'appeler python helloworld.py pour générer le schéma :

# helloworld.py
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

graph_attr = {
    "margin":"-1.8, -1.8"
}

with Diagram("Simple", filename="helloworld", graph_attr=graph_attr, show=False):
    ELB("lb") >> EC2("web") >> RDS("userdb")

=>

helloworld.png

Conversion des fichiers dans un dossier

Le bon vieux Makefile suivant fait l'affaire :

SRC=$(wildcard *.py)

.PHONY: build
build: $(SRC)
 python $^

Ressources