All tutorials
ADVANCED10 parts · Est. 10 hours

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.

KotlinBPMN
pC
Prashant Chaturvedi
Updated 2026-09-27
Start reading

Chapters

1

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.

9 min•2026-09-12
2

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.

5 min•2026-09-14
3

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.

5 min•2026-09-15
4

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.

6 min•2026-09-17
5

Part 5: Validation as a first-class feature

Build BpmnValidator — structured diagnostics for identifiers, flow semantics, gateways, lanes, collaboration, boundary events, and diagrams.

5 min•2026-09-19
6

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.

4 min•2026-09-20
7

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.

5 min•2026-09-22
8

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.

4 min•2026-09-24
9

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.

4 min•2026-09-25
10

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.

6 min•2026-09-27

Other Series

Type to search the site.

↑↓ navigate⏎ openPowered by Pagefind