def linking_nodes_diagram(): from diagrams import Diagram, Cluster from diagrams.aws.compute import EC2 from diagrams.aws.network import ELB from diagrams.aws.network import Route53 from diagrams.onprem.database import PostgreSQL # Would typically use RDS from aws.database from diagrams.onprem.inmemory import Redis # Would typically use ElastiCache from aws.database with Diagram( "Simple Website Diagram", direction='LR' ) as diag4: # It's LR by default, but you have a few options with the orientation dns = Route53("DNS") load_balancer = ELB("Load Balancer") database = PostgreSQL("User Database") cache = Redis("Cache") with Cluster("Webserver Cluster"): svc_group = [ EC2("Webserver 1"), EC2("Webserver 2"), EC2("Webserver 3") ] dns >> load_balancer >> svc_group svc_group >> cache svc_group >> database print( diag4 ) # This will illustrate the diagram if you are using a Google Colab or Jypiter notebook.
def nodes_diagram(): with Diagram("Simple Website Diagram") as diag2: dns = Route53("dns") load_balancer = ELB("Load Balancer") database = PostgreSQL("User Database") cache = Redis("Cache") svc_group = [ EC2("Webserver 1"), EC2("Webserver 2"), EC2("Webserver 3") ] print( diag2 ) # This will illustrate the diagram if you are using a Google Colab or Jypiter notebook.
def linking_nodes_diagram(): with Diagram( "Simple Website Diagram", direction='LR' ) as diag4: # It's LR by default, but you have a few options with the orientation dns = Route53("DNS") load_balancer = ELB("Load Balancer") database = PostgreSQL("User Database") cache = Redis("Cache") with Cluster("Webserver Cluster"): svc_group = [ EC2("Webserver 1"), EC2("Webserver 2"), EC2("Webserver 3") ] dns >> load_balancer >> svc_group svc_group >> cache svc_group >> database print( diag4 ) # This will illustrate the diagram if you are using a Google Colab or Jypiter notebook.
def nodes_diagram(): from diagrams import Diagram, Cluster from diagrams.aws.compute import EC2 from diagrams.aws.network import ELB from diagrams.aws.network import Route53 from diagrams.onprem.database import PostgreSQL # Would typically use RDS from aws.database from diagrams.onprem.inmemory import Redis # Would typically use ElastiCache from aws.database with Diagram("Simple Website Diagram") as diag2: dns = Route53("dns") load_balancer = ELB("Load Balancer") database = PostgreSQL("User Database") cache = Redis("Cache") svc_group = [ EC2("Webserver 1"), EC2("Webserver 2"), EC2("Webserver 3") ] print( diag2 ) # This will illustrate the diagram if you are using a Google Colab or Jypiter notebook.
if len(sys.argv) > 1: file = str(sys.argv[1]) else: file = "diagram" with Diagram("Advanced Web Service with On-Premise", filename=file, show=False): ingress = Nginx("ingress") metrics = Prometheus("metric") metrics << Grafana("monitoring") with Cluster("Service Cluster"): grpcsvc = [Server("grpc1"), Server("grpc2"), Server("grpc3")] with Cluster("Sessions HA"): master = Redis("session") master - Redis("replica") << metrics grpcsvc >> master with Cluster("Database HA"): master = PostgreSQL("users") master - PostgreSQL("slave") << metrics grpcsvc >> master aggregator = Fluentd("logging") aggregator >> Kafka("stream") >> Spark("analytics") ingress >> grpcsvc >> aggregator
"fontsize": "20", "bgcolor": "white" #transparent } with Diagram("Application Architecture", graph_attr=graph_attr, outformat="png", filename="application_architecture"): ELB("lb") >> EC2("web") >> RDS("userdb") >> S3("store") ELB("lb") >> EC2("web") >> RDS("userdb") << EC2("stat") (ELB("lb") >> EC2("web")) - EC2("web") >> RDS("userdb") with Cluster("Application Context"): app = EC2("Spring Boot") ELB("lb") >> app metrics = Prometheus("metric") metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring") Jenkins("CI") client = Client("A") client >> User("B") >> Users("S") client >> PostgreSQL("Database") client >> Internet("Remote API") client >> Docker("Docker") client >> Server("Server") client >> SQS("Sync Books") client >> Spring("Backend") client >> React("React")
prometheus = Prometheus("Prometheus") grafana = Grafana("Grafana") prometheus >> service1 prometheus >> service2 grafana >> prometheus support >> grafana with Cluster("Streams"): kafka = Kafka("Kafka") ibmmq = Ibmmq("MQ") with Cluster("Databases"): cassandra = Cassandra("NoSQL DB\n(Cassandra)") database = PostgreSQL("SQL DB\n(Postgres)") redis = Redis("Cache\n(Redis)") with Cluster("Other services"): service3 = EC2("") service4 = EC2("") service5 = EC2("") service6 = EC2("") with Cluster("SSO Infrastructure"): sso = EC2("SSO") user >> internet internet >> load_balancer
from diagrams.onprem.queue import Kafka from diagrams.onprem.compute import Server from diagrams.onprem.database import PostgreSQL from diagrams import Cluster, Diagram, Edge with Diagram("Monitoring pipeline", show=False): with Cluster("Monitoring Agents"): agents = [ Server("Agent1"), Server("Agent2"), Server("Agent3") ] with Cluster("Targets"): targets = [ Server("Target1") << Edge(color="darkgreen", label="probe") << agents[0], Server("Target2") << Edge(color="darkred", label="probe") << agents[1], Server("Target3") << Edge(color="darkgreen", label="probe") << agents[2] ] with Cluster("agent-probe-results.v1.json"): topic = Kafka("") agents >> Edge(label="push", reverse=False, forward=True) >> topic with Cluster("Results processor"): processor = Server("Results processor") processor << Edge(label="consume") << topic database = PostgreSQL("database.probe_results") processor >> database
from diagrams import Diagram from diagrams import Cluster, Diagram from diagrams.aws.network import ELB from diagrams.aws.compute import ECS from diagrams.onprem.database import PostgreSQL from diagrams.aws.database import Aurora with Diagram("DIAGRAMA : ARQUITECTURA HORIZONTAL", show=False): lb = ELB("API/CONETENEDOR C") with Cluster("Database "): master = PostgreSQL("CONTENEDOR A") data = Aurora("DATABASE") lb >> master >> data with Cluster("Service"): svc_pgadmin = ECS("PGADMIN/CONTENEDOR B") data >> svc_pgadmin with Cluster("Services"): svc_flask = ECS("FLASK/CONTENEDOR D") svc_redis = ECS("REDIS/CONTENEDOR E") master >> svc_flask master >> svc_redis
direction=direction, show=False): ingress = Nginx("ingress") metrics = Prometheus("metric") metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring") with Cluster("Service Cluster"): grpcsvc = [Server("grpc1"), Server("grpc2"), Server("grpc3")] with Cluster("Sessions HA"): primary = Redis("session") primary - Edge(color="brown", style="dashed") - Redis("replica") << Edge( label="collect") << metrics grpcsvc >> Edge(color="brown") >> primary with Cluster("Database HA"): primary = PostgreSQL("users") primary - Edge(color="brown", style="dotted") - PostgreSQL("replica") << Edge( label="collect") << metrics grpcsvc >> Edge(color="black") >> primary aggregator = Fluentd("logging") aggregator >> Edge(label="parse") >> Kafka("stream") >> Edge( color="black", style="bold") >> Spark("analytics") ingress >> Edge(color="darkgreen") << grpcsvc >> Edge( color="darkorange") >> aggregator
#!/usr/bin/env python from diagrams import Diagram from diagrams.onprem.database import PostgreSQL from diagrams.onprem.database import MongoDB from diagrams.onprem.compute import Server from diagrams.custom import Custom with Diagram("Sample Bank Architecture", show=False): maps = Custom("Google Maps API", "./maps.png") dns = Server("DNS") front = Custom("Frontend", "./react.png") am = Custom("Account Manager", "./node.png") ps = Custom("Plan Simulator", "./node.png") bf = Custom("Branch Finder", "./ts.png") db1 = PostgreSQL("PostgreSQL") db2 = PostgreSQL("PostgreSQL") db3 = MongoDB("MongoDB") dns >> front >> am front >> ps front >> bf am >> db1 ps >> db2 bf >> db3 bf >> maps
def ArchitectureDiagrams(prod_short, project_context, orch_name): script_path = os.path.dirname(os.path.realpath(__file__)) file_path = script_path + \ '/../modules/administration-guide/images/architecture/' + project_context + '-' prod_icon = script_path + '/' + project_context + '-icon.png' graph_attr = { "bgcolor": "white", "layout": "dot", "overlap": "false", # "splines": "curved" } filename = file_path + 'architecture-with-che-server-engine' with Diagram(filename=filename, show=False, direction="TB", outformat="png", edge_attr={"constraint": "false"}, graph_attr=graph_attr): devfile = Git('Devfile v1') dashboard = Custom('User dashboard', prod_icon) che_host = Custom(prod_short + ' server', prod_icon) with Cluster(orch_name + ' API'): workspace = Compute('User workspace') devfile >> dashboard >> che_host >> workspace filename = file_path + 'interacting-with-devworkspace' with Diagram(filename=filename, show=False, direction="LR", outformat="png", graph_attr=graph_attr): devfile = Git('Devfile v2') dashboard = Custom('User dashboard', prod_icon) with Cluster(orch_name + ' API'): devworkspace_operator = Compute('DevWorkspace') workspace = Compute('User workspace') devfile >> dashboard >> devworkspace_operator >> workspace filename = file_path + 'deployments-interacting-with-devworkspace' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): che_dashboard = Custom('User dashboard', icon_path=prod_icon) che_gateway = Traefik('Gateway') devfile_registries = SimpleStorageService('Devfile registries') che_host = Custom(prod_short + ' server', icon_path=prod_icon) git = Git('Git provider') postgres = PostgreSQL('PostgreSQL') plugin_registry = SimpleStorageService('Plug-in registry') kubernetes_api = APIServer(orch_name + ' API') user = User('User browser') user >> che_gateway che_gateway >> [ che_dashboard, devfile_registries, che_host, plugin_registry, kubernetes_api ] che_host >> [postgres, git] filename = file_path + 'gateway-interactions' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): user = User('User') che_gateway = Traefik('Gateway') che_dashboard = Custom('User dashboard', icon_path=prod_icon) devfile_registries = SimpleStorageService('Devfile registry') che_host = Custom(prod_short + ' server', icon_path=prod_icon) plugin_registry = SimpleStorageService('Plug-in registry') user_workspace = Compute('User workspaces') user >> che_gateway >> [ che_dashboard, che_host, devfile_registries, plugin_registry, user_workspace ] filename = file_path + 'dashboard-interactions' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): che_dashboard = Custom('User dashboard', icon_path=prod_icon) devfile_registry = SimpleStorageService('Devfile registries') che_host = Custom(prod_short + ' server', icon_path=prod_icon) plugin_registry = SimpleStorageService('Plug-in registry') crd_workspace = APIServer(orch_name + ' API') che_dashboard >> che_host, che_dashboard >> [devfile_registry, plugin_registry] che_dashboard >> crd_workspace filename = file_path + 'server-interactions' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): che_host = Custom(prod_short + ' server', icon_path=prod_icon) postgres = PostgreSQL('PostgreSQL') git_provider = Git('Git provider') crd_workspace = APIServer('API') che_dashboard = Custom('User dashboard', icon_path=prod_icon) che_dashboard >> che_host che_host >> [git_provider] che_host >> crd_workspace che_host >> postgres filename = file_path + 'postgresql-interactions' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): che_host = Custom(prod_short + ' server', icon_path=prod_icon) postgres = PostgreSQL('PostgreSQL') che_host >> postgres filename = file_path + 'devfile-registry-interactions' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): che_dashboard = Custom('User dashboard', icon_path=prod_icon) devfile_registry = SimpleStorageService('Devfile registries') che_dashboard >> devfile_registry filename = file_path + 'plugin-registry-interactions' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): che_dashboard = Custom('User dashboard', icon_path=prod_icon) plugin_registry = SimpleStorageService('Plug-in registry') che_dashboard >> plugin_registry filename = file_path + 'user-workspaces-interactions' with Diagram(filename=filename, show=False, direction="TB", outformat="png", graph_attr=graph_attr): che_gateway = Traefik('Gateway') git = Git('Git provider') container_registries = SimpleStorageService('Container registries') artifact_management = SimpleStorageService('Dependency provider') user = User('User') user_workspace = Compute('User workspaces') user >> che_gateway >> user_workspace user_workspace >> [git, container_registries, artifact_management]
ui = React("UI") with Cluster("Kube"): net = Istio("loremipsum.com") with Cluster('Logging'): logging = Fluentd('logging') es = ElasticSearch('index') kibana = Kibana('Log View') logging >> es >> kibana with Cluster('Monitoring'): metrics = Prometheus('metrics') monitoring = Grafana('monitoring') tracing = Jaeger('tracing') with Cluster("DB") as cluster: db_books = PostgreSQL("books") db_auth = PostgreSQL("auth") # pvc = PVC("pvc") # pvc << [db_books, db_auth] with Cluster('Lorem Ipsum Apps'): books_svc = Service('books') apps = [] for _ in range(2): pod = Pod("pod") apps.append(books_svc >> pod >> [db_books, metrics, logging]) auth_svc = Service('auth') apps = [] for _ in range(2): pod = Pod("pod") apps.append(auth_svc >> pod >> [db_auth, metrics, logging]) search_engine = Service("Search Engine")
from diagrams.onprem.database import PostgreSQL graph_attr = {"bgcolor": "transparent"} with Diagram("Basic Architecture", outformat="png", graph_attr=graph_attr): with Cluster("Docker Swarm"): host = [Server("Cloud Host")] with Cluster("Frontend"): frontend = Vue("Nuxt + Vuetify") host << frontend with Cluster("Search Engine"): search = Rust("MeiliSearch") frontend << search with Cluster("API"): api = Python("FastAPI") search >> api api >> search with Cluster("Database"): db = PostgreSQL("Recipes") api >> db db >> api with Cluster("Web Scraper"): scraper = Python("Scrapy") scraper >> api
from diagrams.onprem.database import Postgresql as PostgreSQL from diagrams.onprem.network import Zookeeper from diagrams.onprem.queue import Kafka cluster_attr = { "bgcolor": "transparent", "pencolor" : "white", } with DaC("mysql postgres dblog zookeeper kafka ", filename= "./diagram-adhocBT", show=True, direction="BT"): with Cluster(" ", graph_attr=cluster_attr): with Cluster("mysql service"): mysql = MySQL("mysql") with Cluster("postgres service"): postgres = PostgreSQL("postgres") vol_mysql = Volume("db-data") vol_mysql >> Edge(color="darkgreen", style="dashed") << mysql vol_postgres = Volume("db-data") vol_postgres >> Edge(color="darkgreen", style="dashed") << postgres with Cluster("dblog service"): dblog = Server("dblog") with Cluster(" ", graph_attr=cluster_attr): with Cluster("zookeeper service"): zookeeper = Zookeeper("zookeeper") with Cluster("kafka service"): kafka = Kafka("kafka")
from diagrams import Diagram from diagrams.onprem.client import Users from diagrams.onprem.database import PostgreSQL from diagrams.programming.framework import Spring graph_attr = { "fontsize": "20", "bgcolor": "white" # transparent } with Diagram("", direction="LR", graph_attr=graph_attr, outformat="png", filename="architecture"): users = Users("Users") backend = Spring("Application") database = PostgreSQL("PostgreSQL database") backend >> database users >> backend
with Diagram(name="Advanced Web Service with On-Premise (colored)", show=False): ingress = Nginx("ingress") metrics = Prometheus("metric") metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring") with Cluster("Service Cluster"): grpcsvc = [Server("grpc1"), Server("grpc2"), Server("grpc3")] with Cluster("Sessions HA"): master = Redis("session") master - Edge(color="brown", style="dashed") - Redis("replica") << Edge( label="collect") << metrics grpcsvc >> Edge(color="brown") >> master with Cluster("Database HA"): master = PostgreSQL("users") master - Edge(color="brown", style="dotted") - PostgreSQL("slave") << Edge( label="collect") << metrics grpcsvc >> Edge(color="black") >> master aggregator = Fluentd("logging") aggregator >> Edge(label="parse") >> Kafka("stream") >> Edge( color="black", style="bold") >> Spark("analytics") ingress >> Edge(color="darkgreen") << grpcsvc >> Edge( color="darkorange") >> aggregator
from diagrams.onprem.inmemory import Redis from diagrams.programming.language import NodeJS filename = "architecture-cloud-gov" with Diagram("Site Scanner", show=False, filename=filename): with Cluster("API"): api_data_gov = Firewall("api.data.gov") # not really a firewall router = Switch("Cloud.gov router") with Cluster("API Logic"): node_api_app = NodeJS("API Logic") with Cluster("Data and Storage"): postgres = PostgreSQL("AWS-RDS PG") with Cluster("Node Cold Storage"): cold_storage_node = NodeJS("Cold Storage Code") s3_cold_storage = S3("S3 (Cold Storage)") with Cluster("Scanning"): with Cluster("Configurable CRON jobs"): cron = [NodeJS("Nightly CRON job"), NodeJS("Weekly CRON job")] with Cluster("Producer Logic"): producer_node = NodeJS("producer code") with Cluster("Message Queues"): queue = Redis("Headless Queue")
workstation = Ansible("homelab.git") with Cluster("Service Node"): ingress = Traefik("ingress") middleware = [Firewall("OAuth middlware")] ingress >> Edge(style="dashed") >> middleware ( ingress >> Edge(color="green") >> [ Server("adguard"), Server("espial"), Server("miniflux"), PostgreSQL("miniflux_db"), Server("firefly"), PostgreSQL("firefly_db"), Server("healthchecks"), Server("n8n"), PostgreSQL("n8n_db"), Prometheus("prometheus"), Grafana("grafana"), Firewall("oauth"), ] ) with Cluster("Media Node"): media_services = [ Server("plex"), Server("ombi"),
_icon = "MuPDF.png" class Peewee(Custom): _icon = "peewee.png" from diagrams import Cluster, Diagram from diagrams.aws.compute import ECS from diagrams.aws.integration import SQS from diagrams.elastic.elasticsearch import Elasticsearch from diagrams.onprem.database import PostgreSQL from diagrams.onprem.network import Nginx with Diagram("Web Service", show=True): with Cluster("Processing"): workers = [ECS("worker1"), ECS("worker2")] with Cluster("Extraction"): with Cluster("PDF"): pdf = Camelot("Table") - MuPDF("Text") with Cluster("database"): orm = Peewee("ORM") postgres = PostgreSQL("storage") queue = SQS("event queue") server = Flask() Nginx("Nginx") >> server >> queue >> workers >> pdf pdf >> orm >> postgres
"Step 1 - Webapp and Database", "Step 2 - Scaling Messages", "Step 3 - Searching Messages", "Step 4 -Client-side Caching", "Step 5 - Logging and Metrics" ] with Diagram(show=False) as d: # Step 1 with d, Diagram(show=True, filename=files[0]): with Cluster("Web"): web_clients = [React("Client 1"), React("Client 2")] with Cluster("API and Database"): with Cluster("Heroku"): hasura = Server("GraphQL") with Cluster("Aiven"): pg = PostgreSQL("DB") web_clients << Edge(color="green") >> hasura >> Edge( color="green") << pg # Step 2 with Diagram(show=True, filename=files[1]): with Cluster("Web"): web_clients = [React("Client 1"), React("Client 2")] with Cluster("API and Database"): with Cluster("Heroku"): hasura = Server("GraphQL") with Cluster("Aiven"): pg = PostgreSQL("DB") web_clients << Edge(color="green") >> hasura >> Edge( color="green") << pg
from diagrams.onprem.database import PostgreSQL from diagrams.onprem.network import Internet from diagrams.programming.framework import Spring, React graph_attr = { "fontsize": "20", "bgcolor": "white" # transparent } with Diagram("", direction="LR", graph_attr=graph_attr, outformat="png", filename="book-reviewr-application-architecture"): with Cluster("Book Reviewr"): frontend = React("Frontend") backend = Spring("Backend") queue = SQS("SQS (Messaging Queue)") users = Users("Users") database = PostgreSQL("PostgreSQL (Database)") keycloak = Server("Keycloak (Identity Provider)") api = Internet("Open Library (REST API)") keycloak << [frontend, backend] users >> frontend frontend >> backend >> database backend >> api backend << queue
from diagrams import Cluster, Diagram, Edge from diagrams.onprem.database import PostgreSQL from diagrams.programming.language import Java graph_attr = { "fontsize": "20", "bgcolor": "white" # transparent } with Diagram("", direction="LR", graph_attr=graph_attr, outformat="png", filename="test-basic-setup"): database = PostgreSQL("Database") collaborator = Java("UserRepository") fake_collaborator = Java("FakeUserRepository") with Cluster("Class Under Test (CUT) "): cut = Java("RegistrationService") database << collaborator collaborator << Edge(color="red", style="dotted") << cut fake_collaborator << cut
from diagrams.onprem.logging import Fluentd from diagrams.onprem.monitoring import Grafana, Prometheus from diagrams.onprem.network import Nginx from diagrams.onprem.queue import Kafka with Diagram(name="Advanced Web Service with On-Premise (colored)", show=False): ingress = Nginx("ingress") metrics = Prometheus("metric") metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring") with Cluster("Service Cluster"): grpcsvc = [ Server("grpc1"), Server("grpc2"), Server("grpc3")] with Cluster("Sessions HA"): master = Redis("session") master - Edge(color="brown", style="dashed") - Redis("replica") << Edge(label="collect") << metrics grpcsvc >> Edge(color="brown") >> master with Cluster("Database HA"): master = PostgreSQL("users") master - Edge(color="brown", style="dotted") - PostgreSQL("slave") << Edge(label="collect") << metrics grpcsvc >> Edge(color="black") >> master aggregator = Fluentd("logging") aggregator >> Edge(label="parse") >> Kafka("stream") >> Edge(color="black", style="bold") >> Spark("analytics") ingress >> Edge(color="darkgreen") << grpcsvc >> Edge(color="darkorange") >> aggregator
from diagrams import Diagram, Edge from diagrams.onprem.database import PostgreSQL from diagrams.onprem.queue import Kafka from diagrams.onprem.container import Docker with Diagram("Monitoring Application", show=False): Docker("Monitoring service") >> Edge(color="black", style="bold") >> Kafka( "stream" ) >> Edge(color="black", style="bold") >> Docker("Consumer service") >> Edge( color="black", style="bold" ) >> PostgreSQL( "storage" )
# docker = Docker("Docker") admin = User("Admin User") with Cluster("End Users"): users = Users("End Users") with Cluster("AWS"): with Cluster("VPC"): routetable = network.RouteTable("Route Tables") firewall = network.VPC("VPC Firewall Rules") with Cluster("Public Subnets") as public1: rs1 = database.Redshift("Redshift\nCluster") postgres = PostgreSQL("Postgres\n(RDS)") mySQL = MySQL("MySQL\n(RDS)") airflow = Airflow("Airflow Server\n(ECS Fargate)") # with Cluster("Public Subnet (2)") as pub2: nat = network.NATGateway("NAT\nGateway") # rs2 = database.Redshift("Redshift\n(node 2)") elb = network.ELB("Elastic Load\nBalancer") with Cluster("Private Subnets") as priv1: Blank("") singer1 = Singer("Singer.io\nExtract/Loads\n(ECS Fargate)") Blank("") Blank("") Blank("") # with Cluster("Private Subnet (2)") as priv2: tableau = Tableau("Tableau Server\n(EC2)")