Coder Social home page Coder Social logo

jorzel / recruitment Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 61 KB

Playground app modelling candidate simple path in a recruitment process using Event Sourcing + CQRS

Python 100.00%
eventsourcing cqrs python3 python hexagonal-architecture port-and-adapters sqlalchemy learning-materials

recruitment's Introduction

Overview

Playground app modelling candidate simple path in a recruitment process implementing Event Sourcing(ES) + Command Query Resposibility Segregation (CQRS) concepts.

Command path is represented by Candidate aggregate. The aggregate is build on streams of sequential events, that are persisted (instead of persisting state itself). Query path is represented by CandidateProjection read model and is build by handling Candidate dispatched events.

Persistance

Aggregate state is reconstructed from stream of persisted StorageEvent (Event Sourcing). Each aggregate modification is manifested by specific type of DomainEvent dispatch. However all DomainEvent types are persisted in the same StorageEvent structure. Transformation between DomainEvent and StorageEvent is bidirectional and implemented by EventMapper class.

Read model synchronization options

  • LocalEventPublisher that is a simplified implementation of event bus. There is no message broker, published events are directly passed to event handlers.
  • CandidateProjection handler method called in use case method (in the same transaction as Candidate aggregate modification). However it increases coupling between Candidate aggreagte and CandidateProjection read model.
  • any implementation of real event bus / message broker (RabbitMQ, Kafka). Thanks to it, read model can be placed in other module / application / system, and update is eventually consistent

Solution architecture

Application Architecture is port and adapters.

  • secondary ports (interfaces) in application and domain layers
  • secondary adapters (implementations) in infrastructure layer
  • primary ports (application service and handlers) in application layer
  • primary adapter (API for incoming request) is not implemented

Development

The implementation is simplified and omits some important aspects like:

  • events versioning
  • concurrency version control
  • snapshoting of an aggregate
  • genuine event bus implementation
  • API to transport incoming requests

Huge part of this code was inspired by: https://breadcrumbscollector.tech/category/event-sourcing/

Install packages

>> pip install -r dev_requirements.txt

Run tests

>> PYTHONPATH=src pytest -x

recruitment's People

Contributors

jorzel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.