Git Product home page Git Product logo

trivago-cqrs-es-workshop-2017's Introduction

Basic CQRS and Event Sourcing with Prooph

This is an example application aimed at teaching basic event sourcing.

Requirements

To run this application, you will need:

Toolchain

The tools that we are going to use are:

Domain of the app

The domain of the application is quite limited, but sufficient to explain how and when to effectively use CQRS and EventSourcing.

The MVP of the application has following specification:

  • assume that each person interacting with the system has a badge with a username on it
  • assume that the username is given: we assume that the input data is already validated against existing users
  • track people entering (check-in) a building
  • track people leaving (check-out) a building
  • prevent people from double-entering a building (security concern)
  • prevent people from double-leaving a building (security concern)
  • allow querying a list of people that are currently in the building

Build steps

Following steps are to be implemented:

  • Ability to register a new building (already provided)
  • Ability to check-in with a username and a building identifier (skeleton code provided)
  • Ability to check-out with a username and a building identifier (skeleton code provided)
  • Provide console output (STDERR) every time a check-in happens (event handler)
  • Provide console output (STDERR) every time a check-out happens (event handler)
  • Provide a file per building (accessible via HTTP) with usernames of currently checked-in persons

Additional notes from the forker

  • Prevent people from double check-in
  • Prevent people from double check-out
  • Write BDD tests written in Gherkin for Behat
Proccess summary starting from a command until the domain event is being written
  1. Command (contains only a payload) is registered in the container
  2. Command registration returns a callable for latter execution
  3. Command gets passed to the CommandBus (web layer)
  4. CommandBus calls listener
  5. Listener executes code from the command registered callable
  6. Callable gets an aggregate and performs an action
  7. The action creates an domain event

Specify one "when" method per domain event, otherwise the framework will crash. These methods are for hydrating the aggregate from the event store.

Checking-in a user calls its "when" method:

  1. Before check-in. By getting aggregate that is going to be hydrated, thus can be called multiple times
  2. After check-in, one time again for ensuring the state change on this aggregate

trivago-cqrs-es-workshop-2017's People

Contributors

fabpico avatar ocramius avatar

Watchers

 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.