Skip to content

Fmodel demo - Functional and Algebraic Domain modeling - State stored flavour

License

Notifications You must be signed in to change notification settings

fraktalio/fmodel-spring-state-stored-demo

Repository files navigation

fmodel-spring-demo (StateStored)

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 a Traditional/State-Stored way.

For Event-Sourced flavor of the system, please check https://github.com/fraktalio/fmodel-spring-demo, and notice:

  • how the domain package/model is the same / state-stored system and event-sourced system share the same domain logic
  • application and adapters are different / we only choose to compose and run them differentlly

event model image this bleuprint is an outcome of the event-modeling process

Fmodel

This project is using Fmodel - Kotlin, multiplatform library.

Fmodel is:

  • enabling functional, algebraic and reactive domain modeling with Kotlin programming language.
  • inspired by DDD 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 >

Check the tests!

with(orderDecider) {
    givenEvents(listOf(orderCreatedEvent)) {         // PRE CONDITIONS
        whenCommand(createOrderCommand)              // ACTION
    } thenEvents listOf(orderRejectedEvent)          // POST CONDITIONS
}

Tools

  • EventModeling - a method of describing systems using an example of how information has changed within them over time.

Prerequisites

Technology

Spring (Reactive Web,R2DBC, RSocket)

Run & Test

This project is using Gradle as a build and automation tool.

Test:

./gradlew check

Run:

Make sure you have PostgreSQL installed and running. Check the connection URL and username/password in application.properties

./gradlew bootRun

Run in Docker

Make sure you have Docker installed and running.

Build OCI (docker) image:

./gradlew bootBuildImage

Run application and PostgreSQL:

docker-compose up

Explore the REST API

Explore the REST API using the test.http file.

Further Reading


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.