Skip to content
/ 4dk Public

DDD framework with some features such as Logging, Authorization ...

License

Notifications You must be signed in to change notification settings

jultabary/4dk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

4dk

(Domain Driven Design Development Kit)

Presentation

This project proposes a framework to easily transpose an "Event Storming" into your code.
This framework is based on famous concept such as CQRS, Hexagonal Architecture, CommandBus pattern.
If you have never heard about "Domain Driven Design" or "Event Storming", you have to discover it. It will change your vision of software development.
This projects presents an implementation in Java and another in Rust

Objectives

Event storming is a tool to help you to identify your core business. One of the event storming (most famous strategic DDD tool) goal is to help you to design your domains.
At the end of your "event storming", the result will look such as something like this:

The next step is to transpose it into your code. (tactic DDD pattern)

Event Storming design the behaviours of your domains with commands and events.

These framework implements with bus all the successions rules between event storming "post it" :

To see "how to switch from events storming into the code" please follow basic samples (Java or Rust). You will see how an "events storming" could be your software design.

Command (Blue post-it):

Command object matches this post it.
A Command is handled by a unique CommandHandler.
A CommandHandler is a Clean Architecture Usecase which can only be triggered by its associated Command.
It returned a list of Event generated by the domain transaction.

Event (Orange post-it)

Event object matches this post it.
An Event is handled by one or several EventHandler.
An EventHandler is a Clean Architecture Usecase which can only be triggered by its associated event. Contrary to Command, Event can be associated to serveral EventHandler.

Policy (Purple post-it)

EventHandler object could match this post it.
More exactly, it will be the Clean Architecture Usecase which will trigger the policy rule from a specific event.

Query (Green post-it)

Query object could partially match this post it.
Query is a question ask to the system. In CQRS, we differentiate WriteModel and ReadModel. ReadModel is built with produced Event. An EventHandler could also be dedicated to build a ReadModel. Query asks a question to a ReadModel.

Features

Command

Features Description Java Rust
CommandDispatcher CommandBus which dispatches command to its associated CommandHandler X X
CommandLoggingMiddleware CommandBus which logs all command handled and events resulted by the transactionwhich X X
EventsProducedByCommandBusPersistenceMiddleware CommandBus which saves all events resulted by the transaction in an event store X
EventsProducedByCommandBusDispatcher CommandBus which dispatches resulted events to an EventBus X X
SecuredCommandDispatcher CommandDispatcher which dispatches SecuredCommands only if they have correct authorization X X

Query

Features Description Java Rust
QueryDispatcher QueryBus which dispatches query to its associated QueryHandler X X
QueryLoggingMiddleware QueryBus which logs all query handled and responses resulted X X
SecuredQueryDispatcher QueryDispatcher which dispatches SecuredQuery only if they have correct authorization X X

Event

Features Description Java Rust
EventDispatcher EventBus which dispatches event to its associated EventHandlers X X
EventHandlerLogger Add Logging to EventHandler X X

External Event

Features Description Java Rust
ExternalEventDispatcher ExternalEventBus which dispatches external event to its associated PolicyHandler X X
ExternalEventLoggingMiddleware ExternalEventBus which logs all external event handled and commands returned by policies X X
CommandProducedByExternalEventBusDispatcher Dispatch Command produced by ExternalEventBus to CommandBus X X