A demo/example project for the imaginary restaurant and order management. It is backing the Fmodel Reference Guide.
It demonstrates how to run our unique domain and orchestrate it in an EventSourced/EventDriven way.
this blueprint is an outcome of the event-modeling process
This project is using Fmodel - Kotlin, multiplatform library.
Fmodel is:
- enabling functional, algebraic and reactive domain modeling with Kotlin programming language.
- 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.
- enabling illustrating requirements using examples
- the requirements are presented as scenarios.
- a scenario is an example of the system’s behavior from the users’ perspective,
- and they are specified using the Given-When-Then structure to create a testable/runnable specification
- Given
< some precondition(s) / events >
- When
< an action/trigger occurs / commands>
- Then
< some post condition / events >
- Given
Check the tests!
with(orderDecider) {
givenEvents(listOf(orderCreatedEvent)) { // PRE CONDITIONS
whenCommand(createOrderCommand) // ACTION
} thenEvents listOf(orderRejectedEvent) // POST CONDITIONS
}
This project is using PostgreSQL powered event store, optimized for event sourcing and event streaming.
Fstore-SQL is enabling event-sourcing and pool-based event-streaming patterns by using SQL (PostgreSQL) only.
event-sourcing
data pattern (by using PostgreSQL database) to durably store events- Append events to the ordered, append-only log, using
entity id
/decider id
as a key - Load all the events for a single entity/decider, in an ordered sequence, using the
entity id
/decider id
as a key - Support optimistic locking/concurrency
- Append events to the ordered, append-only log, using
event-streaming
to concurrently coordinate read over a streams of events from multiple consumer instances- Support real-time concurrent consumers to project events into view/query models
- EventModeling - a method of describing systems using an example of how information has changed within them over time.
- EventSourcing
- CQRS
- Fmodel - Domain modeling with Kotlin
- Ktor (HTTP)
- Kotlin (Coroutines, Serialization)
- Arrow (Fx Coroutines, ...)
- Postgres (event store, projections)
This project is using Gradle as a build and automation tool.
./gradlew check
Make sure you have Postgres installed and running.
Alternatively, you can use Docker to run PostgreSQL.
docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
Check the connection URL in application environment variables
./gradlew run
Make sure you have Docker installed and running.
Build OCI (docker) image:
./gradlew publishImageToLocalRegistry
Run application and Postgres database:
docker-compose up
- Check the FModel reference guide
- Read the blog
- Learn by example on the playground
- Spring Boot version of this project.
Created with ❤️ by Fraktalio
Excited to launch your next IT project with us? Let's get started! Reach out to our team at info@fraktalio.com
to
begin the journey to success.