Playground
See kUML in action.
Curated examples of UML and C4 diagrams expressed as type-safe Kotlin code. Source on the left, rendered SVG on the right.
Classes, enums, associations, inheritance
order-domain.kuml.kts
classDiagram(name = "Order Domain") {
val status = enumOf(name = "OrderStatus") {
literal(name = "DRAFT")
literal(name = "CONFIRMED")
literal(name = "SHIPPED")
literal(name = "CANCELLED")
}
val payable = interfaceOf(name = "Payable") {
operation(name = "pay") { returns(typeName = "Boolean") }
}
// Abstrakte Basisklasse — Name wird kursiv gerendert
val abstractEntity = classOf(name = "AbstractEntity") {
isAbstract = true
attribute(name = "id", type = "UUID", visibility = Visibility.PROTECTED, isReadOnly = true)
}
val customer = classOf(name = "Customer") {
attribute(name = "id", type = "UUID")
attribute(name = "name", type = "String")
attribute(name = "email", type = "String")
}
val order = classOf(name = "Order") {
attribute(name = "id", type = "UUID")
attribute(name = "status", type = status, defaultValue = "DRAFT")
attribute(name = "total", type = "BigDecimal", visibility = Visibility.PRIVATE)
attribute(name = "taxRate", type = "BigDecimal", isStatic = true, defaultValue = "0.19")
implements(iface = payable)
extends(general = abstractEntity)
operation(name = "place") {
visibility = Visibility.PUBLIC
parameter(name = "items", type = "List<OrderItem>")
returns(typeName = "OrderId")
}
operation(name = "confirm") { returns(typeName = "Boolean") }
// OCL-Invariante — wird per `kuml validate` geprüft
constraint(name = "PositiveTotal", body = "self.total >= 0")
}
val orderItem = classOf(name = "OrderItem") {
attribute(name = "quantity", type = "Int")
attribute(name = "unitPrice", type = "BigDecimal")
}
val subscription = classOf(name = "Subscription") {
attribute(name = "renewalDate", type = "LocalDate")
attribute(name = "interval", type = "Period")
}
// Generalisierung: Subscription erbt von Order (top-level Schreibweise)
generalization(specific = subscription, general = order)
// Abhängigkeit: Order nutzt eine Notification-Klasse, ohne sie zu besitzen
val notification = classOf(name = "NotificationService")
dependency(client = order, supplier = notification, name = "notifies")
// Assoziation: Kunde besitzt 0..n Bestellungen; Order kennt seinen Customer nicht (nicht navigierbar)
association(source = customer, target = order) {
source { multiplicity(spec = "1"); navigable = false }
target { multiplicity(spec = "0..*"); role = "orders" }
}
// Komposition: eine Bestellung besteht aus 1..n OrderItems
association(source = order, target = orderItem) {
aggregation = AggregationKind.COMPOSITE
source { multiplicity(spec = "1") }
target { multiplicity(spec = "1..*"); role = "items" }
}
// UML-Notiz (Comment): Freitext-Kasten mit gefalteter Ecke, per gestrichelter
// Linie an ein Element angehängt — hier an Order.
comment(
text = "Encapsulates the full order lifecycle from placement to fulfillment.",
firstAnchor = order,
)
}Live rendering supports UML class diagrams only — repeat/for/if and other diagram types are rejected.
place-order.kuml.kts
// uml-sequence-place-order.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/19 UML Sequence – API Submit.md
// Do not edit by hand; update the vault note and re-run the sync.
sequenceDiagram(name = "Place Order — API Submit") {
val customer = lifeline(name = "Customer") { isActor = true }
val frontend = lifeline(name = "Frontend")
val backend = lifeline(name = "Backend")
val db = lifeline(name = "OrderDB")
message(from = customer, to = frontend, label = "submitOrder()")
message(from = frontend, to = backend, label = "POST /orders")
alt {
branch(guard = "[valid]") {
message(from = backend, to = db, label = "INSERT order")
reply(from = db, to = backend, label = "ok")
reply(from = backend, to = frontend, label = "201 Created")
}
branch(guard = "[invalid]") {
reply(from = backend, to = frontend, label = "400 Bad Request")
}
}
reply(from = frontend, to = customer, label = "confirmation")
}order-lifecycle.kuml.kts
// uml-state-order-lifecycle.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/18 UML State Machine – Order Lifecycle.md
// Do not edit by hand; update the vault note and re-run the sync.
stateDiagram(name = "Order Lifecycle") {
val start = initialState()
val draft = state(name = "Draft") {
entry = "validate()"
}
val confirmed = state(name = "Confirmed")
val processing = compositeState(name = "Processing") {
state(name = "Picking")
state(name = "Packing")
}
val shipped = state(name = "Shipped")
val cancelled = finalState(name = "Cancelled")
val done = finalState(name = "Done")
transition(start, draft)
transition(draft, confirmed) {
trigger = "confirm()"
guard = "[valid]"
}
transition(draft, cancelled) {
trigger = "cancel()"
}
transition(confirmed, processing) {
trigger = "process()"
}
transition(processing, shipped) {
trigger = "ship()"
effect = "notifyCustomer()"
}
transition(shipped, done)
}order-checkout.kuml.kts
activityDiagram(name = "Checkout") {
val start = initialNode()
val verify = action(name = "Verify cart")
val ok = decision(name = "valid?")
val charge = action(name = "Charge card")
val confirm = action(name = "Send confirmation")
val cancel = action(name = "Notify error")
val done = finalNode()
edge(from = start, to = verify)
edge(from = verify, to = ok)
edge(from = ok, to = charge, guard = "ok")
edge(from = ok, to = cancel, guard = "invalid")
edge(from = charge, to = confirm)
edge(from = confirm, to = done)
edge(from = cancel, to = done)
}checkout.kuml.kts
// uml-usecase-checkout.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/16 UML Use Case – Online Shop.md
// Do not edit by hand; update the vault note and re-run the sync.
useCaseDiagram(name = "Online Shop") {
val customer = actor(name = "Customer")
val payment = actor(name = "Payment Gateway")
val placeOrder = useCase(name = "Place Order")
val validateCart = useCase(name = "Validate Cart")
val applyDiscount = useCase(name = "Apply Discount")
val charge = useCase(name = "Charge Card")
subject(name = "Online Shop", containedUseCases =
arrayOf(placeOrder, validateCart, applyDiscount, charge))
association(source = customer, target = placeOrder)
association(source = charge, target = payment)
include(base = placeOrder, addition = validateCart)
extend(base = placeOrder, extension = applyDiscount, at = "PaymentChosen")
include(base = placeOrder, addition = charge)
}architecture.kuml.kts
componentDiagram(name = "Order Architecture") {
val orderApi = interfaceOf(name = "IOrderApi") {
operation(name = "placeOrder") { returns(typeName = "OrderId") }
operation(name = "cancelOrder")
}
val orderService = component(name = "OrderService") {
port(name = "api")
provides(iface = orderApi)
}
val invoiceService = component(name = "InvoiceService") {
port(name = "orderEvents")
requires(iface = orderApi)
}
connect(end1 = orderService, port1 = "api",
end2 = invoiceService, port2 = "orderEvents")
}internet-banking.kuml.kts
c4Model(name = "Internet Banking — Context") {
val customer = person(name = "Customer") {
description = "Endnutzer mit Konto"
}
val support = person(name = "Support Agent") {
description = "Interner Mitarbeiter"
}
val banking = softwareSystem(name = "Internet Banking") {
description = "Webanwendung für Endkunden"
}
val email = softwareSystem(name = "Email Service") {
external = true
}
val sms = softwareSystem(name = "SMS Gateway") {
external = true
}
relationship(source = customer, target = banking) { technology = "HTTPS" }
relationship(source = support, target = banking) { technology = "HTTPS" }
relationship(source = banking, target = email) { technology = "SMTP" }
relationship(source = banking, target = sms) { technology = "HTTPS/JSON" }
systemContextDiagram(name = "Banking — Context View") {
include(customer, support, banking, email, sms)
}
}hybrid-vehicle.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "VehicleSystem") {
val massType = attributeDef(name = "Mass")
val powerType = attributeDef(name = "Power")
// Abstrakte Basis-Definition — kann nicht direkt instanziiert werden
val powertrain = partDef(name = "Powertrain", isAbstract = true) {
attribute(name = "ratedPower", typeId = powerType.id)
}
val vehicle = partDef(name = "Vehicle") {
attribute(name = "mass", typeId = massType.id)
}
// Spezialisierung: Engine ist eine konkrete Powertrain-Ausprägung
val engine = partDef(name = "Engine", specializesId = powertrain.id) {
attribute(name = "ratedPower", typeId = powerType.id)
}
bdd(name = "Vehicle BDD") {
include(definition = powertrain)
include(definition = vehicle)
include(definition = engine)
}
}vehicle-requirements.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "VehicleRequirements") {
// ── Requirements ────────────────────────────────────────────────────
val topSpeed = requirementDef(
name = "TopSpeedRequirement",
reqId = "R-001",
text = "The vehicle shall reach at least 180 km/h on flat road",
subject = "Vehicle",
)
val curbWeight = requirementDef(
name = "CurbWeightRequirement",
reqId = "R-002",
text = "The vehicle curb weight shall not exceed 1500 kg",
subject = "Vehicle",
)
val fuelEfficiency = requirementDef(
name = "FuelEfficiencyRequirement",
reqId = "R-003",
text = "The vehicle shall consume less than 4 l/100km combined",
subject = "Vehicle",
)
val emissions = requirementDef(
name = "EmissionsRequirement",
reqId = "R-004",
text = "The vehicle shall comply with Euro 7 emissions standards",
subject = "Vehicle",
)
val nox = requirementDef(
name = "NOxRequirement",
reqId = "R-005",
text = "NOx emissions shall not exceed 30 mg/km",
subject = "Vehicle",
)
// ── Satisfying design element ───────────────────────────────────────
val vehicle = partDef(name = "Vehicle")
// ── Verifying use case ──────────────────────────────────────────────
val verifyTopSpeed = useCaseDef(name = "VerifyTopSpeed")
// ── Requirement Diagram ─────────────────────────────────────────────
reqDiagram(name = "Vehicle — top-level requirements") {
// Nodes
include(definition = topSpeed)
include(definition = curbWeight)
include(definition = fuelEfficiency)
include(definition = emissions)
include(definition = nox)
include(definition = vehicle)
include(definition = verifyTopSpeed)
// Satisfy: Vehicle erfüllt R-001 / R-002 / R-003
satisfy(source = vehicle, requirement = topSpeed)
satisfy(source = vehicle, requirement = curbWeight)
satisfy(source = vehicle, requirement = fuelEfficiency)
// Verify: VerifyTopSpeed prüft R-001
verify(source = verifyTopSpeed, requirement = topSpeed)
// Derive: R-001 leitet sich aus R-003 ab
// (Endgeschwindigkeit vs. Verbrauch ist ein klassischer Trade-off)
derive(source = topSpeed, target = fuelEfficiency)
// Contains: R-004 dekomponiert in R-005
contains(parent = emissions, child = nox)
}
}library-system-uc.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "LibrarySystem") {
// ── Actors ─────────────────────────────────────────────────────────────
val reader = actorDef(name = "Reader")
val librarian = actorDef(name = "Librarian")
val paymentSystem = actorDef(name = "PaymentSystem")
// ── Use Cases ──────────────────────────────────────────────────────────
val borrowBook = useCaseDef(name = "BorrowBook")
val returnBook = useCaseDef(name = "ReturnBook")
val payLateFee = useCaseDef(name = "PayLateFee")
val authenticate = useCaseDef(name = "Authenticate")
// ── Use Case Diagram ───────────────────────────────────────────────────
ucDiagram(name = "Library — top-level use cases") {
// Nodes
include(definition = reader)
include(definition = librarian)
include(definition = paymentSystem)
include(definition = borrowBook)
include(definition = returnBook)
include(definition = payLateFee)
include(definition = authenticate)
// Associations: actor "participates in" use case
association(actor = reader, useCase = borrowBook)
association(actor = reader, useCase = returnBook)
association(actor = reader, useCase = payLateFee)
association(actor = librarian, useCase = borrowBook)
association(actor = paymentSystem, useCase = payLateFee)
// «include»: target is always executed as part of source
include(source = borrowBook, target = authenticate)
include(source = returnBook, target = authenticate)
// «extend»: target's behaviour is optionally extended by source
extend(source = payLateFee, target = returnBook)
}
}traffic-light-stm.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "TrafficLight") {
// ── States ────────────────────────────────────────────────────────────
val initial = stateDef(name = "Initial", isInitial = true)
val red = stateDef(
name = "Red",
entryAction = "switchLights('red')",
exitAction = "logTransition('red')",
)
val green = stateDef(
name = "Green",
entryAction = "switchLights('green')",
doAction = "tickTimer()",
)
val yellow = stateDef(
name = "Yellow",
entryAction = "switchLights('yellow')",
)
val off = stateDef(name = "Off", isFinal = true)
// ── Transitions ───────────────────────────────────────────────────────
transition(name = "init", source = initial, target = red)
transition(name = "redToGreen", source = red, target = green, trigger = "timer60s")
transition(name = "greenToYellow", source = green, target = yellow, trigger = "timer45s")
transition(name = "yellowToRed", source = yellow, target = red, trigger = "timer5s")
transition(
name = "powerOff",
source = red,
target = off,
trigger = "powerOff",
guard = "!emergency",
effect = "shutdownLights()",
)
// ── State Transition Diagram ─────────────────────────────────────────
stmDiagram(name = "TrafficLight — phase cycle") {
include(state = initial)
include(state = red)
include(state = green)
include(state = yellow)
include(state = off)
}
}stm-timer.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
import kotlin.time.Duration.Companion.seconds
sysml2Model(name = "TimerAmpel") {
// ── Zustände ──────────────────────────────────────────────────────────
val initial = stateDef(name = "Initial", isInitial = true)
val red = stateDef(name = "Red", entryAction = "switchLights('red')")
val green = stateDef(name = "Green", entryAction = "switchLights('green')")
val yellow = stateDef(name = "Yellow", entryAction = "switchLights('yellow')")
val night = stateDef(name = "NightBlink", entryAction = "blinkYellow()")
val off = stateDef(name = "Off", isFinal = true)
// ── Übergänge: Zeit-Trigger statt Ereignisnamen ───────────────────────
transition(name = "init", source = initial, target = red)
transition(name = "redToGreen", source = red, target = green, timer = after(duration = 30.seconds))
transition(name = "greenToYellow", source = green, target = yellow, timer = after(duration = 45.seconds))
transition(name = "yellowToRed", source = yellow, target = red, timer = after(duration = 5.seconds))
transition(name = "nightMode", source = red, target = night, timer = at(iso = "2026-12-24T22:00:00Z"))
transition(name = "daybreak", source = night, target = red, trigger = "daybreak")
transition(
name = "powerOff",
source = red,
target = off,
trigger = "powerOff",
guard = "!emergency",
effect = "shutdownLights()",
)
// ── Diagramm ──────────────────────────────────────────────────────────
stmDiagram(name = "Timer-Ampel") {
include(state = initial)
include(state = red)
include(state = green)
include(state = yellow)
include(state = night)
include(state = off)
}
}stm-regions-fork-join.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "BestellungParallel") {
val initial = stateDef(name = "Initial", isInitial = true)
val received = stateDef(name = "Received")
val closed = stateDef(name = "Closed", isFinal = true)
// ── Zusammengesetzter Zustand mit zwei Regionen ──────────────────────
val processing = stateDef(name = "Processing")
val payment = region(owner = processing, name = "Payment")
val shipping = region(owner = processing, name = "Shipping")
val payOpen = stateDef(name = "PaymentOpen", parent = processing, region = payment)
val payDone = stateDef(name = "PaymentDone", parent = processing, region = payment)
val shipPicking = stateDef(name = "Picking", parent = processing, region = shipping)
val shipPacked = stateDef(name = "Packed", parent = processing, region = shipping)
val split = fork(name = "Split")
val merge = join(name = "Merge")
// ── Übergänge ─────────────────────────────────────────────────────────
transition(name = "init", source = initial, target = received)
transition(name = "accept", source = received, target = split, trigger = "accept")
transition(name = "toPayment", source = split, target = payOpen)
transition(name = "toShipping", source = split, target = shipPicking)
transition(name = "paid", source = payOpen, target = payDone, trigger = "paymentOk")
transition(name = "packed", source = shipPicking, target = shipPacked, trigger = "packed")
transition(name = "payJoin", source = payDone, target = merge, trigger = "complete")
transition(name = "shipJoin", source = shipPacked, target = merge, trigger = "complete")
transition(name = "finish", source = merge, target = closed, effect = "sendInvoice()")
stmDiagram(name = "Bestellung parallel") {
include(state = initial)
include(state = received)
include(state = processing)
include(state = split)
include(state = merge)
include(state = closed)
}
}stm-history-junction.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "Waschmaschine") {
val initial = stateDef(name = "Initial", isInitial = true)
val off = stateDef(name = "Off")
// ── On: zusammengesetzter Zustand mit History ────────────────────────
val on = stateDef(name = "On")
val onInit = stateDef(name = "OnInit", isInitial = true, parent = on)
val washing = stateDef(name = "Washing", parent = on)
val spinning = stateDef(name = "Spinning", parent = on)
val hist = history(name = "H", deep = true, parent = on)
// ── Junction: Programmwahl nach Guard ─────────────────────────────────
val choose = junction(name = "Program")
val eco = stateDef(name = "EcoWash")
val normal = stateDef(name = "NormalWash")
// ── Übergänge ─────────────────────────────────────────────────────────
transition(name = "init", source = initial, target = off)
transition(name = "powerOn", source = off, target = hist, trigger = "powerOn")
transition(name = "powerOff", source = on, target = off, trigger = "powerOff")
transition(name = "onInit", source = onInit, target = washing)
transition(name = "spin", source = washing, target = spinning, trigger = "spin")
transition(name = "wash", source = spinning, target = washing, trigger = "wash")
transition(name = "selectProgram", source = off, target = choose, trigger = "start")
transition(name = "ecoRun", source = choose, target = eco, guard = "vars.load < 3")
transition(name = "normalRun", source = choose, target = normal, guard = "vars.load >= 3")
stmDiagram(name = "Waschmaschine") {
include(state = initial)
include(state = off)
include(state = on)
include(state = choose)
include(state = eco)
include(state = normal)
}
}stm-prose-guards.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "Genehmigung") {
val initial = stateDef(name = "Initial", isInitial = true)
val submitted = stateDef(name = "Submitted")
val review = stateDef(name = "InReview")
val approved = stateDef(name = "Approved", isFinal = true)
val rejected = stateDef(name = "Rejected", isFinal = true)
transition(name = "init", source = initial, target = submitted)
transition(name = "startReview", source = submitted, target = review, trigger = "assign")
// Freitext: der Simulator weiß nicht, ob der Antrag vollständig ist
transition(
name = "approve",
source = review,
target = approved,
trigger = "decide",
guard = prose(text = "Antrag vollständig und Gebühr bezahlt"),
effect = "notifyApplicant()",
)
// Auswertbar: ein normaler Ausdruck, daneben im selben Diagramm
transition(
name = "reject",
source = review,
target = rejected,
trigger = "decide",
guard = "vars.documentsMissing > 2",
)
stmDiagram(name = "Genehmigung") {
include(state = initial)
include(state = submitted)
include(state = review)
include(state = approved)
include(state = rejected)
}
}req-groups.kuml.kts
import dev.kuml.sysml2.RequirementPriority
import dev.kuml.sysml2.RequirementStatus
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Vehicle Requirements") {
val car = partDef("Car")
val brakes = partDef("BrakeSystem")
val top = requirementDef(
"TopSpeed",
reqId = "R-001",
text = "The vehicle shall reach at least 180 km/h on flat road within 30 seconds.",
priority = RequirementPriority.HIGH,
status = RequirementStatus.APPROVED,
source = "Marketing, Product Brief 2026",
subjectRef = "Car",
)
val stop = requirementDef(
"StoppingDistanceFromHundredKilometresPerHourOnDryAndWetRoadSurfaces",
reqId = "R-002",
text = "The vehicle shall stop from 100 km/h within 36 metres on a dry road.",
priority = RequirementPriority.MEDIUM,
status = RequirementStatus.DRAFT,
)
val stopCopy = requirementDef(
"StoppingCopy",
text = "The vehicle shall stop from 100 km/h within 36 metres on a dry road.",
)
val dry = requirementDef(
"DryRoadAssumption",
text = "Tests are run on dry asphalt at 20 degrees Celsius.",
isAssumption = true,
)
val abs = requirementDef("AbsRequired", text = "ABS is mandatory.", priority = RequirementPriority.LOW)
val speedTest = testCaseDef("TopSpeedTest", text = "Accelerate on the test track.")
val driving = useCaseDef("DriveFast")
reqDiagram("Vehicle requirements") {
include(car)
include(brakes)
include(driving)
include(top)
include(speedTest)
group("Performance") {
include(top)
group("Braking") {
include(stop)
group("Details") {
include(stopCopy)
include(abs)
}
}
}
include(dry)
satisfy(car, top)
satisfy(brakes, stop)
verify(speedTest, top)
derive(abs, stop)
contains(stop, abs)
refine(driving, top)
trace(dry, stop)
copy(stopCopy, stop)
}
}uc-subject-frames.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Library") {
val user = actorDef("User")
val reader = actorDef("Reader")
val librarian = actorDef("Librarian")
val borrow = useCaseDef("Borrow Book", description = "A reader borrows a book for up to four weeks. The system checks the account and records the loan.")
val auth = useCaseDef("Authenticate")
val fee = useCaseDef("Pay Late Fee")
val manage = useCaseDef("Manage Catalogue", description = "Add, change or remove titles in the catalogue of the library system.")
val export = useCaseDef("Export Report")
ucDiagram("Library system") {
include(user)
include(reader)
include(librarian)
include(borrow)
include(auth)
include(fee)
include(manage)
include(export)
generalize(reader, user)
generalize(librarian, user)
association(reader, borrow)
association(librarian, manage)
association(librarian, export)
include(borrow, auth)
extend(fee, borrow)
subject("Lending") {
include(borrow)
include(auth)
include(fee)
}
subject("Administration") {
include(manage)
include(export)
}
}
}act-signals-regions.kuml.kts
import dev.kuml.sysml2.ActionPin
import dev.kuml.sysml2.PinDirection
import dev.kuml.sysml2.PinSide
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("OrderHandling") {
val customer = activityPartition("Customer")
val shop = activityPartition("Shop")
val start = initialNode(partition = customer)
val placeOrder =
actionDef(
name = "PlaceOrder",
partition = customer,
pins =
listOf(
ActionPin(name = "order", typeId = "Order", direction = PinDirection.Output, side = PinSide.Right),
ActionPin(name = "budget", typeId = "Money", direction = PinDirection.Output, side = PinSide.Bottom),
),
)
val stock = callBehavior(name = "CheckStock", activityId = "StockCheckActivity", partition = shop)
val inStock = decisionNode(name = "in stock?", partition = shop, showName = true)
val payment = interruptibleRegion(name = "Payment")
val retry = interruptibleRegion(name = "Retry", parent = payment)
val requestPayment = sendSignal(name = "RequestPayment", signal = "PaymentRequest", partition = shop, region = payment)
val paid = acceptEvent(name = "PaymentReceived", partition = shop, region = payment)
val timeout = acceptTimeEvent(name = "PaymentTimeout", time = "after 10 min", partition = shop, region = payment)
val charge =
actionDef(
name = "ChargeCard",
partition = shop,
region = payment,
pins =
listOf(
ActionPin(name = "order", typeId = "Order", direction = PinDirection.Input, side = PinSide.Left),
),
)
val retryCharge = actionDef(name = "RetryCharge", partition = shop, region = retry)
val handleError = actionDef(name = "HandleError", partition = shop)
val cancel = actionDef(name = "CancelOrder", partition = shop)
val split = forkNode(name = "pack and notify", partition = shop, showName = true)
val pack = actionDef(name = "PackGoods", partition = shop)
val notify = actionDef(name = "NotifyCustomer", partition = shop)
val join = joinNode(name = "done", partition = shop, showName = true)
val end = finalNode(partition = shop)
val aborted = flowFinalNode(partition = shop)
controlFlow(name = "start", source = start, target = placeOrder)
objectFlow(name = "order", source = placeOrder, target = charge, objectType = "Order", sourcePin = "order", targetPin = "order")
controlFlow(name = "toStock", source = placeOrder, target = stock)
controlFlow(name = "stockChecked", source = stock, target = inStock)
controlFlow(name = "yes", source = inStock, target = requestPayment, guard = "yes")
controlFlow(name = "no", source = inStock, target = cancel, guard = "no")
controlFlow(name = "waiting", source = requestPayment, target = paid)
controlFlow(name = "received", source = paid, target = charge)
controlFlow(name = "again", source = charge, target = retryCharge)
controlFlow(name = "timedOut", source = timeout, target = cancel, interrupts = true)
controlFlow(name = "afterCharge", source = charge, target = split)
controlFlow(name = "packing", source = split, target = pack)
controlFlow(name = "informing", source = split, target = notify)
controlFlow(name = "packed", source = pack, target = join)
controlFlow(name = "informed", source = notify, target = join)
controlFlow(name = "finish", source = join, target = end)
controlFlow(name = "abort", source = cancel, target = aborted)
exceptionHandler(protectedNode = charge, handler = handleError, type = "PaymentError")
controlFlow(name = "errorEnd", source = handleError, target = aborted)
actDiagram("Order handling") {
include(start)
include(placeOrder)
include(stock)
include(inStock)
include(requestPayment)
include(paid)
include(timeout)
include(charge)
include(retryCharge)
include(handleError)
include(cancel)
include(split)
include(pack)
include(notify)
include(join)
include(end)
include(aborted)
layout {
sameLayer(pack, notify)
last(end, aborted)
}
}
}act-pins.kuml.kts
import dev.kuml.sysml2.ActionPin
import dev.kuml.sysml2.PinDirection
import dev.kuml.sysml2.PinSide
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Pins") {
val make = actionDef(
name = "MakeParts",
pins = listOf(
ActionPin(name = "parts", typeId = "Part", direction = PinDirection.Output, side = PinSide.Bottom),
ActionPin(name = "scrap", typeId = "Part", direction = PinDirection.Output, side = PinSide.Right),
),
)
val assemble = actionDef(
name = "Assemble",
pins = listOf(ActionPin(name = "parts", typeId = "Part", direction = PinDirection.Input, side = PinSide.Top)),
)
val recycle = actionDef(
name = "Recycle",
pins = listOf(ActionPin(name = "scrap", typeId = "Part", direction = PinDirection.Input, side = PinSide.Left)),
)
objectFlow(name = "good", source = make, target = assemble, objectType = "Part", sourcePin = "parts", targetPin = "parts")
objectFlow(name = "bad", source = make, target = recycle, objectType = "Part", sourcePin = "scrap", targetPin = "scrap")
actDiagram("Pins an allen Seiten") {
include(make)
include(assemble)
include(recycle)
}
}seq-nested-ref-time.kuml.kts
import dev.kuml.sysml2.CombinedFragmentOperator
import dev.kuml.sysml2.MessageKind
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "OrderPayment") {
val customer = lifelineDef(name = "Customer")
val shop = lifelineDef(name = "Shop")
val payment = lifelineDef(name = "Payment")
val bank = lifelineDef(name = "Bank")
foundMessage(label = "newOrder", target = shop, seqNo = 0)
message(label = "charge(total)", source = shop, target = payment, seqNo = 1, kind = MessageKind.Sync)
message(label = "authorize", source = payment, target = bank, seqNo = 2, kind = MessageKind.Sync)
combinedFragment(name = "result", operator = CombinedFragmentOperator.Alt) {
operand(guard = "approved", start = 3, end = 6) {
combinedFragment(name = "receipts", operator = CombinedFragmentOperator.Loop) {
operand(guard = "for each item", start = 5, end = 6)
}
}
operand(guard = "else", start = 7, end = 8)
}
message(label = "approved", source = bank, target = payment, seqNo = 3, kind = MessageKind.Reply)
message(label = "paid", source = payment, target = shop, seqNo = 4, kind = MessageKind.Reply)
message(label = "receipt()", source = shop, target = customer, seqNo = 5, kind = MessageKind.Sync)
message(label = "ack", source = customer, target = shop, seqNo = 6, kind = MessageKind.Reply)
message(label = "declined", source = payment, target = shop, seqNo = 7, kind = MessageKind.Reply)
lostMessage(label = "notifyLater", source = shop, seqNo = 8)
interactionUse(name = "audit", refersTo = "AuditTrail", lifelines = listOf(shop, payment), seqNo = 10)
durationConstraint(lifeline = payment, from = 1, to = 4, expression = "t <= 2 s")
seqDiagram(name = "Order payment") {
include(customer)
include(shop)
include(payment)
include(bank)
}
}par-nested-pins.kuml.kts
import dev.kuml.sysml2.ConstraintParameter
import dev.kuml.sysml2.ConstraintParameterDirection.In
import dev.kuml.sysml2.ConstraintParameterDirection.Out
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "VehicleDynamicsModel") {
attributeDef(name = "Mass")
attributeDef(name = "Force")
attributeDef(name = "Speed")
attributeDef(name = "Acceleration")
val dynamics = constraintDef(
name = "VehicleDynamics",
expression = "a = (F_drive - k * v^2) / m",
parameters = listOf(
ConstraintParameter(name = "m", typeId = "Mass", direction = In),
ConstraintParameter(name = "F_drive", typeId = "Force", direction = In),
ConstraintParameter(name = "v", typeId = "Speed", direction = In),
ConstraintParameter(name = "a", typeId = "Acceleration", direction = Out),
),
)
val drag = constraintDef(
name = "Drag",
expression = "F_net = F_drive - k * v^2",
parameters = listOf(
ConstraintParameter(name = "F_drive", typeId = "Force", direction = In),
ConstraintParameter(name = "v", typeId = "Speed", direction = In),
ConstraintParameter(name = "F_net", typeId = "Force", direction = Out),
),
parent = dynamics,
)
val newton = constraintDef(
name = "NewtonsLaw",
expression = "a = F / m",
parameters = listOf(
ConstraintParameter(name = "F", typeId = "Force", direction = In),
ConstraintParameter(name = "m", typeId = "Mass", direction = In),
ConstraintParameter(name = "a", typeId = "Acceleration", direction = Out),
),
parent = dynamics,
)
val vehicle = partDef(name = "Vehicle") {
attribute(name = "mass", typeId = "Mass")
attribute(name = "driveForce", typeId = "Force")
attribute(name = "speed", typeId = "Speed")
attribute(name = "acceleration", typeId = "Acceleration")
}
// Vehicle attributes to the pins of the outer constraint
bind(name = "mass_to_m", source = "Vehicle::mass", target = dynamics.pin("m"))
bind(name = "drive_to_F", source = "Vehicle::driveForce", target = dynamics.pin("F_drive"))
bind(name = "speed_to_v", source = "Vehicle::speed", target = dynamics.pin("v"))
bind(name = "a_to_accel", source = dynamics.pin("a"), target = "Vehicle::acceleration")
// Outer pins to inner pins
bind(name = "F_to_drag", source = dynamics.pin("F_drive"), target = drag.pin("F_drive"))
bind(name = "v_to_drag", source = dynamics.pin("v"), target = drag.pin("v"))
bind(name = "m_to_newton", source = dynamics.pin("m"), target = newton.pin("m"))
// Between the inner constraints
bind(name = "net_to_newton", source = drag.pin("F_net"), target = newton.pin("F"))
// Inner pin back to the outer pin
bind(name = "newton_to_a", source = newton.pin("a"), target = dynamics.pin("a"))
parDiagram(name = "Vehicle dynamics") {
include(definition = dynamics)
include(definition = drag)
include(definition = newton)
include(definition = vehicle)
}
}req-wrap-columns.kuml.kts
import dev.kuml.sysml2.RequirementPriority
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Platform Requirements") {
val reqs = listOf(
"Boot" to "The platform shall boot within 5 seconds.",
"Update" to "Updates shall install without user interaction.",
"Rollback" to "A failed update shall roll back automatically.",
"Telemetry" to "Telemetry shall be opt-in.",
"Logging" to "Logs shall be kept for 30 days.",
"Auth" to "Every request shall be authenticated.",
"Audit" to "Security events shall be audited.",
"Encrypt" to "Data at rest shall be encrypted.",
"Backup" to "Backups shall run nightly.",
"Restore" to "A restore shall complete within one hour.",
"Scale" to "The platform shall scale to 10 000 users.",
"Monitor" to "Health shall be monitored continuously.",
).mapIndexed { i, (name, text) ->
requirementDef(name, reqId = "R-${i + 1}", text = text, priority = RequirementPriority.MEDIUM)
}
reqDiagram("Platform requirements") {
reqs.forEach { include(it) }
layout {
wrapColumns = 4
}
}
}uml-class-note-kinds.kuml.kts
classDiagram(name = "Note kinds") {
val order = classOf(name = "Order") {
attribute(name = "id", type = "String")
attribute(name = "total", type = "Decimal")
}
val line = classOf(name = "OrderLine") {
attribute(name = "qty", type = "Int")
}
association(source = order, target = line)
comment(text = "A plain note without a symbol.", firstAnchor = order, kind = NoteKind.NOTE)
comment(text = "Warning: totals are not rounded here.", firstAnchor = order, kind = NoteKind.WARNING)
comment(text = "Decision: orders are immutable once paid.", firstAnchor = order, kind = NoteKind.DECISION)
comment(text = "Todo: add the discount rules.", firstAnchor = line, kind = NoteKind.TODO)
comment(text = "Risk: a large order may exceed the gateway limit.", firstAnchor = line, kind = NoteKind.RISK)
comment(text = "Deprecated: use Invoice instead of Bill.", firstAnchor = line, kind = NoteKind.DEPRECATED)
}sysml2-bdd-note-kinds.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "Note kinds") {
val vehicle = partDef(name = "Vehicle")
val engine = partDef(name = "Engine")
bdd(name = "Note kinds") {
include(vehicle)
include(engine)
comment(text = "A plain note without a symbol.", firstAnchor = vehicle, kind = NoteKind.NOTE)
comment(text = "Important: the engine must be certified.", firstAnchor = vehicle, kind = NoteKind.IMPORTANT)
comment(text = "Assumption: one engine per vehicle.", firstAnchor = vehicle, kind = NoteKind.ASSUMPTION)
comment(text = "Question: is a hybrid drive a second engine?", firstAnchor = engine, kind = NoteKind.QUESTION)
comment(text = "Reference: see the powertrain specification.", firstAnchor = engine, kind = NoteKind.REFERENCE)
}
}erm-note-kinds.kuml.kts
ermModel(name = "Note kinds") {
val customer =
entity(name = "Customer") {
id()
attribute(name = "email", type = ErmDataType.Varchar(255), unique = true, nullable = false)
}
val order =
entity(name = "Order") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
attribute(name = "total", type = ErmDataType.Decimal(precision = 10, scale = 2))
}
relationship(from = customer, to = order, sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
note(text = "A plain note without a symbol.", customer)
note(text = "Hint: index the email column.", customer, kind = NoteKind.HINT)
note(text = "Warning: totals are not rounded here.", order, kind = NoteKind.WARNING)
note(text = "Success: all foreign keys are checked.", order, kind = NoteKind.SUCCESS)
}bpmn-note-kinds.kuml.kts
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "Note kinds") {
process(id = "p", name = "Order") {
val start = startEvent(name = "Start")
val check = task(name = "Check order")
val ship = task(name = "Ship order")
val done = endEvent(name = "Done")
sequenceFlow(from = start, to = check)
sequenceFlow(from = check, to = ship)
sequenceFlow(from = ship, to = done)
textAnnotation(text = "A plain note without a symbol.", start, kind = NoteKind.NOTE)
textAnnotation(text = "Hint: check the stock first.", check, kind = NoteKind.HINT)
textAnnotation(text = "Risk: the carrier may be late.", ship, kind = NoteKind.RISK)
textAnnotation(text = "Success: the order is complete.", done, kind = NoteKind.SUCCESS)
}
diagram(name = "Note kinds", processId = "p")
}uml-class-note-format.kuml.kts
classDiagram(name = "Formatted notes") {
val order = classOf(name = "Order") {
attribute(name = "id", type = "String")
}
val line = classOf(name = "OrderLine") {
attribute(name = "qty", type = "Int")
}
association(source = order, target = line)
comment(text = "**Bold** and *italic* with `code()` and ***both***.", firstAnchor = order, kind = NoteKind.NOTE)
comment(text = "Checks:\n- totals are **rounded**\n- ids are *unique*\n- see `validate()`", firstAnchor = order, kind = NoteKind.WARNING)
comment(text = "Steps:\n1. validate\n1. reserve stock\n1. charge the card", firstAnchor = order, kind = NoteKind.TODO)
comment(text = "Read the [kUML handbook](https://kuml.dev/handbook) before you start.", firstAnchor = line, kind = NoteKind.INFO)
}sysml2-bdd-note-format.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "Formatted notes") {
val vehicle = partDef(name = "Vehicle")
val engine = partDef(name = "Engine")
bdd(name = "Formatted notes") {
include(vehicle)
include(engine)
comment(text = "**Requirement:** the *engine* needs `12V`.\n- starts within 2 s\n- runs at idle", firstAnchor = vehicle, kind = NoteKind.INFO)
comment(text = "Risk: ***fatal overheating*** is possible, see [the spec](https://example.org/spec).", firstAnchor = engine, kind = NoteKind.RISK)
}
}c4-context-note-kinds-format.kuml.kts
import dev.kuml.c4.dsl.c4Model
c4Model(name = "Shop") {
val user = person(name = "User")
val shop = softwareSystem(name = "Shop")
val pay = softwareSystem(name = "Payment") { external = true }
relationship(source = user, target = shop) { description = "uses" }
relationship(source = shop, target = pay) { description = "pays via" }
note(text = "**Decision:** orders are *immutable* once paid, see [**the ADR**](https://kuml.dev/adr).", shop, kind = NoteKind.DECISION)
note(text = "Payment runs through an external provider.", pay, kind = NoteKind.INFO)
systemContextDiagram(name = "Context") {
include(user, shop, pay)
note(text = "Question: should refunds be `separate`?\n- yes\n- no", id = "freeNote", kind = NoteKind.QUESTION)
}
}bpmn-note-format.kuml.kts
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "Formatted notes") {
process(id = "p", name = "Order") {
val start = startEvent(name = "Start")
val check = task(name = "Check order")
val ship = task(name = "Ship order")
val done = endEvent(name = "Done")
sequenceFlow(from = start, to = check)
sequenceFlow(from = check, to = ship)
sequenceFlow(from = ship, to = done)
textAnnotation(text = "**Hint:** call `validate()` first.\n- *stock*\n- credit", check, kind = NoteKind.HINT)
textAnnotation(text = "Warning: see [the policy](https://example.org/policy).", ship, kind = NoteKind.WARNING)
}
diagram(name = "Formatted notes", processId = "p")
}newton-second-law-par.kuml.kts
import dev.kuml.sysml2.ConstraintParameter
import dev.kuml.sysml2.ConstraintParameterDirection
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "NewtonModel") {
attributeDef(name = "Mass")
attributeDef(name = "Acceleration")
attributeDef(name = "Force")
val newton = constraintDef(
name = "NewtonsLaw",
expression = "F = m * a",
parameters = listOf(
ConstraintParameter(name = "F", typeId = "Force", direction = ConstraintParameterDirection.Out),
ConstraintParameter(name = "m", typeId = "Mass", direction = ConstraintParameterDirection.In),
ConstraintParameter(name = "a", typeId = "Acceleration", direction = ConstraintParameterDirection.In),
),
)
val vehicle = partDef(name = "Vehicle") {
attribute(name = "mass", typeId = "Mass")
attribute(name = "acceleration", typeId = "Acceleration")
attribute(name = "force", typeId = "Force")
}
bind(name = "F_to_force", source = "NewtonsLaw::F", target = "Vehicle::force")
bind(name = "m_to_mass", source = "NewtonsLaw::m", target = "Vehicle::mass")
bind(name = "a_to_acceleration", source = "NewtonsLaw::a", target = "Vehicle::acceleration")
parDiagram(name = "Newton — F = m·a applied to Vehicle") {
include(definition = newton)
include(definition = vehicle)
}
}login-flow-seq.kuml.kts
import dev.kuml.sysml2.CombinedFragmentOperand
import dev.kuml.sysml2.CombinedFragmentOperator
import dev.kuml.sysml2.MessageKind
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "LoginFlow") {
// ── Lifelines (participants) ─────────────────────────────────────────
val user = lifelineDef(name = "User")
val browser = lifelineDef(name = "Browser")
val authService = lifelineDef(name = "AuthService")
// ── Create message (top of the interaction) ─────────────────────────
message(
label = "new Browser()",
source = user,
target = browser,
seqNo = 0,
kind = MessageKind.Create,
)
// ── Messages (sequence-ordered) ──────────────────────────────────────
message(
label = "enterCredentials(user, pwd)",
source = user,
target = browser,
seqNo = 1,
kind = MessageKind.Sync,
)
message(
label = "login(user, pwd)",
source = browser,
target = authService,
seqNo = 2,
kind = MessageKind.Sync,
)
message(
label = "validateCredentials()",
source = authService,
target = authService,
seqNo = 3,
kind = MessageKind.Sync,
)
message(
label = "sessionToken",
source = authService,
target = browser,
seqNo = 4,
kind = MessageKind.Reply,
)
message(
label = "welcomeScreen",
source = browser,
target = user,
seqNo = 5,
kind = MessageKind.Reply,
)
message(
label = "loginError",
source = authService,
target = browser,
seqNo = 6,
kind = MessageKind.Reply,
)
message(
label = "errorScreen",
source = browser,
target = user,
seqNo = 7,
kind = MessageKind.Reply,
)
// ── Execution Specification on AuthService ──────────────────────────
executionSpec(
name = "authServiceActive",
lifeline = authService,
startSeqNo = 2,
endSeqNo = 3,
)
// ── Combined Fragment — `alt` over the reply phase ──────────────────
// Beide Operanden bekommen eigene Nachrichten-Spannen, damit der
// Operand-Separator des Sad-Paths zwischen `welcomeScreen` (seqNo=5)
// und `loginError` (seqNo=6) eingezogen wird und der Frame beide
// Branches umschließt. Ein Sad-Path-Operand mit Null-Spanne
// (`startSeqNo == endSeqNo == letzter Happy-Path-seqNo`) würde vom
// V2.0.44-Guard im Renderer aus dem Frame herausgeschoben — siehe
// [[03 Bereiche/kUML/Architektur#SEQ-Renderer-Operand-Guards]].
combinedFragment(
name = "credentialsCheck",
operator = CombinedFragmentOperator.Alt,
operands = listOf(
CombinedFragmentOperand(guard = "credentials valid", startSeqNo = 4, endSeqNo = 5),
CombinedFragmentOperand(guard = "credentials invalid", startSeqNo = 6, endSeqNo = 7),
),
)
// ── Sequence Diagram ────────────────────────────────────────────────
seqDiagram(name = "Login flow") {
include(lifeline = user)
include(lifeline = browser)
include(lifeline = authService)
}
}order-processing-act.kuml.kts
import dev.kuml.sysml2.ActionPin
import dev.kuml.sysml2.PinDirection
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model(name = "OrderProcessing") {
// ── PartDefinitions für `represents`-Targets ────────────────────────
partDef(name = "Customer")
partDef(name = "OrderSystem")
partDef(name = "Warehouse")
// ── Activity Partitions (Swimlanes) ─────────────────────────────────
val customerLane = activityPartition(name = "Customer", represents = "Customer")
val orderSysLane = activityPartition(name = "OrderSystem", represents = "OrderSystem")
val warehouseLane = activityPartition(name = "Warehouse", represents = "Warehouse")
// ── Customer Lane ───────────────────────────────────────────────────
val initial = initialNode(partition = customerLane)
val placeOrder = actionDef(
name = "PlaceOrder",
action = "submit(order)",
partition = customerLane,
pins = listOf(ActionPin(name = "orderDetails", typeId = "Order", direction = PinDirection.Output)),
)
// ── OrderSystem Lane ────────────────────────────────────────────────
val validate = actionDef(
name = "ValidateOrder",
action = "validate(order)",
partition = orderSysLane,
pins = listOf(
ActionPin(name = "orderDetails", typeId = "Order", direction = PinDirection.Input),
ActionPin(name = "validation", typeId = "Bool", direction = PinDirection.Output),
),
)
val decide = decisionNode(name = "valid?", partition = orderSysLane)
val pay = actionDef(
name = "ProcessPayment",
action = "charge(order.total)",
partition = orderSysLane,
pins = listOf(ActionPin(name = "validation", typeId = "Bool", direction = PinDirection.Input)),
)
val cancel = actionDef(
name = "CancelOrder",
action = "notify(order, 'cancelled')",
partition = orderSysLane,
pins = listOf(ActionPin(name = "validation", typeId = "Bool", direction = PinDirection.Input)),
)
// ── Warehouse Lane ──────────────────────────────────────────────────
val reserve = actionDef(
name = "ReserveInventory",
action = "reserve(order.items)",
partition = warehouseLane,
pins = listOf(ActionPin(name = "orderDetails", typeId = "Order", direction = PinDirection.Input)),
)
val ship = actionDef(
name = "ShipOrder",
action = "dispatch(order)",
partition = warehouseLane,
pins = listOf(ActionPin(name = "inventory", typeId = "Inventory", direction = PinDirection.Input)),
)
val finalN = finalNode(partition = warehouseLane)
val flowFinal = flowFinalNode(partition = warehouseLane)
// ── Control Flows (token-passing edges) ─────────────────────────────
controlFlow(name = "start", source = initial, target = placeOrder)
controlFlow(name = "validated", source = validate, target = decide)
controlFlow(name = "yes", source = decide, target = pay, guard = "valid")
controlFlow(name = "payToReserve", source = pay, target = reserve)
controlFlow(name = "reserveToShip", source = reserve, target = ship)
controlFlow(name = "end", source = ship, target = finalN)
controlFlow(name = "no", source = decide, target = cancel, guard = "!valid")
controlFlow(name = "cancelEnd", source = cancel, target = flowFinal)
// ── Object Flow (token carries a typed object) ──────────────────────
objectFlow(name = "carryOrder", source = placeOrder, target = validate, objectType = "Order")
// ── Activity Diagram ────────────────────────────────────────────────
actDiagram(name = "Order Processing — workflow") {
include(node = initial)
include(node = placeOrder)
include(node = validate)
include(node = decide)
include(node = pay)
include(node = cancel)
include(node = reserve)
include(node = ship)
include(node = finalN)
include(node = flowFinal)
}
}order-snapshot.kuml.kts
// uml-object-order-snapshot.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/10 UML Objekt – Order Snapshot.md
// Do not edit by hand; update the vault note and re-run the sync.
// Klassifikatoren werden direkt als UmlClass konstruiert — `classOf` ist auf
// einen UmlModelScope (z. B. innerhalb von classDiagram { … }) beschränkt,
// den wir hier nicht öffnen.
val customer = UmlClass(
id = "Customer",
name = "Customer",
attributes = listOf(
UmlProperty(id = "Customer::id", name = "id", type = UmlTypeRef("UUID")),
UmlProperty(id = "Customer::name", name = "name", type = UmlTypeRef("String")),
),
)
val order = UmlClass(
id = "Order",
name = "Order",
attributes = listOf(
UmlProperty(id = "Order::id", name = "id", type = UmlTypeRef("UUID")),
UmlProperty(id = "Order::amount", name = "amount", type = UmlTypeRef("BigDecimal")),
UmlProperty(id = "Order::customer", name = "customer", type = UmlTypeRef("Customer")),
),
)
objectDiagram(name = "Order #42 Snapshot") {
val alice = instanceOf(classifier = customer, name = "alice") {
slot(feature = "id", value = literal("c0ffee-001"))
slot(feature = "name", value = literal("Alice Müller"))
}
val ord = instanceOf(classifier = order, name = "order42") {
slot(feature = "id", value = literal("o-42"))
slot(feature = "amount", value = literal("19.95 EUR"))
slot(feature = "customer", value = ref(alice))
}
link(from = alice, to = ord, sourceRole = "buyer", targetRole = "purchase")
}layered-architecture.kuml.kts
// uml-package-layered-architecture.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/11 UML Paket – Domain Modules.md
// Do not edit by hand; update the vault note and re-run the sync.
packageDiagram(name = "Order Domain Modules") {
val shared = packageOf(name = "shared") {
classOf(name = "Money") {
attribute(name = "amount", type = "BigDecimal")
attribute(name = "currency", type = "String")
}
}
val shop = packageOf(name = "shop") {
classOf(name = "Customer")
classOf(name = "Order")
}
val payment = packageOf(name = "payment") {
classOf(name = "Invoice")
classOf(name = "Receipt")
}
packageImport(client = shop, supplier = shared)
packageImport(client = payment, supplier = shared)
packageAccess(client = payment, supplier = shop)
}uml-composite-payment-service.kuml.kts
compositeStructureDiagram(name = "OrderService Internals") {
val orderApi = interfaceOf(name = "IOrderApi") {
operation(name = "placeOrder") { returns(typeName = "OrderId") }
}
val dbApi = interfaceOf(name = "IPersistence") {
operation(name = "save")
}
// Referenzen auf verschachtelte Parts vor dem Parent-Block deklarieren,
// damit connect() auf Diagramm-Ebene darauf zugreifen kann.
lateinit var validator: UmlComponent
lateinit var persistence: UmlComponent
val service = component(name = "OrderService") {
port(name = "api")
provides(iface = orderApi)
port(name = "db")
requires(iface = dbApi)
validator = component(name = "Validator") {
port(name = "in") // empfängt eingehende Anfragen
port(name = "out") // gibt validierte Daten weiter
}
persistence = component(name = "Persistence") {
port(name = "in") // empfängt von Validator
port(name = "db") // Datenbankzugriff via Boundary-Port
requires(iface = dbApi)
}
}
// Delegation-Connector: Boundary-Port → innerer Part-Port
connect(end1 = service, port1 = "api", end2 = validator, port2 = "in")
// Assembly-Connector: Part-Port → Part-Port
connect(end1 = validator, port1 = "out", end2 = persistence, port2 = "in")
// Delegation-Connector: innerer Part-Port → Boundary-Port (nach außen)
connect(end1 = persistence, port1 = "db", end2 = service, port2 = "db")
}order-system-deployment.kuml.kts
// uml-deployment-order-system.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/14 UML Deployment – Cloud Stack.md
// Do not edit by hand; update the vault note and re-run the sync.
deploymentDiagram(name = "Production Cloud Stack") {
val cluster = executionEnvironment(name = "EKS Cluster") {
val pod = node(name = "Pod: order-service") {
artifact(name = "orderservice.jar")
artifact(name = "config.yaml")
}
}
val db = device(name = "PostgreSQL 16") {
artifact(name = "orders.db")
}
val webApp = artifact(name = "webapp.war")
val edge = node(name = "Edge Gateway")
deploy(artifact = webApp, node = edge)
communicationPath(end1 = cluster, end2 = db)
communicationPath(end1 = edge, end2 = cluster)
}uml-profile-autosar.kuml.kts
// uml-profile-autosar.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/29 UML Profil – AUTOSAR.md
// Do not edit by hand; update the vault note and re-run the sync.
profileDiagram(name = "AUTOSAR Adaptive Platform Profile") {
val classMC = metaclass(name = "Class")
val interfaceMC = metaclass(name = "Interface")
val portMC = metaclass(name = "Port")
val operationMC = metaclass(name = "Operation")
val swComponent = stereotype(name = "SoftwareComponent", metaclasses = listOf("Class")) {
tag(name = "kind", type = "String")
tag(name = "category", type = "String")
}
val atomicSwc = stereotype(name = "AtomicSoftwareComponent", metaclasses = listOf("Class")) {
tag(name = "kind", type = "String")
tag(name = "memoryMappingEnabled", type = "Boolean")
}
val senderReceiverIf = stereotype(name = "SenderReceiverInterface", metaclasses = listOf("Interface")) {
tag(name = "dataElement", type = "String")
tag(name = "category", type = "String")
}
val clientServerIf = stereotype(name = "ClientServerInterface", metaclasses = listOf("Interface")) {
tag(name = "category", type = "String")
}
val providedPort = stereotype(name = "ProvidedPort", metaclasses = listOf("Port")) {
tag(name = "portInterface", type = "String")
}
val requiredPort = stereotype(name = "RequiredPort", metaclasses = listOf("Port")) {
tag(name = "portInterface", type = "String")
}
val runnable = stereotype(name = "Runnable", metaclasses = listOf("Operation")) {
tag(name = "period", type = "Integer")
tag(name = "activationReason", type = "String")
}
extension(stereotype = swComponent, metaclass = classMC)
extension(stereotype = atomicSwc, metaclass = classMC)
extension(stereotype = senderReceiverIf, metaclass = interfaceMC)
extension(stereotype = clientServerIf, metaclass = interfaceMC)
extension(stereotype = providedPort, metaclass = portMC)
extension(stereotype = requiredPort, metaclass = portMC)
extension(stereotype = runnable, metaclass = operationMC)
}uml-profile-autosar-ecu.kuml.kts
// uml-profile-autosar-ecu.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/29 UML Profil – AUTOSAR.md
// Do not edit by hand; update the vault note and re-run the sync.
classDiagram(name = "Braking ECU – SW Component Architecture") {
val sensor = classOf(name = "SpeedSensorSwc") {
stereotypes += "AtomicSoftwareComponent"
attribute(name = "rawSpeedValue", type = "Float")
operation(name = "readSensor") {
stereotypes += "Runnable"
}
}
val controller = classOf(name = "BrakeControllerSwc") {
stereotypes += "AtomicSoftwareComponent"
attribute(name = "brakePressure", type = "Float")
operation(name = "controlBrake") {
stereotypes += "Runnable"
}
}
val speedIf = interfaceOf(name = "SpeedSignalIf") {
stereotypes += "SenderReceiverInterface"
}
realization(implementing = sensor, iface = speedIf)
dependency(client = controller, supplier = speedIf)
}uml-profile-soaml.kuml.kts
@file:Suppress("unused")
import dev.kuml.core.dsl.classDiagram
import dev.kuml.profile.soaml.soamlProfile
import dev.kuml.uml.dsl.applyProfile
import dev.kuml.uml.dsl.attribute
import dev.kuml.uml.dsl.classOf
import dev.kuml.uml.dsl.collaboration
import dev.kuml.uml.dsl.component
import dev.kuml.uml.dsl.stereotype
classDiagram("Order Processing SOA") {
applyProfile(soamlProfile)
// ── Participants ──────────────────────────────────────────────────────────
val orderService =
component("OrderService") {
stereotype("Participant")
}
val paymentService =
component("PaymentService") {
stereotype("Participant")
}
// ── Message Type ──────────────────────────────────────────────────────────
classOf("OrderMessage") {
stereotype("MessageType")
attribute(name = "orderId", type = "UUID")
attribute(name = "totalAmount", type = "BigDecimal")
}
// ── Service Contract ──────────────────────────────────────────────────────
collaboration("OrderPaymentContract") {
stereotype("ServiceContract")
role(name = "provider", type = orderService.name)
role(name = "consumer", type = paymentService.name)
}
}uml-profile-spring.kuml.kts
@file:Suppress("unused")
import dev.kuml.core.dsl.classDiagram
import dev.kuml.profile.javaee.javaEeProfile
import dev.kuml.profile.spring.springProfile
import dev.kuml.uml.dsl.applyProfile
import dev.kuml.uml.dsl.classOf
import dev.kuml.uml.dsl.operation
import dev.kuml.uml.dsl.returns
import dev.kuml.uml.dsl.stereotype
classDiagram("Payment Service") {
applyProfile(javaEeProfile)
applyProfile(springProfile)
// ── Service + REST Layer ──────────────────────────────────────────────────
classOf("PaymentProcessor") {
stereotype("Service") // from JavaEE — transactional service
stereotype("RestController") { // from Spring — REST endpoint
"produces" to "application/json"
}
operation(name = "process") { returns("PaymentResult") }
operation(name = "refund") { returns("RefundResult") }
}
// ── Data Layer ────────────────────────────────────────────────────────────
classOf("PaymentRepository") {
stereotype("SpringData") { "readOnly" to false }
operation(name = "findByOrderId") { returns("Payment") }
operation(name = "save") { returns("Payment") }
}
// ── Scheduled background job ──────────────────────────────────────────────
classOf("ReportScheduler") {
stereotype("Service") { "transactional" to false }
operation("sendDailyReport") {
stereotype("Scheduled") { "cron" to "0 0 8 * * *" }
returns("void")
}
operation("pollExternalQueue") {
stereotype("Scheduled") { "fixedRate" to 5000L }
returns("void")
}
}
}uml-profile-openapi.kuml.kts
@file:Suppress("unused")
import dev.kuml.core.dsl.classDiagram
import dev.kuml.profile.openapi.openApiProfile
import dev.kuml.uml.dsl.applyProfile
import dev.kuml.uml.dsl.attribute
import dev.kuml.uml.dsl.classOf
import dev.kuml.uml.dsl.stereotype
classDiagram(name = "User API") {
applyProfile(openApiProfile)
// ── REST Resource ─────────────────────────────────────────────────────────
classOf("UserResource") {
stereotype("Resource") {
"path" to "/users"
"version" to "v2"
}
}
// ── Data Schemas ──────────────────────────────────────────────────────────
classOf("UserSchema") {
stereotype("Schema") {
"format" to "json"
"description" to "Public user representation"
}
attribute(name = "id", type = "UUID")
attribute(name = "email", type = "String")
attribute(name = "name", type = "String")
}
classOf("ErrorSchema") {
stereotype("Schema") {
"format" to "json"
"description" to "RFC-7807 error body"
}
attribute(name = "type", type = "String")
attribute(name = "title", type = "String")
attribute(name = "status", type = "Int")
}
}jpa-profile.kuml.kts
// uml-profile-jpa-annotations.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/15 UML Profil – Java EE Profile.md
// Do not edit by hand; update the vault note and re-run the sync.
profileDiagram(name = "Java EE Profile") {
val classMC = metaclass(name = "Class")
val entity = stereotype(name = "Entity", metaclasses = listOf("Class")) {
tag(name = "tableName", type = "String")
tag(name = "schema", type = "String")
}
val valueObject = stereotype(name = "ValueObject", metaclasses = listOf("Class")) {
tag(name = "immutable", type = "Boolean")
}
extension(stereotype = entity, metaclass = classMC)
extension(stereotype = valueObject, metaclass = classMC)
}uml-profile-exposed.kuml.kts
// uml-profile-exposed.kuml.kts — synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/38 UML Profil – Exposed.md
// Do not edit by hand; update the vault note and re-sync (see note there re: multi-block profile examples).
profileDiagram(name = "Exposed Profile") {
val classMC = metaclass(name = "Class")
val propertyMC = metaclass(name = "Property")
val associationMC = metaclass(name = "Association")
val table = stereotype(name = "Table", metaclasses = listOf("Class")) {
tag(name = "tableName", type = "String")
tag(name = "schema", type = "String")
}
val column = stereotype(name = "Column", metaclasses = listOf("Property")) {
tag(name = "columnType", type = "String")
tag(name = "name", type = "String")
}
val fk = stereotype(name = "FK", metaclasses = listOf("Association")) {
tag(name = "targetTable", type = "String")
}
extension(stereotype = table, metaclass = classMC)
extension(stereotype = column, metaclass = propertyMC)
extension(stereotype = fk, metaclass = associationMC)
}uml-profile-exposed-psm.kuml.kts
// uml-profile-exposed-psm.kuml.kts — synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/38 UML Profil – Exposed.md
// Do not edit by hand; update the vault note and re-sync (see note there re: multi-block profile examples).
classDiagram(name = "Exposed PSM – User & Address") {
val address = classOf(name = "Address") {
stereotypes += "Table"
stereotypes += "Entity"
attribute(name = "id", type = "Long") {
stereotypes += "Id"
}
attribute(name = "city", type = "String") {
stereotypes += "Column"
}
}
val user = classOf(name = "User") {
stereotypes += "Table"
stereotypes += "Entity"
attribute(name = "id", type = "Long") {
stereotypes += "Id"
}
attribute(name = "name", type = "String") {
stereotypes += "Column"
}
}
association(source = user, target = address) {
name = "billingAddress"
stereotypes += "FK"
target { multiplicity("1") }
}
}erm-martin-ecommerce.kuml.kts
// erm-martin-ecommerce.kuml.kts — synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/39 ERM Martin – E-Commerce Schema.md
// Do not edit by hand; update the vault note and re-sync.
ermModel("E-Commerce Schema") {
val customer =
entity("Customer") {
id()
attribute(name = "email", type = ErmDataType.Varchar(255), unique = true, nullable = false)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "created_at", type = ErmDataType.Timestamp(), default = "now()")
}
val address =
entity("Address") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
attribute(name = "street", type = ErmDataType.Varchar(255))
attribute(name = "city", type = ErmDataType.Varchar(120))
attribute(name = "zip", type = ErmDataType.Varchar(20))
}
val category =
entity("Category") {
id()
attribute(name = "name", type = ErmDataType.Varchar(120))
// Self-reference: der eigene id-String ist im Entity-Block noch nicht
// verfügbar, daher hier nur ein normales Attribut — die Kante kommt
// unten als separates relationship(from = category, to = category, …).
attribute(name = "parent_id", type = ErmDataType.Uuid, nullable = true)
}
val product =
entity("Product") {
id()
foreignKey(name = "category_id", references = category, nullable = false)
attribute(name = "sku", type = ErmDataType.Varchar(64), unique = true)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "price", type = ErmDataType.Decimal(10, 2), nullable = false)
check(expression = "price >= 0", name = "positive_price")
index("sku", unique = true, name = "idx_product_sku")
}
val order =
entity("Order") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
// Zwei Fremdschlüssel auf dieselbe Zieltabelle (Address) — Rechnungs-
// und Lieferadresse. Unten als zwei relationship(...)-Aufrufe mit
// unterschiedlichem targetRole abgebildet.
foreignKey(name = "billing_address_id", references = address, nullable = false)
foreignKey(name = "shipping_address_id", references = address, nullable = false)
attribute(name = "status", type = ErmDataType.Varchar(32), default = "'pending'")
attribute(name = "placed_at", type = ErmDataType.Timestamp(), default = "now()")
index("status", name = "idx_order_status")
}
// Schwache Entität / identifizierende Beziehung: OrderItem existiert nur im
// Kontext einer Order (Komposition, ON DELETE CASCADE).
val orderItem =
entity("OrderItem", weak = true) {
foreignKey(name = "order_id", references = order, onDelete = ReferentialAction.CASCADE, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
attribute(name = "quantity", type = ErmDataType.Integer(), nullable = false)
attribute(name = "unit_price", type = ErmDataType.Decimal(10, 2), nullable = false)
}
val payment =
entity("Payment") {
id()
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "amount", type = ErmDataType.Decimal(10, 2), nullable = false)
attribute(name = "method", type = ErmDataType.Varchar(32))
attribute(name = "paid_at", type = ErmDataType.Timestamp())
}
// Drei Fremdschlüssel auf drei verschiedene Zieltabellen aus einer einzigen Entität.
val review =
entity("Review") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "rating", type = ErmDataType.Integer(bits = 16), nullable = false)
attribute(name = "comment", type = ErmDataType.Text)
check(expression = "rating BETWEEN 1 AND 5", name = "rating_range")
}
// Jede oben deklarierte Fremdschlüsselspalte bekommt hier ihre eigene,
// gerenderte relationship(...)-Kante (die ERM-Layout-Bridge zeichnet
// ausschließlich model.relationships, nicht automatisch aus foreignKey()).
relationship(from = customer, to = address, name = "has", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = category,
to = category,
name = "subcategory of",
sourceRole = "parent",
targetRole = "child",
sourceCardinality = Cardinality.ZERO_ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(from = category, to = product, name = "groups", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = order, name = "places", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = address,
to = order,
name = "bills",
targetRole = "billing",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = address,
to = order,
name = "ships",
targetRole = "shipping",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = order,
to = orderItem,
name = "contains",
kind = RelationshipKind.IDENTIFYING,
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ONE_MANY,
)
relationship(from = product, to = orderItem, name = "ordered as", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = payment, name = "paid by", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = review, name = "writes", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = product, to = review, name = "reviewed in", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = review, name = "reviewed via", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
view(
name = "active_orders",
query = "SELECT o.id, o.status, o.placed_at, c.email FROM \"order\" o JOIN customer c ON c.id = o.customer_id WHERE o.status != 'cancelled'",
references = listOf(order, customer),
)
diagram(name = "E-Commerce Schema", notation = ErmNotation.MARTIN, showIndexes = true)
}erm-bachman-ecommerce.kuml.kts
// erm-bachman-ecommerce.kuml.kts — synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/39 ERM Martin – E-Commerce Schema.md
// Do not edit by hand; update the vault note and re-sync.
ermModel("E-Commerce Schema") {
val customer =
entity("Customer") {
id()
attribute(name = "email", type = ErmDataType.Varchar(255), unique = true, nullable = false)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "created_at", type = ErmDataType.Timestamp(), default = "now()")
}
val address =
entity("Address") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
attribute(name = "street", type = ErmDataType.Varchar(255))
attribute(name = "city", type = ErmDataType.Varchar(120))
attribute(name = "zip", type = ErmDataType.Varchar(20))
}
val category =
entity("Category") {
id()
attribute(name = "name", type = ErmDataType.Varchar(120))
attribute(name = "parent_id", type = ErmDataType.Uuid, nullable = true)
}
val product =
entity("Product") {
id()
foreignKey(name = "category_id", references = category, nullable = false)
attribute(name = "sku", type = ErmDataType.Varchar(64), unique = true)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "price", type = ErmDataType.Decimal(10, 2), nullable = false)
check(expression = "price >= 0", name = "positive_price")
index("sku", unique = true, name = "idx_product_sku")
}
val order =
entity("Order") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
foreignKey(name = "billing_address_id", references = address, nullable = false)
foreignKey(name = "shipping_address_id", references = address, nullable = false)
attribute(name = "status", type = ErmDataType.Varchar(32), default = "'pending'")
attribute(name = "placed_at", type = ErmDataType.Timestamp(), default = "now()")
index("status", name = "idx_order_status")
}
val orderItem =
entity("OrderItem", weak = true) {
foreignKey(name = "order_id", references = order, onDelete = ReferentialAction.CASCADE, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
attribute(name = "quantity", type = ErmDataType.Integer(), nullable = false)
attribute(name = "unit_price", type = ErmDataType.Decimal(10, 2), nullable = false)
}
val payment =
entity("Payment") {
id()
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "amount", type = ErmDataType.Decimal(10, 2), nullable = false)
attribute(name = "method", type = ErmDataType.Varchar(32))
attribute(name = "paid_at", type = ErmDataType.Timestamp())
}
val review =
entity("Review") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "rating", type = ErmDataType.Integer(bits = 16), nullable = false)
attribute(name = "comment", type = ErmDataType.Text)
check(expression = "rating BETWEEN 1 AND 5", name = "rating_range")
}
relationship(from = customer, to = address, name = "has", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = category,
to = category,
name = "subcategory of",
sourceRole = "parent",
targetRole = "child",
sourceCardinality = Cardinality.ZERO_ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(from = category, to = product, name = "groups", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = order, name = "places", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = address,
to = order,
name = "bills",
targetRole = "billing",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = address,
to = order,
name = "ships",
targetRole = "shipping",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = order,
to = orderItem,
name = "contains",
kind = RelationshipKind.IDENTIFYING,
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ONE_MANY,
)
relationship(from = product, to = orderItem, name = "ordered as", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = payment, name = "paid by", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = review, name = "writes", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = product, to = review, name = "reviewed in", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = review, name = "reviewed via", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
view(
name = "active_orders",
query = "SELECT o.id, o.status, o.placed_at, c.email FROM \"order\" o JOIN customer c ON c.id = o.customer_id WHERE o.status != 'cancelled'",
references = listOf(order, customer),
)
diagram(name = "E-Commerce Schema (Bachman)", notation = ErmNotation.BACHMAN, showIndexes = true)
}erm-chen-ecommerce.kuml.kts
// erm-chen-ecommerce.kuml.kts — synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/39 ERM Martin – E-Commerce Schema.md
// Do not edit by hand; update the vault note and re-sync.
ermModel("E-Commerce Schema") {
val customer =
entity("Customer") {
id()
attribute(name = "email", type = ErmDataType.Varchar(255), unique = true, nullable = false)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "created_at", type = ErmDataType.Timestamp(), default = "now()")
}
val address =
entity("Address") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
attribute(name = "street", type = ErmDataType.Varchar(255))
attribute(name = "city", type = ErmDataType.Varchar(120))
attribute(name = "zip", type = ErmDataType.Varchar(20))
}
val category =
entity("Category") {
id()
attribute(name = "name", type = ErmDataType.Varchar(120))
attribute(name = "parent_id", type = ErmDataType.Uuid, nullable = true)
}
val product =
entity("Product") {
id()
foreignKey(name = "category_id", references = category, nullable = false)
attribute(name = "sku", type = ErmDataType.Varchar(64), unique = true)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "price", type = ErmDataType.Decimal(10, 2), nullable = false)
check(expression = "price >= 0", name = "positive_price")
index("sku", unique = true, name = "idx_product_sku")
}
val order =
entity("Order") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
foreignKey(name = "billing_address_id", references = address, nullable = false)
foreignKey(name = "shipping_address_id", references = address, nullable = false)
attribute(name = "status", type = ErmDataType.Varchar(32), default = "'pending'")
attribute(name = "placed_at", type = ErmDataType.Timestamp(), default = "now()")
index("status", name = "idx_order_status")
}
val orderItem =
entity("OrderItem", weak = true) {
foreignKey(name = "order_id", references = order, onDelete = ReferentialAction.CASCADE, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
attribute(name = "quantity", type = ErmDataType.Integer(), nullable = false)
attribute(name = "unit_price", type = ErmDataType.Decimal(10, 2), nullable = false)
}
val payment =
entity("Payment") {
id()
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "amount", type = ErmDataType.Decimal(10, 2), nullable = false)
attribute(name = "method", type = ErmDataType.Varchar(32))
attribute(name = "paid_at", type = ErmDataType.Timestamp())
}
val review =
entity("Review") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "rating", type = ErmDataType.Integer(bits = 16), nullable = false)
attribute(name = "comment", type = ErmDataType.Text)
check(expression = "rating BETWEEN 1 AND 5", name = "rating_range")
}
relationship(from = customer, to = address, name = "has", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = category,
to = category,
name = "subcategory of",
sourceRole = "parent",
targetRole = "child",
sourceCardinality = Cardinality.ZERO_ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(from = category, to = product, name = "groups", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = order, name = "places", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = address,
to = order,
name = "bills",
targetRole = "billing",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = address,
to = order,
name = "ships",
targetRole = "shipping",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = order,
to = orderItem,
name = "contains",
kind = RelationshipKind.IDENTIFYING,
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ONE_MANY,
)
relationship(from = product, to = orderItem, name = "ordered as", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = payment, name = "paid by", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = review, name = "writes", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = product, to = review, name = "reviewed in", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = review, name = "reviewed via", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
view(
name = "active_orders",
query = "SELECT o.id, o.status, o.placed_at, c.email FROM \"order\" o JOIN customer c ON c.id = o.customer_id WHERE o.status != 'cancelled'",
references = listOf(order, customer),
)
diagram(name = "E-Commerce Schema (Chen)", notation = ErmNotation.CHEN, showIndexes = true)
}erm-idef1x-ecommerce.kuml.kts
// erm-idef1x-ecommerce.kuml.kts — synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/39 ERM Martin – E-Commerce Schema.md
// Do not edit by hand; update the vault note and re-sync.
ermModel("E-Commerce Schema") {
val customer =
entity("Customer") {
id()
attribute(name = "email", type = ErmDataType.Varchar(255), unique = true, nullable = false)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "created_at", type = ErmDataType.Timestamp(), default = "now()")
}
val address =
entity("Address") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
attribute(name = "street", type = ErmDataType.Varchar(255))
attribute(name = "city", type = ErmDataType.Varchar(120))
attribute(name = "zip", type = ErmDataType.Varchar(20))
}
val category =
entity("Category") {
id()
attribute(name = "name", type = ErmDataType.Varchar(120))
attribute(name = "parent_id", type = ErmDataType.Uuid, nullable = true)
}
val product =
entity("Product") {
id()
foreignKey(name = "category_id", references = category, nullable = false)
attribute(name = "sku", type = ErmDataType.Varchar(64), unique = true)
attribute(name = "name", type = ErmDataType.Varchar(255))
attribute(name = "price", type = ErmDataType.Decimal(10, 2), nullable = false)
check(expression = "price >= 0", name = "positive_price")
index("sku", unique = true, name = "idx_product_sku")
}
val order =
entity("Order") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
foreignKey(name = "billing_address_id", references = address, nullable = false)
foreignKey(name = "shipping_address_id", references = address, nullable = false)
attribute(name = "status", type = ErmDataType.Varchar(32), default = "'pending'")
attribute(name = "placed_at", type = ErmDataType.Timestamp(), default = "now()")
index("status", name = "idx_order_status")
}
val orderItem =
entity("OrderItem", weak = true) {
foreignKey(name = "order_id", references = order, onDelete = ReferentialAction.CASCADE, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
attribute(name = "quantity", type = ErmDataType.Integer(), nullable = false)
attribute(name = "unit_price", type = ErmDataType.Decimal(10, 2), nullable = false)
}
val payment =
entity("Payment") {
id()
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "amount", type = ErmDataType.Decimal(10, 2), nullable = false)
attribute(name = "method", type = ErmDataType.Varchar(32))
attribute(name = "paid_at", type = ErmDataType.Timestamp())
}
val review =
entity("Review") {
id()
foreignKey(name = "customer_id", references = customer, nullable = false)
foreignKey(name = "product_id", references = product, nullable = false)
foreignKey(name = "order_id", references = order, nullable = false)
attribute(name = "rating", type = ErmDataType.Integer(bits = 16), nullable = false)
attribute(name = "comment", type = ErmDataType.Text)
check(expression = "rating BETWEEN 1 AND 5", name = "rating_range")
}
relationship(from = customer, to = address, name = "has", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = category,
to = category,
name = "subcategory of",
sourceRole = "parent",
targetRole = "child",
sourceCardinality = Cardinality.ZERO_ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(from = category, to = product, name = "groups", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = order, name = "places", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(
from = address,
to = order,
name = "bills",
targetRole = "billing",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = address,
to = order,
name = "ships",
targetRole = "shipping",
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ZERO_MANY,
)
relationship(
from = order,
to = orderItem,
name = "contains",
kind = RelationshipKind.IDENTIFYING,
sourceCardinality = Cardinality.ONE,
targetCardinality = Cardinality.ONE_MANY,
)
relationship(from = product, to = orderItem, name = "ordered as", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = payment, name = "paid by", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = customer, to = review, name = "writes", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = product, to = review, name = "reviewed in", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
relationship(from = order, to = review, name = "reviewed via", sourceCardinality = Cardinality.ONE, targetCardinality = Cardinality.ZERO_MANY)
view(
name = "active_orders",
query = "SELECT o.id, o.status, o.placed_at, c.email FROM \"order\" o JOIN customer c ON c.id = o.customer_id WHERE o.status != 'cancelled'",
references = listOf(order, customer),
)
diagram(name = "E-Commerce Schema (IDEF1X)", notation = ErmNotation.IDEF1X, showIndexes = true)
}checkout-communication.kuml.kts
communicationDiagram(name = "Place Order — Communication") {
val ui = role(classifierName = "Frontend", roleName = "ui")
val api = role(classifierName = "Backend", roleName = "api")
val db = role(classifierName = "OrderDB", roleName = "db")
message(from = ui, to = api, label = "submitOrder()")
message(from = api, to = db, label = "INSERT order")
message(from = db, to = api, label = "ok")
message(from = api, to = ui, label = "201 Created")
}tcp-handshake.kuml.kts
// uml-timing-tcp-handshake.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/21 UML Timing – TCP Handshake.md
// Do not edit by hand; update the vault note and re-run the sync.
timingDiagram(name = "TCP 3-Way Handshake") {
lifeline(name = "client", states = listOf("CLOSED", "SYN_SENT", "ESTABLISHED")) {
tick(t = 0, state = "CLOSED")
tick(t = 1, state = "SYN_SENT")
tick(t = 3, state = "ESTABLISHED")
}
lifeline(name = "server", states = listOf("LISTEN", "SYN_RCVD", "ESTABLISHED")) {
tick(t = 0, state = "LISTEN")
tick(t = 2, state = "SYN_RCVD")
tick(t = 3, state = "ESTABLISHED")
}
}order-checkout-overview.kuml.kts
// uml-interaction-overview-order-checkout.kuml.kts — auto-synced from vault example
// Source of truth: 03 Bereiche/kUML/Beispiele/22 UML Interaction Overview – Order Process.md
// Do not edit by hand; update the vault note and re-run the sync.
interactionOverviewDiagram(name = "Order Process Overview") {
val start = initial()
val login = interactionRef(name = "Login")
val search = interactionRef(name = "Search Catalog")
val checkout = interactionRef(name = "Checkout")
val notify = interactionRef(name = "Ship Notification")
val end = final()
edge(from = start, to = login)
edge(from = login, to = search)
edge(from = search, to = checkout)
edge(from = checkout, to = notify)
edge(from = notify, to = end)
}banking-containers.kuml.kts
c4Model(name = "Minimal Banking System") {
val customer = person(name = "Customer")
val bankSystem = softwareSystem(name = "Internet Banking") {
container(name = "Web App") {
technology = "Kotlin/Ktor"
}
container(name = "API Server") {
technology = "Kotlin/Spring Boot"
}
}
val emailService = softwareSystem(name = "Email Service") {
external = true
}
relationship(source = customer, target = bankSystem) { technology = "HTTPS" }
relationship(source = bankSystem, target = emailService) { technology = "SMTP" }
containerDiagram(name = "Banking — Container View") {
system = bankSystem
showExternalSystems = true
}
}enterprise-banking-landscape.kuml.kts
import dev.kuml.c4.dsl.c4Model
c4Model(name = "Enterprise Banking Landscape") {
// Persons / Roles
val customer = person(name = "Customer") {
description = "A customer using banking services"
}
val admin = person(name = "Administrator") {
description = "System administrator managing banking infrastructure"
}
// Software Systems
val mainBanking = softwareSystem(name = "Main Banking System") {
description = "Handles customer accounts, transfers, and payments"
}
val creditCard = softwareSystem(name = "Credit Card System") {
description = "Manages credit card operations and billing"
}
val loan = softwareSystem(name = "Loan Management System") {
description = "Manages loan applications and disbursements"
}
val emailService = softwareSystem(name = "Email Service") {
description = "Sends transactional and marketing emails"
external = true
}
val smsService = softwareSystem(name = "SMS Notification Service") {
description = "Sends SMS alerts and notifications"
external = true
}
// Relationships
relationship(source = customer, target = mainBanking) { description = "Uses" }
relationship(source = customer, target = creditCard) { description = "Manages credit cards" }
relationship(source = customer, target = loan) { description = "Applies for loans" }
relationship(source = admin, target = mainBanking) { description = "Administers" }
relationship(source = admin, target = creditCard) { description = "Administers" }
relationship(source = mainBanking, target = emailService) { description = "Sends notifications via" }
relationship(source = mainBanking, target = smsService) { description = "Sends alerts via" }
relationship(source = creditCard, target = emailService) { description = "Sends billing statements via" }
relationship(source = loan, target = emailService) { description = "Sends approval letters via" }
// System Landscape Diagram — shows all systems and persons
systemLandscapeDiagram(name = "Enterprise Banking Landscape") {
description = "High-level overview of all systems and users in the banking enterprise"
}
}order-fulfillment.kuml.kts
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "Order Fulfillment") {
process(id = "p_order", name = "Order Process") {
val start = startEvent(name = "Order Received", definition = EventDefinition.MESSAGE)
val check = task(name = "Check Stock", type = TaskType.SERVICE)
val gw = gateway(type = GatewayType.EXCLUSIVE, name = "In Stock?")
val ship = task(name = "Ship Order", type = TaskType.USER)
val notify = task(name = "Notify Customer", type = TaskType.SEND)
val reject = task(name = "Reject Order", type = TaskType.SEND)
val endOk = endEvent(name = "Order Shipped")
val endFail = endEvent(name = "Order Rejected")
sequenceFlow(from = start, to = check)
sequenceFlow(from = check, to = gw)
sequenceFlow(from = gw, to = ship, condition = "stock > 0", name = "Yes")
sequenceFlow(from = gw, to = reject, condition = "stock == 0", name = "No")
sequenceFlow(from = ship, to = notify)
sequenceFlow(from = notify, to = endOk)
sequenceFlow(from = reject, to = endFail)
}
diagram(name = "Order Fulfillment", processId = "p_order")
}document-review.kuml.kts
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "Document Review") {
process(id = "p_review", name = "Review Process") {
val start = startEvent(name = "Document Submitted")
val review = subProcess(name = "Review Cycle", expanded = true) {
val rStart = startEvent(name = "Start Review")
val read = task(name = "Read Document", type = TaskType.USER)
val decide = gateway(type = GatewayType.EXCLUSIVE, name = "OK?")
val approve = endEvent(name = "Approved")
val revise = task(name = "Request Revision", type = TaskType.USER)
val rEnd = endEvent(name = "Revision Requested")
sequenceFlow(from = rStart, to = read)
sequenceFlow(from = read, to = decide)
sequenceFlow(from = decide, to = approve, condition = "approved")
sequenceFlow(from = decide, to = revise, condition = "needs_revision")
sequenceFlow(from = revise, to = rEnd)
}
val timer = boundaryEvent(attachedTo = review, name = "Deadline", definition = EventDefinition.TIMER)
val expired = endEvent(name = "Review Expired", definition = EventDefinition.TERMINATE)
val done = endEvent(name = "Review Complete")
sequenceFlow(from = start, to = review)
sequenceFlow(from = review, to = done)
sequenceFlow(from = timer, to = expired)
}
diagram(name = "Document Review", processId = "p_review")
}customer-supplier-collaboration.kuml.kts
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "Customer-Supplier Collaboration") {
process(id = "p_customer", name = "Customer") {
val placeOrder = startEvent(name = "Place Order", definition = EventDefinition.MESSAGE)
val waitShip = task(name = "Wait for Shipment", type = TaskType.RECEIVE)
val receive = task(name = "Receive Goods", type = TaskType.USER)
val endOk = endEvent(name = "Order Complete")
sequenceFlow(from = placeOrder, to = waitShip)
sequenceFlow(from = waitShip, to = receive)
sequenceFlow(from = receive, to = endOk)
}
process(id = "p_supplier", name = "Supplier") {
val receiveOrder = startEvent(name = "Receive Order", definition = EventDefinition.MESSAGE)
val pick = task(name = "Pick & Pack", type = TaskType.MANUAL)
val ship = task(name = "Ship Goods", type = TaskType.SERVICE)
val endShipped = endEvent(name = "Goods Shipped", definition = EventDefinition.MESSAGE)
sequenceFlow(from = receiveOrder, to = pick)
sequenceFlow(from = pick, to = ship)
sequenceFlow(from = ship, to = endShipped)
}
collaboration(name = "Order Flow", id = "collab_1") {
pool(name = "Customer", id = "pool_customer") { process(processId = "p_customer") }
pool(name = "Supplier", id = "pool_supplier") { process(processId = "p_supplier") }
messageFlow(from = "p_customer_start_1", to = "p_supplier_start_1", name = "Purchase Order")
messageFlow(from = "p_supplier_end_1", to = "p_customer_task_1", name = "Shipping Notification")
}
collaborationDiagram(name = "Customer-Supplier", collaborationId = "collab_1")
}blueprint-pdv-mitglieder-journey.kuml.kts
blueprint("PdV Mitglieder-Journey") {
// ── Akteure ──
val interessent = actor("Interessent", ActorRole.CUSTOMER)
val mitgliederbuero = actor("Mitgliederbüro", ActorRole.STAFF)
val crm = actor("Mitglieder-CRM", ActorRole.SYSTEM)
val landesverband = actor("Landesverband", ActorRole.PARTNER)
// ── Kanäle ──
val web = channel("pdv.de", ChannelKind.WEB)
val social = channel("Social Media", ChannelKind.SOCIAL)
val mailC = channel("E-Mail", ChannelKind.EMAIL)
val personC = channel("Stammtisch", ChannelKind.IN_PERSON)
// ── Touchpoints (vor den Phasen deklariert) ──
val socialPost = touchpoint("Social-Post", channel = social)
val kampagne = touchpoint("Kampagne", channel = social)
val programmSeite = touchpoint("Programm-Seite", channel = web)
val newsletter = touchpoint("Newsletter-Anmeldung", channel = web)
val onlineAntrag = touchpoint("Online-Antrag", channel = web)
val bestaetigung = touchpoint("Bestätigungs-Mail", channel = mailC)
val willkommensMail = touchpoint("Willkommens-Mail", channel = mailC)
val ausweis = touchpoint("Mitgliedsausweis", channel = mailC)
val stammtisch = touchpoint("Lokaler Stammtisch", channel = personC)
val eventEinladung = touchpoint("Event-Einladung", channel = mailC)
// ── Phase 1: Entdeckung ──
phase("Entdeckung") {
customer("Stößt auf PdV-Inhalt", Sentiment.NEUTRAL, touchpoints = listOf(socialPost))
frontstage("Liefert Content & Werbung", actor = mitgliederbuero, touchpoints = listOf(kampagne))
support("Trackt Reichweite", actor = crm)
}
// ── Phase 2: Interessenbekundung ──
phase("Interessenbekundung") {
customer("Besucht Website, liest Programm", Sentiment.POSITIVE, touchpoints = listOf(programmSeite))
frontstage("Bietet Newsletter & Infomaterial", actor = mitgliederbuero, touchpoints = listOf(newsletter))
backstage("Qualifiziert Lead", actor = mitgliederbuero)
support("Speichert Interessent", actor = crm)
}
// ── Phase 3: Antragstellung ──
phase("Antragstellung") {
customer("Füllt Beitrittsantrag aus", Sentiment.NEUTRAL,
touchpoints = listOf(onlineAntrag), pain = "Formular wirkt lang")
frontstage("Bestätigt Eingang", actor = mitgliederbuero, touchpoints = listOf(bestaetigung))
backstage("Prüft Angaben & Beitrag", actor = mitgliederbuero)
support("Legt Mitgliedsdatensatz an", actor = crm)
}
// ── Phase 4: Beitrittsprozess (Tal der Tränen) ──
phase("Beitrittsprozess") {
customer("Wartet auf Aufnahme", Sentiment.NEGATIVE, pain = "Unklar, wie lange es dauert")
backstage("Beschließt Aufnahme im Vorstand", actor = mitgliederbuero)
support("Weist Landesverband zu", actor = landesverband)
}
// ── Phase 5: Willkommen ──
phase("Willkommen") {
customer("Erhält Willkommenspaket", Sentiment.VERY_POSITIVE, touchpoints = listOf(willkommensMail))
frontstage("Versendet Willkommenspaket", actor = mitgliederbuero, touchpoints = listOf(ausweis))
support("Aktiviert Mitgliederbereich", actor = crm)
}
// ── Phase 6: Erstes Engagement ──
phase("Erstes Engagement") {
customer("Nimmt am Stammtisch teil", Sentiment.VERY_POSITIVE, touchpoints = listOf(stammtisch))
frontstage("Lädt zu Veranstaltungen ein", actor = landesverband, touchpoints = listOf(eventEinladung))
backstage("Matcht Mitglied zu lokaler Gruppe", actor = landesverband)
}
blueprintDiagram("PdV Service Blueprint", emotionCurve = true)
}bpmn-pdv-mitgliedsantrag-animiert.kuml.kts
// trace: 07 Anhänge/kUML/traces/bpmn-pdv-mitgliedsantrag.kuml.trace.v1.json
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "PdV Mitgliedsantrag") {
process(id = "p_antrag", name = "Mitgliedsantrag-Prozess") {
val start = startEvent(name = "Antrag eingegangen")
val pruefung = task(name = "Antrag-Prüfung", type = TaskType.SERVICE)
val gw = gateway(type = GatewayType.EXCLUSIVE, name = "Vollständig?")
val bestaetigung = task(name = "Bestätigung", type = TaskType.SEND)
val nachforderung = task(name = "Nachforderung", type = TaskType.SEND)
val endOk = endEvent(name = "Mitglied bestätigt")
val endNachf = endEvent(name = "Nachforderung gesendet")
sequenceFlow(from = start, to = pruefung)
sequenceFlow(from = pruefung, to = gw)
sequenceFlow(from = gw, to = bestaetigung, condition = "vollständig == true", name = "Ja")
sequenceFlow(from = gw, to = nachforderung, condition = "vollständig == false", name = "Nein")
sequenceFlow(from = bestaetigung, to = endOk)
sequenceFlow(from = nachforderung, to = endNachf)
}
diagram(name = "PdV Mitgliedsantrag", processId = "p_antrag")
}stm-traffic-light-animiert.kuml.kts
// trace: 07 Anhänge/kUML/traces/traffic-light.kuml.trace.v1.json
stateDiagram(name = "Traffic Light") {
val initial = initialState()
val red = state(name = "Red") { entry = "activateRed()" }
val green = state(name = "Green") { entry = "activateGreen()" }
val yellow = state(name = "Yellow") { entry = "activateYellow()" }
val off = finalState(name = "Off")
transition(source = initial, target = red)
transition(source = red, target = green) {
trigger = "timerGreen"
guard = "[cycleActive]"
}
transition(source = green, target = yellow) {
trigger = "timerYellow"
}
transition(source = yellow, target = red) {
trigger = "timerRed"
guard = "[cycleActive]"
}
transition(source = yellow, target = off) {
trigger = "powerOff"
guard = "[!cycleActive]"
}
}blueprint-notes.kuml.kts
import dev.kuml.blueprint.dsl.blueprint
import dev.kuml.blueprint.model.ActorRole
import dev.kuml.blueprint.model.Sentiment
blueprint(name = "Service") {
val staff = actor(name = "Staff", role = ActorRole.STAFF)
lateinit var fill: String
lateinit var check: String
phase(name = "Request") {
fill = customer(name = "Fills in the form", sentiment = Sentiment.NEUTRAL)
check = backstage(name = "Checks the data", actor = staff)
}
phase(name = "Admission") {
customer(name = "Waits", sentiment = Sentiment.NEGATIVE)
}
note("ASSUMPTION A1: the form is digital", fill, check, id = "n1")
note("Free-standing note", id = "free")
blueprintDiagram(name = "Blueprint", emotionCurve = false)
}c4-context-notes.kuml.kts
import dev.kuml.c4.dsl.c4Model
c4Model(name = "Shop") {
val user = person(name = "User")
val shop = softwareSystem(name = "Shop")
val pay = softwareSystem(name = "Payment") { external = true }
relationship(source = user, target = shop) { description = "uses" }
relationship(source = shop, target = pay) { description = "pays via" }
note("ASSUMPTION A1: payment is external", shop)
note("Between two", user, pay, id = "twoNote")
systemContextDiagram(name = "Context") {
include(user, shop, pay)
note("Free-standing note in the diagram", id = "freeNote")
}
}sysml2-act-partition-note.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Orders") {
val customer = activityPartition("Customer")
val system = activityPartition("OrderSystem")
val place = actionDef(name = "PlaceOrder", partition = customer)
val validate = actionDef(name = "ValidateOrder", partition = system)
controlFlow(name = "p2v", source = place, target = validate)
comment(text = "The customer is always a registered user.", firstAnchor = customer, id = "nl")
actDiagram("Orders") {
include(place)
include(validate)
}
}sysml2-ibd-port-connection-notes.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Hybrid") {
val powerLine = connectionDef("PowerLine")
val dcPort = portDef("DcPort")
val battery = partDef("Battery") { port(name = "dcOut", typeId = dcPort.id) }
val motor = partDef("ElectricMotor") { port(name = "dcIn", typeId = dcPort.id) }
val hybrid = partDef("HybridVehicle") {
part(name = "battery", typeId = battery.id)
part(name = "electricMotor", typeId = motor.id)
connect(
name = "batteryToMotor",
typeId = powerLine.id,
sourceEndId = "HybridVehicle::battery::dcOut",
targetEndId = "HybridVehicle::electricMotor::dcIn",
)
}
comment(text = "DC, 400 V", "Battery::dcOut", id = "np")
comment(text = "Fused at 200 A", "HybridVehicle::batteryToMotor", id = "nc")
comment(text = "Owner note", "HybridVehicle", id = "no")
ibd("Hybrid wiring", owner = hybrid)
}sysml2-par-nested-note.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Physics") {
val outer = constraintDef("Outer", expression = "a == b")
val inner = constraintDef("Inner", expression = "c == d", parent = outer)
comment(text = "Holds only for rigid bodies.", firstAnchor = inner, id = "nn")
parDiagram("Physics") {
include(outer)
include(inner)
}
}sysml2-req-multi-notes.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Reqs") {
val boot = requirementDef(name = "Boot", text = "The platform shall boot within 5 seconds.")
val update = requirementDef(name = "Update", text = "Updates shall install without user interaction.")
comment(text = "Measured from power-on.", firstAnchor = boot, id = "n1")
comment(text = "See the update policy.", firstAnchor = update, id = "n2")
reqDiagram("Reqs") {
include(boot)
include(update)
comment(text = "Free note one", id = "f1")
comment(text = "Free note two", id = "f2")
}
}sysml2-seq-lifeline-note.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Ping") {
val a = lifelineDef("A")
val b = lifelineDef("B")
val c = lifelineDef("C")
message(label = "ping", source = a, target = b, seqNo = 0)
message(label = "pong", source = b, target = c, seqNo = 1)
comment(text = "B is the inner lifeline.", firstAnchor = b, id = "nb")
seqDiagram("Ping") {
include(a)
include(b)
include(c)
}
}sysml2-stm-transition-note.kuml.kts
import dev.kuml.sysml2.dsl.sysml2Model
sysml2Model("Door") {
val closed = stateDef("Closed", isInitial = true)
val open = stateDef("Open")
transition(name = "t1", source = closed, target = open, trigger = "openCmd")
val t2 = transition(name = "t2", source = open, target = closed, trigger = "closeCmd")
stmDiagram("Door") {
include(closed)
include(open)
comment(text = "Closing is only allowed when nothing blocks the door.", firstAnchor = t2, id = "nt")
}
}bpmn-choreography-bestellprozess.kuml.kts
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "Bestellprozess Choreographie") {
val chId = choreography(id = "order_choreo", name = "Bestellung") {
val start = startEvent(name = "Bedarf erkannt")
val bestellung = task(
name = "Bestellung aufgeben",
initiatingParticipant = "Kunde",
participants = arrayOf("Kunde", "Händler"),
) {
message(name = "Bestellanfrage", participantRef = "Kunde", isInitiating = true)
message(name = "Auftragsbestätigung", participantRef = "Händler", isInitiating = false)
}
val gw = gateway(type = GatewayType.EXCLUSIVE, name = "Auf Lager?")
val nachbestellung = task(
name = "Nachbestellen",
initiatingParticipant = "Händler",
participants = arrayOf("Händler", "Lieferant"),
) {
message(name = "Nachbestellung", participantRef = "Händler", isInitiating = true)
message(name = "Lieferzusage", participantRef = "Lieferant", isInitiating = false)
}
val lieferung = task(
name = "Lieferung",
initiatingParticipant = "Händler",
participants = arrayOf("Händler", "Kunde"),
) {
message(name = "Versandbenachrichtigung", participantRef = "Händler", isInitiating = true)
}
val end = endEvent(name = "Bestellung abgeschlossen")
sequenceFlow(from = start, to = bestellung)
sequenceFlow(from = bestellung, to = gw)
sequenceFlow(from = gw, to = lieferung, condition = "auf Lager", name = "Ja")
sequenceFlow(from = gw, to = nachbestellung, condition = "nicht auf Lager", name = "Nein")
sequenceFlow(from = nachbestellung, to = lieferung)
sequenceFlow(from = lieferung, to = end)
}
choreographyDiagram("Bestellprozess-Choreographie", choreographyId = chId)
}bpmn-conversation-pdv.kuml.kts
import dev.kuml.bpmn.dsl.*
import dev.kuml.bpmn.model.*
bpmnModel(name = "PdV Kommunikation") {
val convId = conversation(id = "pdv_conv", name = "PdV-Interaktionen") {
val mitglied = participant("Mitglied")
val vorstand = participant("Vorstand")
val netzwerk = participant("Netzwerk")
val oeffentlich = participant("Öffentlichkeit")
// Konversationsknoten (Hexagons)
val beitritt = node("Beitrittsantrag", mitglied, vorstand)
val kampagne = node("Wahlkampagne", vorstand, netzwerk)
val presse = node("Pressekommunikation", vorstand, oeffentlich)
val vernetzung = node("Mitglieder-Vernetzung", mitglied, netzwerk)
// Conversation Links (ungerichtet)
link(mitglied, beitritt)
link(vorstand, beitritt)
link(vorstand, kampagne)
link(netzwerk, kampagne)
link(vorstand, presse)
link(oeffentlich, presse)
link(mitglied, vernetzung)
link(netzwerk, vernetzung)
}
conversationDiagram("PdV-Kommunikationsübersicht", conversationId = convId)
}uml-sequence-api-submit-animiert.kuml.kts
// trace: 07 Anhänge/kUML/traces/sequence-api-submit.kuml.trace.v1.json
sequenceDiagram(name = "Place Order — API Submit") {
val customer = lifeline(name = "Customer") { isActor = true }
val frontend = lifeline(name = "Frontend")
val backend = lifeline(name = "Backend")
val db = lifeline(name = "OrderDB")
message(from = customer, to = frontend, label = "submitOrder()")
message(from = frontend, to = backend, label = "POST /orders")
alt {
branch(guard = "[valid]") {
message(from = backend, to = db, label = "INSERT order")
reply(from = db, to = backend, label = "ok")
reply(from = backend, to = frontend, label = "201 Created")
}
branch(guard = "[invalid]") {
reply(from = backend, to = frontend, label = "400 Bad Request")
}
}
reply(from = frontend, to = customer, label = "confirmation")
}Scroll to zoom, drag to pan — Esc to close