A high-performance, event-driven application framework built entirely in Kotlin. KOFA leverages reactive programming, metaprogramming, and compiler plugins to separate business logic completely from infrastructure concerns.
- Pure Kotlin: 100% Kotlin implementation with native DSL support
- Event-Driven: Built for reactive, high-throughput event processing
- Zero Boilerplate: Compiler plugins generate all infrastructure code
- Modular: Components deploy independently at runtime
- High Performance: Optimized for low-latency applications with Aeron messaging
KOFA enforces a clean 3-tier architecture:
Layer | Responsibility |
---|---|
Application | Configuration, dependency declaration, runtime setup |
Business | Domain logic, event handlers, business rules |
Platform | Infrastructure, lifecycle management, event routing, performance optimization |
Create message definitions by XML file, annotation or Kotlin DSL, currently only xml domain definition is supported
<domain name="carnival">
<message name="Ping">
<field name="num" type="int"/>
</message>
<message name="Pong">
<field name="num" type="int"/>
</message>
</domain>
class MonkeyHandler(val config: MonkeyConfig) {
fun handle(event: PongEvent) {
// Your business logic here
println("Processing ${event.num}")
}
}
@DomainModule(componentType="Monkey", handler = MonkeyHandler::class)
class MonkeyModule {
fun config() = {
scoped{
MonkeyConfig()
}
}
}
Create application.conf
:
kofa {
domain = carnival
timezone = Asia/Shanghai
event-loop {
shutdown-timeout-seconds = 10
execution-policy = "wait"
sleepCycles = "10"
durationMillis = "1000"
}
event-stream {
mode = "live"
url = "aeron://carnival?embedded=true"
aeron {
channel = "aeron:ipc"
sessionId = 1
}
}
component {
Monkey: {
enabled = true
}
}
}
./gradlew examples:carnival:run --args='-c application-carnival.conf'
kofa/
├── platform/ # Core framework
│ ├── platform-api/ # Public APIs and annotations
│ ├── platform-core/ # Runtime implementation
│ ├── platform-codegen/ # Code generation
│ └── platform-launcher/ # Application launcher
├── examples/ # Sample applications
│ ├── carnival/ # Simple event handling demo
│ └── mds/ # Market data system example
└── build.gradle.kts # Kotlin DSL build configuration
Explore working examples in the examples/
directory:
- Carnival: Basic event handling with clowns and monkeys 🎪
- MDS: Real-world portfolio management system 📈
# Build all modules
./gradlew build
# Run specific example
./gradlew examples:mds:run --args='-c application-mds.conf'
- High-frequency trading systems
- Real-time data processing pipelines
- Event-driven microservices
- Low-latency messaging applications
- Backtesting and simulation engines