Skip to content

structurizr dsl code

Italo Pessoa edited this page May 9, 2024 · 1 revision
!const ORGANISATION_NAME "Byte Me Burger"
!const GROUP_NAME "Byte Me Burger"

workspace {

  model {
      customer = person "Customer" {
          tags "Customer"
      }
      
      ccAssistant = person "Customer Care Assistant"
      cooker = person "Cooker"
      mercadoPago = softwareSystem "Mercado Pago" {
          tags "External System"
          description "Description"
      }
     

      notification = softwareSystem "Notification Service" {
          tags "External System"
          description "Notification Service"
      }
      properties {
            "structurizr.groupSeparator" "/"
        }

      group "${GROUP_NAME}" {

          selfServiceSystem = softwareSystem "${ORGANISATION_NAME} - Self Service" {

            mySQL = container "MySQL Database" {
                tags "Database"
            }
            
              vendingMachine = container "Self Service Vending Machine" "Description."{
                  tags "Web Browser"
                  customer -> this "Places an order"
              }
              kds = container "Kitchen Display System" {
                  tags "Mobile App"
                  cooker -> this "Updates order Status"
                  ccAssistant -> this "Set order Status as Completed"
              }
              menuManagementSystem = container "Menu Management System" {
                  tags "Web Browser"
                  ccAssistant -> this "Manages menu items"
              }
              webApi = container "Web API" {
                  technology "C# WepApi"
                  vendingMachine -> this "Makes HTTP calls to"

                  group "Driver Adapters" {

                      orderController = component "Order Controller" {
                          technology "API Controller"
                          kds -> this "Makes HTTP calls to"
                          vendingMachine -> this "Makes HTTP calls to"
                      }
                      customerController = component "Customer Controller" {
                          technology "API Controller"
                          vendingMachine -> this "Makes HTTP calls to"
                      }

                      productController = component "Product Controller" {
                          technology "API Controller"
                          menuManagementSystem -> this "Makes HTTP calls to"
                          vendingMachine -> this "Makes HTTP calls to"
                      }

                      paymentController = component "Payment Controller" {
                          vendingMachine -> this "Makes HTTP calls to"
                      }
                }

                group "Core" {
                  group "Inbound Ports"  {

                      orderService = component "Order Service" {
                          orderController -> this "Uses"
                      }
                      customerService = component "Customer Service" {
                          customerController -> this "Uses"
                      }
                      productService = component "Product Service" {
                          productController -> this "Uses"
                      }
                      paymentServiceInterface = component "Payment Service" {
                          paymentController -> this "Uses"
                      }
                  }
                  
                  group "Application"  {

                      useCases = component "Use Cases" {
                        technology "C# Interface"
                          orderService -> this "Uses"
                      }
                      
                  }
                  

                  group "Outbound Ports" {
                      orderRepository = component "Order Repository" {
                          technology "C# Interface"
                          useCases -> this
                      }
                      customerRepository = component "Customer Repository" {
                          useCases -> this
                          technology "C# Interface"
                      }
                      productRepository = component "Product Repository" {
                          useCases -> this
                          technology "C# Interface"
                      }
                  }
                }

                group "Infrastructure/Driven Adapters" {
                    databaseAdapter = component "Database Adapter" {
                        orderRepository -> this
                        customerRepository -> this
                        productRepository -> this
                    }
                    paymentService = component "Payment Service Gateway" {
                        paymentServiceInterface -> this
                    }

                }

                paymentService -> mercadoPago
                databaseAdapter -> mySQL
              }
            }
        }
    }
    views {
        systemContext selfServiceSystem {
            include *
            autolayout lr
        }

        container selfServiceSystem {
            include *
            autolayout lr
        }
        
        component webApi {
            include *
         autolayout lr
            description "The component diagram for the API Application."
        }
        
        theme default
        
        styles {
            element "Person" {
                color #ffffff
                fontSize 22
                shape Person
            }
            element "Customer" {
                background #08427b
            }
            element "External System" {
                background #990000
            }
            element "Software System" {
                background #1168bd
                color #ffffff
            }
            element "Existing System" {
                background #999999
                color #ffffff
            }
            element "Container" {
                background #438dd5
                color #ffffff
            }
            element "Web Browser" {
                shape WebBrowser
            }
            element "Mobile App" {
                shape MobileDeviceLandscape
            }
            element "Database" {
                shape Cylinder
            }
            element "Component" {
                background #85bbf0
                color #000000
            }
            element "Failover" {
                opacity 25
            }
            element "Group:Core" {
                color #ff0000
            }
            element "Group:Core/Application" {
                color #FC6D03
            }
            element "Group:Core/Inbound Ports" {
                color #ff00ff
            }
            element "Group:Core/Outbound Ports" {
                color #ff00ff
            }
        }
    }    
}