コード例 #1
0
ファイル: main.py プロジェクト: rlabrecque/home-network
def main():
    with Diagram("Home Network",
                 show=False,
                 filename="output/home_network",
                 outformat="png"):
        internet = Internet("internet")

        with Cluster("192.168.0.1/24"):
            router = Router("Synology RT2600ac")  # SynologyRouter
            switch = Switch("Netgear R7000")
            raspberrypi = Server("Raspberry Pi 4 8GB")  # raspberrypi
            raspberrypi_docker = Docker("Docker")

            devices = Client("Devices")

            internet >> router
            internet << router

            router >> raspberrypi
            router >> switch

            router >> devices
            switch >> devices

            with Cluster("10.0.0.0/28"):
                service_nginx_proxy = Nginx("nginx-proxy")
                service_grafana = Grafana("Grafana")
                service_pi_hole = DNS("Pi-hole")
                service_portainer = LinuxGeneral("Portainer")
                service_telegraf = LinuxGeneral("Telegraf")
                service_prometheus = Prometheus("Prometheus")
                service_loki = Loki("Loki")
                service_promtail = Loki("Promtail")

                raspberrypi >> raspberrypi_docker

                raspberrypi_docker >> service_nginx_proxy

                service_nginx_proxy >> service_grafana
                service_nginx_proxy >> service_pi_hole
                service_nginx_proxy >> service_portainer
                service_nginx_proxy >> service_telegraf
                service_nginx_proxy >> service_prometheus
                service_nginx_proxy >> service_loki
                service_nginx_proxy >> service_promtail

                service_prometheus >> Edge(label="collect metrics",
                                           color="firebrick",
                                           style="dashed") >> service_telegraf

                service_promtail >> Edge(label="push logs",
                                         color="firebrick",
                                         style="dashed") >> service_loki

                service_grafana >> Edge(label="query",
                                        color="firebrick",
                                        style="dashed") >> service_prometheus
                service_grafana >> Edge(label="query",
                                        color="firebrick",
                                        style="dashed") >> service_loki
コード例 #2
0
def frontend(
    graph_attr: dict = GRAPH_ATTR,
    output_format: str = OUTPUT_FORMAT,
    output_path: str = OUTPUT_PATH,
) -> str:
    """ Generates frontend diagrams """
    output = f"{output_path}/frontend"

    with Diagram(
        "Frontend",
        show=False,
        outformat=output_format,
        # graph_attr=graph_attr,
        filename=output,
    ):

        client = Client("client")

        with Cluster("Serverless"):

            with Cluster("UI"):
                with Cluster("cache"):
                    web_cdn = CloudFront("CDN\nUI")

                with Cluster("static"):
                    web_host = S3("web")
                    react = React("app")

            with Cluster("Static Assets"):
                with Cluster("cache"):
                    assets_cdn = CloudFront("CDN\nassets")
                    assets_apigw = APIGateway("API Gateway")

                assets = S3("assets\nimages")

                with Cluster("media processing"):
                    assets_gen = Lambda("generate image")
                    layers = Layer("layer\nImageMagick")

        web_cdn << react << web_host
        assets_cdn << assets_apigw << assets_gen << layers << assets
        client - Edge(color="orange") << assets_cdn
        client - Edge(color="orange") << web_cdn
        assets_apigw >> assets_gen
        assets_cdn >> assets_apigw

    return f"{output}.{output_format}"
コード例 #3
0
    "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")
コード例 #4
0
            caddy << Edge(color="firebrick") >> nodeJs

        with Cluster("Arduino Project"):
            piCamera = IotCamera("Camera")
            with Cluster("Arduino"):
                arduino = Custom("Pirate-Hook",
                                 "./customImages/720px-Arduino_Logo.png")
                pid = Custom("PID Controller",
                             "./customImages/720px-Arduino_Logo.png")

    # Data from Arduino to Pi
    nodeJs << Edge(label="Pirate Serial", color="firebrick") >> arduino

    Gstreamer << Edge(color="firebrick") << piCamera

    client = Client("User")
    client << Edge(color="firebrick") >> caddy

with Diagram(filename="pirate_overview", show=False, graph_attr=graph_attr):
    with Cluster("Pirate Module"):
        pi = Custom("Raspberry Pi", "./customImages/RPi-Logo-SCREEN.png")

        with Cluster("Arduino Project"):
            piCamera = IotCamera("Camera")
            arduino = Custom("Pirate Hook",
                             "./customImages/720px-Arduino_Logo.png")

    pi << Edge(label="", color="firebrick") << piCamera
    pi << Edge(label="Serial", color="firebrick") >> arduino

    client = Client("User")
コード例 #5
0
        node_2 - instance_2
        node_3 - instance_3
        instance_1 - disk_1
        instance_2 - disk_2
        instance_3 - disk_3
        instance_3 - pv_disk
        pv_workspace - pv_disk
        core - SQL('PostgreSQL')

        core - GCS('Object Storage')
        lb = LoadBalancing('Load Balancer')
        dns = DNS('DNS')
        lb >> ing
        dns >> lb

    [Client('SDKs'), Users('Users')] >> dns

with Diagram('Amazon Web Services resources',
             show=False,
             filename='aws',
             outformat='png'):
    with Cluster('Amazon Web Services'):
        with Cluster('Virtual Private Cloud'):
            kube = EKS('Elastic Kubernetes\nService')
            instance_1 = EC2('EC2 Instance 1\n(m5.xlarge)')
            disk_1 = EBS('EBS Disk 1\n(gp2)')
            instance_2 = EC2('EC2 Instance 2\n(m5.xlarge)')
            disk_2 = EBS('EBS Disk 2\n(gp2)')

            instance_1 - disk_1
            instance_2 - disk_2
コード例 #6
0
ファイル: diagram.py プロジェクト: km45/misc
from diagrams import Diagram, Cluster

from diagrams.aws.database import Dynamodb
from diagrams.azure.database import CosmosDb
from diagrams.onprem.ci import Jenkins
from diagrams.onprem.client import Client, Users
from diagrams.onprem.compute import Server
from diagrams.onprem.database import MongoDB
from diagrams.onprem.network import Nginx
from diagrams.onprem.vcs import Git

with Diagram("trial", show=False, outformat="png"):
    with Cluster("office"):
        git = Git("GitBucket")
        developer = Client("developer")

    with Cluster("on-premises"):
        on_premises_balancer = Server("balancer")
        on_premises_deploy_worker = Jenkins("deploy worker")

        with Cluster("ASP"):
            on_premises_asp_app = Server("application")
            on_premises_asp_db = MongoDB("database")
            on_premises_asp_web_server = Nginx("web server")

    with Cluster("AWS"):
        aws_balancer = Server("balancer")
        aws_jenkins = Jenkins("deploy worker")

        with Cluster("ASP"):
            aws_asp_app = Server("application")
コード例 #7
0
# aws resources
from diagrams.aws.compute import EC2, ECS
from diagrams.aws.storage import S3
from diagrams.aws.general import TradicionalServer, GenericSamlToken
from diagrams.aws.engagement import SimpleEmailServiceSes
from diagrams.aws.network import ElasticLoadBalancing
from diagrams.aws.database import RDS, Elasticache
from diagrams.aws.analytics import ElasticsearchService
from diagrams.aws.storage import EBS

with Diagram("Graph4-simplified", show=True, outformat="png"):
    #STEP1:set up groups and entities
    with Cluster("Internet"):
        with Cluster("Trusted External Parties"):
            tepUser = User("")
            tepDevice = Client("")

    with Cluster("Dept"):
        with Cluster("Department Staff"):
            dsUser = User("")
            dsDevice = Client("")
        with Cluster("Department SAML SSO"):
            tradicionalServer = TradicionalServer("")
            genericSamlToken = GenericSamlToken("")

    with Cluster("AWS Cloud"):
        simpleEmailServiceSes = SimpleEmailServiceSes("Simple Email Service")

        with Cluster("Jira"):
            jELB = ElasticLoadBalancing("Load Balancer")
            jEC2 = EC2("EC2 Instance")
コード例 #8
0
from diagrams import Cluster, Diagram, Edge
from diagrams.custom import Custom
from diagrams.programming.language import JavaScript
from diagrams.onprem.client import Client
from diagrams.aws.iot import IotCamera
from diagrams.programming.language import Go

graph_attr = {"fontsize": "45", "bgcolor": "transparent", "pad": "0.0"}

with Diagram(filename="pirate_spyglass", show=False, graph_attr=graph_attr):

    with Cluster("Experiment"):
        piCamera = IotCamera("PiCamera")
        with Cluster("Raspberry Pi"):
            v4l2 = Custom("PiCamera Driver\n+ V4L2",
                          "./customImages/RPi-Logo-SCREEN.png")
            go = Go("BerryMSE")

    v4l2 << Edge(label="Raw Image", color="firebrick") << piCamera
    go << Edge(label="MPEG-4 Part 10 AVC\nH.264 NAL Units",
               color="firebrick") << v4l2

    with Cluster("Client"):
        website = Client("Website")
        javaScript = JavaScript("MSE")

    javaScript << Edge(label="MPEG-4 Part 15 AVCFF\nH.264 NAL Units",
                       color="firebrick") << go
    website << Edge(label="Video", color="firebrick") << javaScript
コード例 #9
0
from diagrams.aws.compute import ECS
from diagrams.aws.storage import S3
from diagrams.aws.general import TradicionalServer, GenericSamlToken
from diagrams.aws.engagement import SimpleEmailServiceSes
from diagrams.aws.network import ElasticLoadBalancing
from diagrams.aws.database import RDS, Elasticache

with Diagram("Graph2-simplified-test123",
             show=True,
             outformat="png",
             direction="TB"):
    #STEP1:set up groups and entities
    with Cluster("Public"):
        with Cluster("Client"):
            pUser = User("")
            pDevice = Client("")

    with Cluster("Dept"):
        with Cluster("Bio Security Officer"):
            bsoUser = User("")
            bsoDevice = Mobile("")

        with Cluster("Delegated Officer"):
            doUser = User("")
            doDevice = Client("")

        with Cluster("Department SAML SSO"):
            tradicionalServer = TradicionalServer("")
            genericSamlToken = GenericSamlToken("")

    with Cluster("AWS Cloud"):
コード例 #10
0
# diagram.py (https://diagrams.mingrammer.com/)
from diagrams import Diagram
from diagrams.programming.language import Javascript
from diagrams.gcp.compute import GCF
from diagrams.onprem.compute import Server
from diagrams.onprem.client import Client

with Diagram("Google Form to Queue Item", show=False):
    Javascript("Apps Script") >> GCF("Cloud Functions") >> Server(
        "Orcherstrator") >> Client("UiPath Robot")
コード例 #11
0
with Diagram("Graph7", show=True, outformat="png", direction="TB"):

    with Cluster("Azure AD"):
        with Cluster("Mobile App Authentication Domain"):
            genericSamlToken1 = GenericSamlToken("Application Registration")
        with Cluster("Web App Authentication Domain"):
            genericSamlToken2 = GenericSamlToken("Application Registration")

    with Cluster("Airports"):
        aUser = User("Officer")
        aDevice = Mobile("")

    with Cluster("Dept Offices"):
        doUser1 = User("Config Editor")
        doDevice1 = Client("")
        doUser2 = User("Analyst")
        doDevice2 = Client("")

    with Cluster("AWS"):
        with Cluster("Mobile App System Authentication"):
            cognito1 = Cognito("Cognito Userpool")

        with Cluster("Web App System Authentication"):
            cognito2 = Cognito("Cognito Userpool")

        with Cluster("Data Collection"):
            with Cluster("Submission Stage"):
                ssS3 = S3("S3 Bucket")

            with Cluster("Config API - Mobile"):
コード例 #12
0
ファイル: clusfront.py プロジェクト: wearelumenai/clusdoc
from diagrams import Cluster

from diagrams.onprem.client import User, Client

with Cluster('Platform clustering visualization & management'):
    clusfront = Client('clusfront')

    # user = User('user')

    # user >> clusfront
コード例 #13
0
from diagrams import Cluster, Diagram, Edge
from diagrams.onprem.client import Client, User

# aws resources
from diagrams.aws.compute import Lambda
from diagrams.aws.network import CloudFront
from diagrams.aws.mobile import APIGateway
from diagrams.aws.storage import S3

with Diagram("Graph1", show=True, outformat="png"):

    with Cluster("Public"):
        with Cluster("Public"):
            user = User("")
            device = Client("")

    with Cluster("AWS Cloud"):
        with Cluster("Web App"):
            cloudFrontD = CloudFront("CloudFront Distribution")
            lambda1 = Lambda("Lambda Function")
            s3 = S3("S3 Bucket")

        with Cluster("Processing API"):
            api = APIGateway("API Gateway")
            lambda2 = Lambda("Lambda Function")

    #format within Public section
    user - Edge(color="transparent") - device
    #connect within Web App section
    cloudFrontD >> Edge(
        style="dashed",
コード例 #14
0
from diagrams.onprem.client import Client
from diagrams.onprem.container import Docker
from diagrams.generic.database import SQL

NUM_CLIENTS = 3
NUM_SECURE_SERVICES = 2

with Diagram("JWThenticator Direct Validation Example Architecture"):

    with Cluster("Service Runtime"):
        ingress = Ingress("ingress")
        services = []

        jwthenticator = Docker("jwthenticator")
        jwthenticator_db = SQL("jwthenticator-db")

        with Cluster("Secured Endpoints"):
            for i in range(NUM_SECURE_SERVICES):
                services.append(Docker(f"service-{i}"))

    # General initial flow
    for i in range(NUM_CLIENTS):
        Client(f"client-{i}") >> ingress  # pylint: disable=expression-not-assigned

    for i in range(NUM_SECURE_SERVICES):
        ingress >> services[i] >> jwthenticator

    # JWThenticator service
    ingress >> jwthenticator
    jwthenticator - jwthenticator_db
コード例 #15
0
ファイル: diagrams02.py プロジェクト: xyz2900/awstest
from diagrams.onprem.client import Client
from diagrams.aws.storage import S3

graph_attr = {'bgcolor': 'gray', 'fontsize': '28'}

node_attr = {'fontsize': '14'}

edge_attr = {'arrowsize': '2.0', 'penwidth': '5.0'}

with Diagram(name='イベントストリーミング2',
             filename='event_streaming',
             show=True,
             direction='TB',
             graph_attr=graph_attr,
             edge_attr=edge_attr,
             node_attr=node_attr):

    # インスタンス化によってノードを作成
    # ノードにラベルを付与でき、\nを入れることでラベルの改行も可能
    stream = KinesisDataStreams('Kinesis\nData Streams')
    s3 = S3('S3')
    athena = Athena('Athena')

    # 定義したノードを始点とした流れを作成
    # 変数に代入せずとも、ノードは作成可能
    Client() >> stream >> Lambda('Lambda') >> Personalize(
        'Personalize\nEventTracker')
    stream >> KinesisDataFirehose('Kinesis\nData Firehose') >> s3
    s3 - athena >> Quicksight('QuickSight') << Client()
    s3 >> Glue('Glue') >> athena
コード例 #16
0
from diagrams.aws.security import IdentityAndAccessManagementIam
from diagrams.aws.devtools import Codebuild
from diagrams.aws.devtools import Codecommit
from diagrams.aws.devtools import Codedeploy
from diagrams.aws.devtools import Codepipeline
from diagrams.aws.management import Cloudformation
from diagrams.aws.devtools import CommandLineInterface
from diagrams.aws.general import User
from diagrams.aws.general import General
from diagrams.onprem.client import Client

with Diagram("Serverless Web Apps", show=False, direction="TB"):

    with Cluster("Launch API URL"):
        user = User("User")
        console = Client("Browser")
        user >> console

    with Cluster("Cloud9", direction="LR"):
        builder = User("Builder")
        cli = CommandLineInterface("AWS CLI")
        builder >> cli

    with Cluster("CloudFormation"):
        cloudformation = Cloudformation("Stack")
        cloudformation >> IdentityAndAccessManagementIam("IAM")
        cloudformation >> Codecommit("CodeCommit")
        cloudformation >> Codebuild("CodeBuild")
        cloudformation >> Codepipeline("CodePipeline")
        cloudformation >> S3("S3")
        cli >> cloudformation
        firewall = WAF("AWS WAF")
        identity = IAM("AWS IAM")

        with Cluster("CDN"):
            cdn = S3("S3") >> CF("CloudFront CDN")

        with Cluster("Functions") as xyz:
            func_send_mail = Lambda("Send Email")
            func_store_data = Lambda("Store Data")
            functions = [func_send_mail, func_store_data]
            gateway >> Edge() << functions

        functions >> Edge() << identity

        func_send_mail >> Edge() >> email_service >> users
        func_store_data - Edge() - db
        cdn >> Edge() << route

        # Monitoring
        log_connection = Edge(color="darkpink", style="dotted")
        monitoring >> log_connection << gateway
        monitoring >> log_connection << [func_send_mail, func_store_data]
        monitoring >> log_connection << firewall

        firewall >> Edge() << cdn >> Edge() << gateway
        security >> Edge() << gateway

    Client() - \
        Internet("www.yoursite.com") >> \
        Edge(color="darkgreen", style="dotted") << \
        route >> Edge() << gateway
コード例 #18
0
            client_registry = Docker("client-registry")

        with Cluster("Unrestricted Endpoints"):
            jwthenticator_external = Docker("external-jwthenticator")

        with Cluster("Internal Services"):
            jwthenticator_internal = Docker("internal-jwthenticator")

        with Cluster("Services Dependencies"):
            jwthenticator_db = SQL("jwthenticator-db")
            services_deps = []
            for i in range(NUM_SQL_SERVICES):
                services_deps.append(SQL(f"service-{i}-db"))
            for i in range(NUM_STORAGE_SERVICES + 1,
                           NUM_STORAGE_SERVICES + NUM_SQL_SERVICES):
                services_deps.append(Storage(f"service-{i}-storage"))

    # Connect clients to api_gateway
    for i in range(NUM_CLIENTS):
        Client(f"client-{i}") >> api_gateway  # pylint: disable=expression-not-assigned

    # Create internal services flow
    for i in range(NUM_SQL_SERVICES + NUM_STORAGE_SERVICES):
        api_gateway >> services[i] >> services_deps[i]

    # Client registry service
    api_gateway >> client_registry >> jwthenticator_internal >> jwthenticator_db

    # JWThenticator service
    api_gateway >> jwthenticator_external << jwthenticator_db
コード例 #19
0
from diagrams import Diagram, Cluster
from diagrams.gcp.compute import Run
from diagrams.gcp.devtools import Build, GCR, SourceRepositories as GSR
from diagrams.gcp.database import SQL
from diagrams.onprem.vcs import Github
from diagrams.onprem.client import Client, User

with Diagram("Architecture", show=False):
    with Cluster("Apps"):
        with Cluster("CI/CD"):
            dev = GSR("source mirror")
            cicd = dev >> Build("build") >> GCR("container deploy")

        with Cluster("Services"):
            app = Run("Rails + React App")
            cicd >> app >> SQL("database")

    User("developer") >> Github("code push") >> dev
    Client("client") >> app
コード例 #20
0
                    db_pod = Pod("DB Pod")
                    db_pvc = PersistentVolumeClaim("DB PVC")
                    db_pv = PersistentVolume("DB PV")
                    # Relationships
                    sc << db_pv << db_pvc << db_pod >> db_sset
                    db_pods.append(db_pod << db_svc)

        # Relationships
        app_pods << app_svc_int << app_lb_int << app_fw
        # app_pods >> pgpool_svc  # Not rendered since the diagram is busy enough

with Diagram("TRM Exercise Overview", show=False):
    # General overview of system flow

    # Resources
    external_client = Client("external client")
    vpc_client = Client("vpc client")
    app_svc_ext = Service("App Service (external)")
    app_svc_int = Service("App Service (internal)")
    app_lb_ext = LoadBalancing("App LB (HTTP/external)")
    app_lb_int = LoadBalancing("App LB (TCP/internal)")
    app_ingress_ext = Ingress("App Ingress (external)")
    app_fw = FirewallRules("Firewall")
    app_pod = Pod("App Pods")
    pgpool_svc = Service("Pgpool Service")
    pgpool_pod = Pod("Pgpool Pod")
    db_svc = Service("DB Service")
    db_pod = Pod("DB Pods")

    # Relationships
    external_client >> app_fw >> app_ingress_ext >> app_lb_ext >> app_svc_ext >> app_pod