ryanwold.net

A civic-minded citizen seeking the singularity

An entry

A general checklist for refactoring a CRUD system to an event-driven CQRS system

Series: Bitcoin
Date: 2023-02-07
Status: release
Tags: software patterns crud cqrs
This Entry is part of the Series Bitcoin.

Generic disclaimer: This is a general checklist and the specific steps for your project may vary based on the complexity and scale of your system.

  • Define the events: Identify the actions that take place in the system, such as "user created", "order placed", etc. These actions will be the events that drive the system.
  • Separate Read and Write models: Divide the existing CRUD models into separate read and write models to reflect the separation of concerns in a CQRS architecture.
  • Create Event Store: Store the events that occur in the system in a central event store.
  • Implement Command Handlers: Write handlers for each command that maps to an event and stores it in the event store.
  • Implement Event Handlers: Write handlers for each event that updates the read model and any relevant domain entities.
  • Create Query Handlers: Write handlers for each query that retrieves data from the read model.
  • Update API: Update the API to use commands and queries instead of CRUD operations.
  • Test and Validate: Test the system to make sure all the changes work as expected and validate the read and write models.
  • Deploy: Deploy the refactored event-driven CQRS system.
  • Monitor and Improve: Monitor the system for any issues and continuously improve it to meet evolving needs.