// Portable learning example; not a UXXU import format.
// Rename payment below and regenerate both views to test shared identity.
workspace "Checkout architecture" "A reviewable checkout example" {
    model {
        customer = person "Customer" "Places an order"
        payment = softwareSystem "Payment provider" "Authorizes payments"
        commerce = softwareSystem "Commerce platform" "Accepts customer orders" {
            web = container "Storefront" "Checkout user interface" "Web application"
            api = container "Checkout API" "Coordinates checkout" "HTTP API" {
                controller = component "Checkout controller" "Validates incoming requests" "HTTP controller"
                service = component "Order service" "Coordinates order creation" "Application service"
                adapter = component "Payment adapter" "Calls the external payment provider" "HTTPS client"
            }
            database = container "Orders" "Stores accepted orders" "PostgreSQL" {
                tags "Database"
            }
            events = container "Order events" "Delivers post-order events" "Message broker"
            worker = container "Notification worker" "Sends purchase confirmations" "Worker process"
        }
        customer -> commerce "Places orders"
        commerce -> payment "Authorizes payment"
        customer -> web "Uses" "HTTPS"
        web -> api "Submits checkout" "HTTPS/JSON"
        api -> payment "Authorizes payment" "HTTPS"
        api -> database "Reads and writes orders" "SQL"
        api -> events "Publishes order accepted" "Messaging"
        events -> worker "Delivers order events" "Messaging"
        web -> controller "Submits checkout" "HTTPS/JSON"
        controller -> service "Requests order creation"
        service -> adapter "Requests payment authorization"
        adapter -> payment "Authorizes payment" "HTTPS"
        service -> database "Persists order" "SQL"
    }
    views {
        systemContext commerce "Context" {
            include customer commerce payment
            autoLayout lr
        }
        container commerce "Containers" {
            include customer payment web api database events worker
            autoLayout lr
        }
        component api "Components" {
            include web controller service adapter payment database
            autoLayout lr
        }
        styles {
            element "Element" {
                color #ffffff
                background #176b87
            }
            element "Person" {
                shape Person
            }
            element "Database" {
                shape Cylinder
            }
        }
    }
}
