// Canonical example for the book: advanced custom views.

person = kind "Person"
system = kind "System"
container = kind "Container"
component = kind "Component"
database = kind "Database"

// Elements
Customer = person "Customer"
Admin = person "Administrator"

Shop = system "E-Commerce Shop" {
  WebApp = container "Web Application" {
    technology "React"
    description "Customer-facing web UI"
    Cart = component "Shopping Cart" {
      description "Manages items selected for purchase"
    }
    Checkout = component "Checkout Service" {
      description "Collects payment and confirms the order"
    }
    Catalog = component "Product Catalog" {
      description "Displays the product list and details"
    }
  }

  API = container "REST API" {
    technology "Rust"
    description "Backend HTTP API for authentication and order processing"
    Auth = component "Authentication" {
      description "Authenticates users and issues session tokens"
    }
    Orders = component "Order Handler" {
      description "Validates and processes customer orders"
    }
  }

  DB = database "PostgreSQL" {
    technology "PostgreSQL"
    description "Primary transactional data store for orders and products"
  }
  Cache = database "Redis Cache" {
    technology "Redis"
    description "Cache for session and frequently accessed catalog data"
  }
}

// Relationships
Customer -> Shop.WebApp "browses"
Admin -> Shop.WebApp "manages"
Shop.WebApp -> Shop "part of"
Shop.API -> Shop "part of"
Shop.DB -> Shop "part of"
Shop.Cache -> Shop "part of"
Shop.WebApp -> Shop.API "calls"
Shop.API -> Shop.DB "reads/writes"
Shop.API -> Shop.Cache "reads"
Shop.WebApp.Cart -> Shop.API.Auth "validates"
Shop.API.Auth -> Shop.API.Orders "authorizes"
Shop.WebApp.Checkout -> Shop.API.Orders "creates orders"
Shop.WebApp.Catalog -> Shop.API "browses catalog via"
