Introduction#

jeepito is a library that implement some Domain Driven Design approach that is popularised by the book Architecture Patterns With Python.

It encourage to create a domain model, by subclassing the class jeepito.Model, and by writing jeepito.Command and jeepito.Event.

jeepito.Model are stored and accessed via repositories. Every models has its own repository, a subclass of jeepito.AsyncAbstractRepository and those repositories are then gather in a Unit Of Work.

Mutations of the models are also part of the domain models, those mutations are store in specific objects, named Command and Event.

Commands are implemented by subclassing the jeepito.Command in order to discribe the intention of the mutation.

Events are implemented by subclassing the jeepito.Event in order to discribe that the mutation has happened.

Commands and events are versionned, the update of any format, that represent a Breaking Change is discouraged without creating a new version.

jeepito.Command and jeepito.Event are both jeepito.Message. And those messages can be listened by a service handler, in a jeepito.AsyncMessageBus using a decorator jeepito.async_listen().

Note

The jeepito.SyncMessageRegistry has to be used with the decorator jeepito.sync_listen() for the synchronous version.

During the startup of the app, all service handlers must be registered the message registry by calling the function jeepito.scan().

Afterwhat, the jeepito.AsyncMessageBus is ready to handle message using it function jeepito.AsyncMessageBus.handle(). you will have understood it, the jeepito.AsyncMessageBus is the message bus object.

Finally, when the unit of work commit its transaction, the a publisher object can send all the desired message to an Event Stream.

This is a bit condensed, but the essence of the event driven throw the message bus, is here. So lets get deeper going step by step in the cookbook.