Intro
Domain modeling is a powerful tool for clarifying and refining our understanding of a subject area, and for identifying opportunities for optimization and improvement. By carefully considering the needs of stakeholders and the nature of the domain, it is possible to create effective and useful models that can facilitate communication and drive progress.
Fmodel aims to bring functional, algebraic and reactive domain modeling to Kotlin.
It is inspired by DDD, EventSourcing and Functional programming communities, yet implements these ideas and concepts in idiomatic Kotlin, which in turn makes our code
- less error-prone,
- easier to understand,
- easier to test,
- type-safe and
- thread-safe.
FModel promotes clear separation between data and behaviour:
- Data
Command
- An intent to change the state of the systemEvent
- The state change itself, a fact. It represents a decision that has already happened.State
- The current state of the system. It is evolved out of past events.
- Behaviour
Decide
- A pure function that takescommand
and currentstate
as parameters, and returns the flow of newevents
.Evolve
- A pure function that takesevent
and currentstate
as parameters, and returns the newstate
of the system.React
- A pure function that takesevent
as parameter, and returns the flow ofcommands
, deciding what to execute next.
The focus is on implementing robust information systems (back-end):
traditional - state-stored systems / storing the new
state
by overwriting the previousstate
.event-driven - event-sourced systems / storing the
events
in immutable storage by only appending.or you can have both flavors within your systems landscape, and easily transit from one to another
What you'll need
- Java version 11 or above.
Getting Started
Get started by including dependencies.
All Fmodel libraries are Multiplatform-ready, so you can use them in all of your KMP projects.
Enable the Maven Central repository
Fmodel is published in Maven Central, so you need to enable it as a source of dependencies in your build.
- Gradle (Kotlin)
- Gradle (Groovy)
- Maven
repositories {
mavenCentral()
}
repositories {
mavenCentral()
}
Maven includes the Maven Central repository by default.
Include the dependencies
You're now ready to include Fmodel in your project.
- Gradle (Kotlin)
- Gradle (Groovy)
- Maven
dependencies {
implementation("com.fraktalio.fmodel:domain:3.5.0")
implementation("com.fraktalio.fmodel:application-vanilla:3.5.0")
implementation("com.fraktalio.fmodel:application-arrow:3.5.0")
}
dependencies {
implementation 'com.fraktalio.fmodel:domain:3.5.0'
implementation 'com.fraktalio.fmodel:application-vanilla:3.5.0'
implementation 'com.fraktalio.fmodel:application-arrow:3.5.0'
}
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>domain</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>application-vanilla</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>com.fraktalio.fmodel</groupId>
<artifactId>application-arrow</artifactId>
<version>3.5.0</version>
</dependency>
Create a new application
You have great frameworks at your service to bootstrap development:
- Ktor (check the demo applications)
- Spring (check the demo applications)
Fmodel does not require usage of any framework whatsoever. It is completely up to you!