Skip to content
Son Luong Ngoc edited this page Dec 4, 2017 · 15 revisions

CQRS-bookstore Documentation

Goals and aim

This is not a full-fledged CQRS-application. We have made quite a few simplifications and cut a lot of corners in order to be able to paint the bigger picture without too much code and complicated setup.

This example application shows some ideas and implementation styles we have used when building CQRS/ES-systems for our clients. This includes:

  • REST-like API's for receiving commands/querying the system
  • Clear separation of the domain model and the data projections used for queries
  • Event-sourced aggregate roots
  • Handling of long-running processes using Sagas

Prerequisites

In order to build and run the example application you need:

  • Java 7
  • Maven 3.x

Application use cases

The application is a small bookstore where customers can buy books. There is also an admin interface where the owner of the bookstore can 'activate' orders and view the events in the application.

Getting Started

  1. Clone the repository

  2. Run mvn clean install

  3. Start the order service on port 8070 by running

    java -jar order-context-parent/order-application/target/order-application-1.0-SNAPSHOT.jar server order-context-parent/order-application/dev.yml

  4. Start the product catalog service on port 8090 by running

    java -jar product-catalog-context/target/product-catalog-context-1.0-SNAPSHOT.jar server product-catalog-context/dev.yml

  5. Start the shopping service on port 8080 by running

    java -jar shopping-context/target/shopping-context-1.0-SNAPSHOT.jar server shopping-context/dev.yml

  6. Load sample products into the catalog by running

    mvn -pl product-catalog-context exec:java -Dexec.mainClass="se.citerus.cqrs.bookstore.productcatalog.application.TestProductDataImporter" -Dexec.classpathScope="test"

  7. Load sample contracts into the order service by running

    mvn -pl order-context-parent/order-application exec:java -Dexec.mainClass="se.citerus.cqrs.bookstore.ordercontext.application.TestContractDataImporter" -Dexec.classpathScope="test"

  8. Access the bookstore web application at http://localhost:8080/index.html and the order management admin interface at http://localhost:8070/admin.html

Design