Building a Type-Safe Kotlin DSL for BPMN 2.0
Design a Kotlin internal DSL that compiles BPMN collaborations into an immutable AST, validates them, emits BPMN 2.0 semantic XML plus BPMN DI layout, and renders in standards-compatible viewers — with the buyer process deployable to Flowable.
Chapters
Part 1: Why build a Kotlin DSL for BPMN 2.0?
Why handwritten BPMN XML and visual modelers fall short for generated workflows — and the AST-first architecture this series builds around them.
Part 2: Modeling BPMN collaborations, pools, lanes, and flow nodes
Define the immutable BPMN AST — collaborations vs processes, participants vs pools, lanes as references, and a sealed flow-node type hierarchy.
Part 3: Designing a type-safe Kotlin DSL for BPMN
Turn the AST into a fluent internal DSL — lambdas with receivers, @DslMarker scope control, and builders that compile into immutable definitions.
Part 4: Modeling the procurement collaboration end to end
The full running example — two pools, six lanes, inclusive-gateway conditional approvals, SLA timers, renegotiation, and an exception subprocess.
Part 5: Validation as a first-class feature
Build BpmnValidator — structured diagnostics for identifiers, flow semantics, gateways, lanes, collaboration, boundary events, and diagrams.
Part 6: Generating BPMN 2.0 XML safely from the AST
Serialize the validated AST to BPMN 2.0 XML with StAX — namespaces, event definitions, condition expressions, and the engine-extension seam.
Part 7: Generating BPMN diagrams that actually render
Build a deterministic layered layout engine — flow-graph columns, lane rows, pinned boundary events, orthogonal routing — and emit BPMN DI XML.
Part 8: Testing BPMN semantics, DI, and visual output
Assert the real contract — every node shaped, every edge resolved, containment, determinism — then prove bpmn-js renders it without warnings.
Part 9: Deploying the generated buyer process to Flowable
Keep the core model engine-neutral — map DSL metadata to flowable:* via a serializer seam, and deploy only the executable buyer pool to Flowable.
Part 10: Turning the DSL into a maintainable workflow authoring library
Package the pipeline as a library — module boundaries, DSL versioning, extension seams, and the honest list of what was deliberately left out.