Code Monkey home page Code Monkey logo

tiny-event-sourcing-demo's Introduction

Tiny event sourcing library demo

This project demonstrates how easily you can build your event-driven, event sourcing based application POC in 15 minutes using Tiny Event Sourcing library

Run MongoDb

This example uses MongoDb as an implementation of the Event store. You can see it in pom.xml:

<dependency>
    <groupId>ru.quipy</groupId>
    <artifactId>tiny-mongo-event-store-spring-boot-starter</artifactId>
    <version>${tiny.es.version}</version>
</dependency>

Thus, you have to run MongoDb in order to test this example. We have docker-compose file in the root. Run following command to start the database:

docker-compose up

Run the application

To make the application run you can start the main class DemoApplication.

Test the endpoints

There are a couple of REST endpoints you can try to call.

To create new Project with name "Project" and creator user "Andrey" call:

POST http://localhost:8080/projects/Project?creatorId="Andrey"

As a response you will receive the corresponding event if everything went well:

{
    "projectId": "823d4576-5e95-4027-bd9e-63b27086256c",
    "title": "Project",
    "creatorId": "\"Andrey\"",
    "createdAt": 1672078429244,
    "id": "e18fb19b-96eb-4706-b030-6cc5f7c23de2",
    "name": "PROJECT_CREATED_EVENT",
    "version": 1
}

Now lets add some Task with name "Task" to the project. Take the projectId from previous response and perform:

POST http://localhost:8081/projects/823d4576-5e95-4027-bd9e-63b27086256c/tasks/Task 

You will receive corresponding TASK_CREATED_EVENT if everything ok

Now lets fetch the current state of the ProjectAggregate:

GET http://localhost:8081/projects/823d4576-5e95-4027-bd9e-63b27086256c

You will receive something like this:

{
    "createdAt": 1672078820917,
    "updatedAt": 1672078820917,
    "projectTitle": "Project",
    "creatorId": "Andrey",
    "tasks": {
        "4b2e75be-19c8-4504-82b1-be3a8775a21a": {
            "id": "4b2e75be-19c8-4504-82b1-be3a8775a21a",
            "name": "Task",
            "tagsAssigned": []
        }
    },
    "projectTags": {},
    "id": "823d4576-5e95-4027-bd9e-63b27086256c"
}

This is the project with the only task inside.

tiny-event-sourcing-demo's People

Contributors

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