Skip to content

structurizr dsl code

Italo Pessoa edited this page Jul 18, 2024 · 2 revisions
!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
            }
        }
    }    
}
              
              
!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"

                group "Frameworks & Drivers" {
                    domainEventHandler = component "Domain Event handler" {
                        technology "C# Class"
                    }

                    orderController = component "Order Controller" {
                        technology "ASP.NET Controller"
                    }
                    customerController = component "Customer Controller" {
                        technology "ASP.NET Controller"
                    }

                    productController = component "Product Controller" {
                        technology "ASP.NET Controller"
                    }
                    paymentController = component "Payment Controller" {
                        technology "ASP.NET Controller"
                    }
                    notificationsController = component "Notifications Controller" {
                        technology "ASP.NET Controller"
                    }
                }

                group "Controllers"  {
                    orderService = component "Order Service" {
                        technology "Clean Arch Controller"
                        orderController -> this "Uses"
                        domainEventHandler -> this "Uses"
                    }
                    customerService = component "Customer Service" {
                        technology "Clean Arch Controller"
                        customerController -> this "Uses"
                        }
                    productService = component "Product Service" {
                        technology "Clean Arch Controller"
                        productController -> this "Uses"
                    }
                    paymentServiceInterface = component "Payment Service" {
                        technology "Clean Arch Controller"
                        paymentController -> this "Uses"
                        notificationsController -> this "Uses"
                    }
                }
                group "Gateways" {
                    orderRepositoryImpl = component "Repositories" {
                        
                        
                    }
                    paymentGateway = component "Payment Gateway" {
                       
                    }
                }
                group "Core" {     
                   group "Use Cases"  {
                        useCases = component "Use Cases" {
                            technology "C# Interface"
                            orderService -> this "Uses"
                            productService -> this "Uses"
                            customerService -> this "Uses"
                            paymentServiceInterface -> this "Uses"
                        }
                    }
                    group "Domain"  {
                        orderRepository = component "IOrderRepository" {
                            technology "C# Interface"
                            useCases -> this
                            orderRepositoryImpl -> this "Implements"
                        }
                        customerRepository = component "ICustomerRepository" {
                            useCases -> this
                            technology "C# Interface"
                            orderRepositoryImpl -> this "Implements"
                        }
                        productRepository = component "IProductRepository" {
                            useCases -> this
                            technology "C# Interface"
                            orderRepositoryImpl -> this "Implements"
                        }
                        paymentRepository = component "IPaymentRepository" {
                            useCases -> this
                            technology "C# Interface"
                            orderRepositoryImpl -> this "Implements"
                        }
                        IPaymentGatewayFactoryMethod = component "Payment Gateway Factory" {
                            technology "C# Interface"
                            useCases -> this
                            paymentServiceInterface -> this "Uses"
                        }
                        IPaymentGateway = component "IPaymentGateway" {
                            technology "C# Interface"
                            paymentGateway -> this "Uses"
                        }
                    }
                }
                
                
              }
            }
        }
    }
    views {
        systemContext selfServiceSystem {
            include *
            autolayout tb
        }

        container selfServiceSystem {
            include *
            autolayout tb
        }
        
        component webApi {
            include *
            autolayout tb
            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/Use Cases" {
                color #FA5A71
            }
            element "Group:Controllers" {
                color #77FA36
            }
            element "Group:Core/Application/UseCases" {
                color #ff00ff
            }
            element "Group:Gateways" {
                color #77FA36
            }
            element "Group:Frameworks & Drivers" {
                color #0064FF
            }
        }
    }    
}