Meetup Paris TypeScript #19 - CQRS with Nest.js

Meetup Paris TypeScript #19 - CQRS with Nest.js

Quick presentation of CQRS with a demo (Nest.js & CosmosDB)

Content based on the presentation I did during the GAB Rennes 2019 (https://speakerdeck.com/spontoreau/microservices-azure-cosmos-db-to-rule-them-all)

9298dcce5b2b0e88d8ffbb837192ca98?s=128

Sylvain Pontoreau

June 04, 2019
Tweet

Transcript

  1. Paris TypeScript June 4th 2019

  2. Premier Field Engineer @spontoreau In ❤️ with Co-organizer

  3. None
  4. Data Driven Development Domain Driven Design Domain Driven Development !=

    Data structure MCD CRUD Behavior Bounded Context Event
  5. Bounded context Independent Autonomous Loosely coupled

  6. Query Just a read operation Command Data validation Business logic

    Persistence CQRS
  7. CQRS GetOrderById Query UpdateProduct Command GetProducts Query DeleteOrder Command …

    … Dispatcher Dispatcher QueryHandler CommandHandler Validation Plugin Monitoring Plugin Telemetry Plugin … Eventual consistency
  8. Consistency • All system nodes needs to manipulate exactly the

    same data at the same time. Availability Partition tolerance • Requests must succeed. • Node failure must not create a complete system failure. A distributed system can only guarantee 2 constrains at the same time, not 3… you have to embrace eventual consistency when building Microservices! Eventual consistency?
  9. https://martinfowler.com/eaaDev/EventSourcing.html Event Sourcing

  10. CQRS & Event Sourcing GetOrderById Query UpdateProduct Command GetProducts Query

    DeleteOrder Command … … Dispatcher Dispatcher QueryHandler CommandHandler Projection Projection Aggregate State Events
  11. None
  12. Cosmos DB as an Event Store Read Enpoint Write Enpoint

    Event Store Projector Read DB publish trigger persist query
  13. Resources https://docs.microsoft.com/en-us/azure/cosmos-db/introduction https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-nodejs https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed https://medium.com/@thomasweiss_io/planet-scale-event-sourcing-with-azure- cosmos-db-48a557757c8d https://www.youtube.com/watch?v=5YNJpGwj_Zs https://docs.microsoft.com/en-US/azure/architecture/patterns/cqrs https://docs.microsoft.com/en-us/azure/architecture/patterns/event-sourcing https://docs.microsoft.com/en-

    us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/ https://docs.nestjs.com/recipes/cqrs https://gitpitch.com/jrouaix/cqrs-es-presentation/master#/ https://www.youtube.com/watch?v=qBLtZN3p3FU https://www.youtube.com/watch?v=LDW0QWie21s
  14. None
  15. None
  16. None