Git Product home page Git Product logo

eventuate-examples-java-spring-todo-list's Introduction

Todo List example application

The Todo List application is the hello world application for the Eventuate™ Platform. It illustrates how you can use the platform to write an application that uses Event Sourcing and Command Query Responsibility Segregation (CQRS). The Todo List application lets users maintain a todo list.

The Todo List application is a Java and Spring Boot application built using Eventuate™'s Event Sourcing based programming model. Todos are implemented by an Event Sourcing-based TodoAggregate. The aggregate's events are persisted in the Eventuate event store. The application also maintains a materialized view of the data in MySQL.

Don't forget to take a look at the other Eventuate example applications.

Got questions?

Don't hesitate to create an issue or see

Architecture

The following diagram shows the Todo List application architecture:

The application consists of the following:

  • Todo List Server - a Java and Spring Boot-based server-side application that has a HATEAOS-style REST API for creating, updating and querying todo list items.
  • MySQL database - stores a materialized/denormalized view of todo list items.

Note: for simplicity, the Todo List service is deployed as a monolithic server but as you will see below, it consists of several independent modules.

Todo List Server design

The Todo List server has a Spring MVC-based REST API for creating, updating and querying todo list items. The Todo List server is written using the Eventuate Client Framework for Java, which provides an event sourcing based programming model. The server persists todo list items as events in the Eventuate event store. The Todo List server also maintains a materialized view of the todo list in MySQL.

The following diagram shows the design of the server:

The application is structured using the Command Query Responsibility Segregation (CQRS) pattern. It consists of the following modules:

  • Command-side module - it handles requests to create and update (e.g. HTTP POST, PUT and DELETE requests) todo list items. The business logic consists of event sourcing based Todo aggregates.

  • Query-side module - it handles query requests (ie. HTTP GET requests) by querying a MySQL materialized view that it maintains. It has an event handler that subscribes to Todo events and updates MySQL.

Two versions of the source code

There are two versions of the source code:

  • single-module - a single module Gradle project. It is the easiest to get started with.
  • multi-module - a multi-module Gradle project. It illustrates how to use multiple modules to separate the command side code from the query-side code.

Building and running the application

This is a Gradle project. However, you do not need to install Gradle since it will be downloaded automatically. You just need to have Java 8 installed.

The details of how to build and run the services depend slightly on whether you are using Eventuate SaaS or Eventuate Local.

Building and running using Eventuate SaaS

First, must sign up to get your credentials in order to get free access to the SaaS version.

Next, build the application

./gradlew assemble

Next, you can launch the services using Docker Compose:

docker-compose build
docker-compose up -d

Building and running using Eventuate Local

First, build the application

./gradlew assemble -P eventuateDriver=local

Next, launch the services using Docker Compose:

export DOCKER_HOST_IP=...
docker-compose -f docker-compose-eventuate-local.yml build
docker-compose -f docker-compose-eventuate-local.yml up -d

Note: You need to set DOCKER_HOST_IP before running Docker Compose. This must be an IP address or resolvable hostname. It cannot be localhost. See this guide to setting DOCKER_HOST_IP for more information.

Using the application

Once the application has started, you can use the application via the Swagger UI.

If you are running the multi-module version:

  • http://${DOCKER_HOST_IP}:8081/swagger-ui.html - the command-side service
  • http://${DOCKER_HOST_IP}:8082/swagger-ui.html - the query-side service

If you are running the single-module version:

  • http://${DOCKER_HOST_IP}:8080/swagger-ui.html - the monolithic application

Got questions?

Don't hesitate to create an issue or see

eventuate-examples-java-spring-todo-list's People

Contributors

cer avatar dartpopikyardo avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.