
kotlin-cor — Chain of Responsibility for Business Logic
kotlin-cor is a lightweight Kotlin Multiplatform library that brings Chain of Responsibility pattern to business logic orchestration. It allows you to write complex business processes as readable, declarative code — instead of XML schemas or visual BPM designers.
Niche & Purpose
kotlin-cor fills the gap between simple CoR pattern and full-blown workflow engines:
Primary Use Cases:
- Request handling pipelines (validation → authorization → processing → response)
- Business logic in microservices without external orchestration
- Projects requiring Kotlin Multiplatform (JVM + JS + Native)
- Teams wanting version control over business logic
Competitive Advantages
- Code-first — Business logic in Kotlin, not XML/BPMN
- No infrastructure — Just a library, no external servers
- KMP — Single codebase for all platforms (JVM, JS, Native, Wasm)
- Readable — Chain reads like documentation
- Extensible — Easy to add custom handlers
See docs/comparison.md for detailed analysis.
Quick Example
val chain = rootChain<BizContext> {
validate("Validate request") {
validateNotEmpty("Check ID not empty")
validateFormat("Check ID format")
}
authorize("Check access rights") {
fetchUserPermissions()
checkObjectAccess()
}
fetchData("Load business object")
respond("Prepare response")
}.build()
runBlocking { chain.exec(BizContext(request)) }
Key Features
- Human-readable — business logic reads like a specification
Installation
dependencies {
implementation("com.crowdproj:kotlin-cor:${VERSION}")
}
Documentation
Status
- Version: ${VERSION}
- Kotlin: 2.3.20
- Platforms: JVM, JS, Linux, iOS, macOS, tvOS, watchOS, Wasm, Windows, Android Native