chartletv0.21.0chartlet.casoon.de

← All examples

Shop modules

Seven classes of a shop in four packages: Ordering and Catalog nested inside Shop, Billing beside it, and the customer outside all of them. Classes name their package with in; relations run across package borders as before. The description names every package with what it holds, and the table gains a Package column such as Shop › Ordering.

Shop modules

examples/shop-modules.json
{
  "schemaVersion": 1,
  "type": "classes",
  "title": "Shop modules",
  "source": "Illustrative domain model",
  "width": 900,
  "height": 860,
  "classes": {
    "packages": [
      {
        "id": "shop",
        "label": "Shop"
      },
      {
        "id": "ordering",
        "label": "Ordering",
        "in": "shop"
      },
      {
        "id": "catalog",
        "label": "Catalog",
        "in": "shop"
      },
      {
        "id": "billing",
        "label": "Billing"
      }
    ],
    "classes": [
      {
        "id": "customer",
        "label": "Customer",
        "attributes": [
          "+ id: Int",
          "+ name: String",
          "+ email: String"
        ],
        "methods": [
          "+ placeOrder(): Order"
        ]
      },
      {
        "id": "order",
        "label": "Order",
        "attributes": [
          "+ id: Int",
          "+ placedAt: Date",
          "+ status: Status"
        ],
        "methods": [
          "+ total(): Money",
          "+ cancel()"
        ],
        "in": "ordering"
      },
      {
        "id": "line",
        "label": "OrderLine",
        "attributes": [
          "+ quantity: Int",
          "+ price: Money"
        ],
        "in": "ordering"
      },
      {
        "id": "product",
        "label": "Product",
        "attributes": [
          "+ sku: String",
          "+ name: String",
          "+ price: Money"
        ],
        "in": "catalog"
      },
      {
        "id": "payment",
        "label": "Payment",
        "kind": "interface",
        "methods": [
          "+ charge(amount: Money): Receipt"
        ],
        "in": "billing"
      },
      {
        "id": "card",
        "label": "CardPayment",
        "attributes": [
          "- number: String"
        ],
        "methods": [
          "+ charge(amount: Money): Receipt"
        ],
        "in": "billing"
      },
      {
        "id": "status",
        "label": "Status",
        "kind": "enum",
        "attributes": [
          "PLACED",
          "PAID",
          "SHIPPED",
          "CANCELLED"
        ],
        "in": "ordering"
      }
    ],
    "relations": [
      {
        "from": "customer",
        "to": "order",
        "fromCardinality": "1",
        "toCardinality": "0..*",
        "label": "places"
      },
      {
        "from": "order",
        "to": "line",
        "kind": "composition",
        "fromCardinality": "1",
        "toCardinality": "1..*"
      },
      {
        "from": "line",
        "to": "product",
        "fromCardinality": "*",
        "toCardinality": "1"
      },
      {
        "from": "card",
        "to": "payment",
        "kind": "realization"
      },
      {
        "from": "order",
        "to": "payment",
        "kind": "dependency",
        "label": "paid by"
      },
      {
        "from": "order",
        "to": "status",
        "kind": "dependency"
      }
    ]
  }
}
Focus
Shop modules
Shop modulesClass diagram with 7 classes and 6 relations in 4 packages. Shop: Ordering, Catalog. Ordering (in Shop): Order, OrderLine, Status. Catalog (in Shop): Product. Billing: Payment, CardPayment. Most connected: Order (4 connections). Bottleneck: Order; without it the diagram falls apart. Customer: 3 attributes, 1 method. Customer is associated with Order (1 : 0..*) [places]. Order: 3 attributes, 2 methods. Order is composed of OrderLine (1 : 1..*); depends on Payment [paid by]; depends on Status. OrderLine: 2 attributes, 0 methods. OrderLine is associated with Product (* : 1). Product: 3 attributes, 0 methods. Payment: 0 attributes, 1 method. CardPayment: 1 attribute, 1 method. CardPayment implements Payment. Status: 4 attributes, 0 methods.BillingShopCatalogOrderingCustomer → Order: places0..*1Order → OrderLine1..*1OrderLine → Product1*Payment → CardPaymentOrder → Payment: paid byOrder → Statusplacespaid byCustomerCustomer+ id: Int+ name: String+ email: String+ placeOrder(): OrderOrderOrder+ id: Int+ placedAt: Date+ status: Status+ total(): Money+ cancel()OrderLineOrderLine+ quantity: Int+ price: MoneyProductProduct+ sku: String+ name: String+ price: MoneyPayment – «interface»«interface»Payment+ charge(amount: Money): ReceiptCardPaymentCardPayment- number: String+ charge(amount: Money): ReceiptStatus – «enumeration»«enumeration»StatusPLACEDPAIDSHIPPEDCANCELLED

Source: Illustrative domain model

Show chart data
Data for Shop modules
ItemKindPackageAttributesMethodsRelations
CustomerClass+ id: Int; + name: String; + email: String+ placeOrder(): Orderis associated with Order (1 : 0..*) [places]
OrderClassShop › Ordering+ id: Int; + placedAt: Date; + status: Status+ total(): Money; + cancel()is composed of OrderLine (1 : 1..*); depends on Payment [paid by]; depends on Status
OrderLineClassShop › Ordering+ quantity: Int; + price: Moneyis associated with Product (* : 1)
ProductClassShop › Catalog+ sku: String; + name: String; + price: Money
PaymentInterfaceBilling+ charge(amount: Money): Receipt
CardPaymentClassBilling- number: String+ charge(amount: Money): Receiptimplements Payment
StatusEnumerationShop › OrderingPLACED; PAID; SHIPPED; CANCELLED
  • Class diagram with packages
  • Show how a domain model is divided into modules