reSolve is a framework for developing apps based on CQRS and Event Sourcing using React + Redux on the client. It can help negate differences between your domain and technical languages, and focus on your application code.
reSolve is a set of libraries which can be used independently or simultaneously. Each library is responsible for a particular CQRS + Event Sourcing system part as shown in the image below.
This scheme is based on the "CQRS with Event Sourcing" image from the Event Sourcing for Functional Programmers presentation.
When you need to change the system's state, you send a Command. A command is addressed to a Domain Aggregate. An Aggregate is a cluster of logically related objects, containing enough information to perform a command as one transaction. It handles a command, checks whether it can be executed and generates an event to change the system's state. A new event is sent to Event Store. Refer to DDD_Aggregates or DDD, Event Sourcing, and CQRS Tutorial: design for more information on aggregates.
The resolve-command library allows you to handle commands and send produced events to the event store based on aggregate definitions and their commands. All aggregates are passed to resolve-command
as an array. The library creates an Aggregate Repository and finds or instantiates a particular aggregate to handle each command.
You can send a command on the client side by dispatching a redux action of the appropriate type. To do this, use the sendComand from the resolve-redux package.
Refer to package documentation for an example of resolve-command
usage.
The Event Store stores all events aggregates produce and delivers them to subscribers. It combines a persistent storage and message bus.
reSolve provides the resolve-es package containing the event store implementation, as well as storage-adapters and bus-adapters allowing you to specify where to store and how to send events.
The Read Model represents a system state or its part. It is built using Projection functions. All events from the beginning of time are applied to a read model to build its current state.
View model is a read model or part of it that represent a part of UI state and can live on client. It can be updated by Redux reducer function on the client and on the server.
Queries are used to get data from a read model and view model.
See Event Sourcing - Projections or DDD, Event Sourcing, and CQRS Tutorial: read models for more information.
You can use resolve-query as a query. This package allows you to obtain data from a read model by a GraphQL request.
Refer to package documentation for an example of resolve-query
usage.
Learn more about related concepts:
- Why using DDD, CQRS and Event Sourcing
- Education course for DDD (Domain Driven Design)
- Building Scalable Applications Using Event Sourcing and CQRS
- Blog about DDD
- Immutability Changes Everything
Note: Installing a package globally may require administrative privileges. That means you have to use the sudo command for Unix-based systems or run a terminal with administrative privileges on Windows systems.
Create a new reSolve application using the create-resolve-app package.
npm i -g create-resolve-app
create-resolve-app my-resolve-app
cd my-resolve-app
npm run dev
The application will be opened in your browser at http://localhost:3000/.
Refer to the reSolve Getting Started Guide for detailed information on how to create a new reSolve application and all the available scripts.
reSolve includes the following libraries which can be used independently or simultaneously.
App generator libraries:
- 🚀 create-resolve-app
Creates a new application based on reSolve.
Core libraries:
-
📢 resolve-command
Creates a function to execute a command. -
🏣 resolve-es
Provides an event store implementation. -
🔍 resolve-query
Creates a function to execute a query. -
🔩 resolve-redux
Helper for creating the Redux storage.
Adapters for event store:
-
🚌 Bus adapters specifying how to send events:
- resolve-bus-memory (recommended for debugging purposes)
- resolve-bus-rabbitmq
- resolve-bus-zmq
-
🛢 Storage adapters specifying where to store events:
-
resolve-scripts-with-router-2
resolve-scripts-with-router-4
These examples show how to useresolve-scripts
with thereact-router v2.x.x
andreact-router v4.x.x
. -
two-level todo list
This example is an application with several aggregate types related to each other. It also shows how to implement a custom backend API server.
- Report bugs and request features on our issues page.
- Code released under the MIT license.
- reSolve is developed by Developer Express Inc. (https://devexpress.com)
- Learn how to make Hacker News application