Skip to content

Reactive implementation of bank account example using spring reactor and DDD

License

Notifications You must be signed in to change notification settings

michalzeman/reactor-ddd

Repository files navigation

Bank account reactive DDD DEMO

This is the DDD reactive implementation of bank account example. The purpose of this demo is to demonstrate how to deal with data consistence in the reactive implementation using DDD (domain driven design) principles.

List of design patterns used in this demo

  • DDD
  • message driven architecture
  • event sourcing
  • CQRS

Technologies

This demo is implemented using Spring reactor project.

The implementation consists by two aggregates

  • Account
  • Transaction

Those two aggregate roots representing two bounded contexts Account bounded context and Transaction bounded context.

Supported operation by Account aggregate

account-domain-api module contains definition of contract provided by Account aggregate. Here is the list of basic operations:

  • create account
  • deposit money
  • withdraw money

Supported operation by Transaction aggregate

transaction-domain-api module contains definition of contract provided by Transaction aggregate Here is the list of basic operations:

  • create transaction
  • cancel/rollback transaction
  • finish transaction
  • transfer money between two accounts

Persistence

Implementation is following CQRS and event sourcing design pattern. Persistence API is provided by common-persistence-api. This module provides in memory storage for:

  • events generated by particular aggregate AggregateRepositoryImpl
  • storage for view model ViewRepositoryImpl

Business case representing of data consistency

  • Create two accounts A and B with specific amount of money
  • Create the transaction for transferring specific amount of money from account A to account B
  • Transaction finished: successfully or failed

Transaction is successful

  • Transaction closes and informs about result.

Transaction failed:

Failed due to account A doesn't have enough amount

  • Transaction closes and informs about result.

Failed due to account B doesn't exist

  • Transaction returns money to account A
  • Transaction closes and informs about result.

Failed due to cancellation

  • If money were withdrawn from account A -> money returns to account A
  • Transaction closes and informs about cancellation.

Releases

No releases published

Packages

No packages published

Languages