Skip to content

Build reactive apps with functional JavaScript, CQRS and Event Sourcing

License

Notifications You must be signed in to change notification settings

dirk-pieterse/resolve

 
 

Repository files navigation

Build Status npm version styled with prettier GitHub issues GitHub forks GitHub stars GitHub license Join the chat at https://gitter.im/reimagined/resolve

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.

📑 Table of Contents

🏗️ Basic Concepts

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.

CQRS schema
This scheme is based on the "CQRS with Event Sourcing" image from the Event Sourcing for Functional Programmers presentation.

Command and Aggregate

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.

Event Store

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.

Read Model, View Model and Query

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.

See Also

Learn more about related concepts:

🚀 Quick Installation

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

Terminal 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.

📚 Packages

reSolve includes the following libraries which can be used independently or simultaneously.

App generator libraries:

Core libraries:

Adapters for event store:

💻 Examples

Development

Join us

About

Build reactive apps with functional JavaScript, CQRS and Event Sourcing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%