Samples showing practical aspect of EventStoreDB, Event Sourcing

Overview

EventStoreDB samples

EventStoreDB is an industrial-strength database technology used as the central data store for event-sourced systems. It is available open-source to run locally on most platforms or as SaaS through Event Store Cloud.

This repository provides samples demonstrating the functionalities of EventStoreDB and the client SDKs of EventStore and practical usage.

Common operations & usage samples can be found in the client repositories

Contributing

Feel free to create a GitHub issue if you have any questions or request for more explanation or samples.

We're open for any contribution! If you noticed some inconsistency, missing piece, or you'd like to extend existing samples - we'll be happy to get your Pull Request.

Read more in the Contribution Guidelines

Samples

Samples are organised by the specific topic. By going to the folder, you can find dedicated folders for different programming languages/environments.

CQRS flow

  • .NET

    Description:

    • typical Event Sourcing with CQRS flow.
    • stores events to EventStoreDB.
    • shows how to organise the write model and read model handling.
    • Builds read models using Subscription to $all.
    • Read models are stored as ElasticSearch documents.
    • Shows how to unit and integration test solution.
  • Java

    Description:

    • typical Event Sourcing with CQRS flow.
    • stores events to EventStoreDB.
    • shows how to organise the write model and read model handling.
    • Builds read models using Subscription to $all.
    • Read models are stored as Postgres documents.
    • Shows how to unit and integration test solution.

    There are two variations of handling the business logic:

Crypto Shredding

  • .NET

    Description:

    • shows how to Protecting Sensitive Data (e.g. for European General Data Protection Regulation) in Event-Sourced Systems.
    • shows how to use the .NET System.Security.Cryptography library with AES algorithm to encrypt and decrypt events' data.
    • uses EventStoreDB.

Sending EventStoreDB logs to Elasticsearch

Description:

This samples show how to configure various ways of sending logs from EventStoreDB to Elasticsearch:

Running samples locally

Check the README.md file in the specific sample folder for the detailed run instructions.

Support

Information on commercial support can be found here: https://eventstore.com/support/.

Documentation can be found here: https://developers.eventstore.com/

We invite you to join our community discussion space at Discuss.

Comments
  • Added sample configuration of sending EventStoreDB logs to Elastic

    Added sample configuration of sending EventStoreDB logs to Elastic

    Added sample configuration of sending EventStoreDB logs to Elastic together with Kibana integration.

    That includes:

    • Filebeat,
    • Logstash,
    • Filebeat and Logstash.

    See also related documentation PR: https://github.com/EventStore/EventStore/pull/3488.

    opened by oskardudycz 1
  • Shift tenant to aggregateId part of streamId

    Shift tenant to aggregateId part of streamId

    While the exact layout of a streamId is pretty arbitrary, in general it works better to have the tenant to the right of the '-' in the streamId as the default category projection treats anything to the left of the first '-' as the category (while this is configurable, this is the default, so Pit Of Success principles apply)

    opened by bartelink 1
  • Added samples for Protecting Sensitive Data in Event-Sourced Systems with Crypto Shredding

    Added samples for Protecting Sensitive Data in Event-Sourced Systems with Crypto Shredding

    Protecting Sensitive Data in Event-Sourced Systems with Crypto Shredding

    This sample is showing an example of using the Crypto Shredding pattern with EventStoreDB. This can be a solution for handling, e.g. European General Data Protection Regulation.

    Read more in the Diego Martin article "Protecting Sensitive Data in Event-Sourced Systems with Crypto Shredding".

    Description

    • shows how to Protecting Sensitive Data (e.g. for European General Data Protection Regulation) in Event-Sourced Systems.
    • shows how to use the .NET System.Security.Cryptography library with AES algorithm to encrypt and decrypt events' data.
    • uses EventStoreDB.

    Other changes:

    Updated the CI configuring for showing test results to:

    • not override each other if there are other changes
    • be able to be run by external PR. Unfortunately, that part is only to be verified once it's merged because of how GH is running the workflow triggers (the workflow file has to be on the main branch already).
    enhancement Crypt Shredding GDPR .NET 
    opened by oskardudycz 1
  • Added classic CQRS flow in .NET

    Added classic CQRS flow in .NET

    Added E-Commerce sample showing the classic Event Sourcing and CQRS flow with EvenStoreDB in .NET.

    Overview

    • typical Event Sourcing with CQRS flow.
    • stores events to EventStoreDB.
    • shows how to organise the write model and read model handling.
    • Builds read models using Subscription to $all.
    • Read models are stored as ElasticSearch documents.
    • Shows how to unit and integration test solution.

    Write Model

    Read Model

    Tests

    Other

    Besides that:

    • Added README.md with repository description
    • Added CONTRIBUTING.md with contribution guidelines
    • set MIT Licence
    • Github Action with build, test and acceptance tests for the sample and test report
    enhancement cqrs .NET 
    opened by oskardudycz 1
  • Updated .NET Crypto Shredding example to .NET 6, bumped packages to the latest version

    Updated .NET Crypto Shredding example to .NET 6, bumped packages to the latest version

    • Updated .NET CQRS flow to .NET 6, bumped packages to the latest version
    • Moved to file-scoped namespaces.
    • Updated obsolete usage of AesManaged to Aes.Create. From: https://www.meziantou.net/cryptography-in-dotnet.htm#aes:

      "AESManaged is fully implemented in .NET, however, the implementation is not FIPS compliant. AESCryptoServiceProvider uses the Windows implementation (CryptoAPI) which is FIPS compliant. Or you can create an instance of the best available provider using AES.Create()."

    Note for reviewers: Review with whitespace hidden, there is ten time less line change https://github.com/EventStore/samples/pull/13/files?diff=split&w=1

    Crypt Shredding .NET upgrade 
    opened by oskardudycz 0
  • Updated .NET CQRS flow to .NET 6, bumped packages to the latest version

    Updated .NET CQRS flow to .NET 6, bumped packages to the latest version

    • Updated .NET CQRS flow to .NET 6, bumped packages to the latest version
    • Moved to file-scoped namespaces.
    • Refactored and simplified Subscription to all processing.
    • Fixed bug in the ElasticSearchProjection processing: Entity wasn't getting from the database because of missing index name.
    • Added tests for:
      • adding product item,
      • removing product item,
      • confirming shopping cart.
    • Added StreamEvent wrapper to pass event metadata (e.g. to support idempotency in the projections).
    • Updated ElasticSearchProjection to generically support idempotency.
    • Hidden generic Publish method in EventBus, as it may be getting the wrong Type (e.g. base class instead of the exact one). It's also redundant to keep it public, as the object has a method.
    • Updated SubscribeToAll logic to not fail when it wasn't possible to deserialise even.
    • Removed test report workflow, as it's flaky and not adding much value.
    • Disabled Test parallelization for API tests to not have deadlocks on starting subscription host.

    Note for reviewers: Review with whitespace hidden, there is ten timeless line change https://github.com/EventStore/samples/pull/12/files?diff=split&w=1

    cqrs .NET upgrade 
    opened by oskardudycz 0
  • Refactoring of the CQRS Flow .NET example based on the feedback

    Refactoring of the CQRS Flow .NET example based on the feedback

    • [x] Removed MediatR library not to have a redundant dependency from the external package (no advanced features like pipelines were used)
    • [x] Removed marker interface for Commands, Queries and Events to reduce potential ceremony
    enhancement cqrs .NET 
    opened by oskardudycz 0
  • Derivation of Category name / StreamPrefix is broken

    Derivation of Category name / StreamPrefix is broken

    The logic in StreamNameMapper.ToStreamPrefix: https://github.com/EventStore/samples/blob/285a71700202166af78028d570d3d6b080c75c42/CQRS_Flow/.NET/Core/Core/Events/StreamNameMapper.cs#L23-L27 is problematic at present as it appears to map MyCompany.Domain.Cart to MyCompany_ItemAdded

    While I'm not a fan of seeing the naming of events as a global thing in the first instance*, I feel that this code is worse than useless as you'll inevitably end up with multiple MyCompany_Added things if you start from this code, which will conceal the objective of the code

    I'd be more than happy to make a PR to remove the prefixing logic, but would settle for any resolution that's more likely to end up with a useful convention as people inevitably paste this code around the world ;)

    • (for me, the event types should be relative to a Category and not even be subject to a global uniqueness constraint within a given store)
    opened by bartelink 0
  • Change local storage for priced items

    Change local storage for priced items

    I was porting your C# code to F# when I've realized that something didn't add up and most notably how merging quantities is achieved in the current implementation:

    https://github.com/EventStore/samples/blob/a552bc5d564cd4121807bc0fba958f5e01e4627e/CQRS_Flow/.NET/Carts/Carts/Carts/Cart.cs#L92-L110

    https://github.com/EventStore/samples/blob/a552bc5d564cd4121807bc0fba958f5e01e4627e/CQRS_Flow/.NET/Carts/Carts/Carts/Products/PricedProductItem.cs#L46-L52

    https://github.com/EventStore/samples/blob/a552bc5d564cd4121807bc0fba958f5e01e4627e/CQRS_Flow/.NET/Carts/Carts/Carts/Products/ProductItem.cs#L30-L36


    Not only there is a redundant check as part of the current implementation:

    https://github.com/EventStore/samples/blob/a552bc5d564cd4121807bc0fba958f5e01e4627e/CQRS_Flow/.NET/Carts/Carts/Carts/Products/PricedProductItem.cs#L41-L44

    https://github.com/EventStore/samples/blob/a552bc5d564cd4121807bc0fba958f5e01e4627e/CQRS_Flow/.NET/Carts/Carts/Carts/Products/ProductItem.cs#L46-L49


    but actually considering how data are stored:

    https://github.com/EventStore/samples/blob/a552bc5d564cd4121807bc0fba958f5e01e4627e/CQRS_Flow/.NET/Carts/Carts/Carts/Cart.cs#L21

    I think it would be relevant to use a map or a dictionary to store the priced items.

    It would make the whole consistency check a lot simpler.

    Also why bother throwing exceptions when you can add a product when the same product isn't already part of the collection and then merge quantities when it is.

    Wdyt?

    enhancement 
    opened by natalie-o-perret 2
Releases(2.2.0)
  • 2.2.0(Dec 8, 2021)

    • Updated .NET CQRS flow to .NET 6, bumped packages to the latest version
    • Moved to file-scoped namespaces.
    • Updated obsolete usage of AesManaged to Aes.Create. From: https://www.meziantou.net/cryptography-in-dotnet.htm#aes:

      "AESManaged is fully implemented in .NET, however, the implementation is not FIPS compliant. AESCryptoServiceProvider uses the Windows implementation (CryptoAPI) which is FIPS compliant. Or you can create an instance of the best available provider using AES.Create()."

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Dec 8, 2021)

    • Updated .NET CQRS flow to .NET 6, bumped packages to the latest version
    • Moved to file-scoped namespaces.
    • Refactored and simplified Subscription to all processing.
    • Fixed bug in the ElasticSearchProjection processing: Entity wasn't getting from the database because of missing index name.
    • Added tests for:
      • adding product item,
      • removing product item,
      • confirming shopping cart.
    • Added StreamEvent wrapper to pass event metadata (e.g. to support idempotency in the projections).
    • Updated ElasticSearchProjection to generically support idempotency.
    • Hidden generic Publish method in EventBus, as it may be getting the wrong Type (e.g. base class instead of the exact one). It's also redundant to keep it public, as the object has a method.
    • Updated SubscribeToAll logic to not fail when it wasn't possible to deserialise even.
    • Removed test report workflow, as it's flaky and not adding much value.
    • Disabled Test parallelization for API tests to not have deadlocks on starting subscription host.

    See details in: https://github.com/EventStore/samples/pull/12

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Aug 12, 2021)

    This sample is showing an example of using the Crypto Shredding pattern with EventStoreDB. This can be a solution for handling, e.g. European General Data Protection Regulation.

    Read more in the Diego Martin article "Protecting Sensitive Data in Event-Sourced Systems with Crypto Shredding".

    Description

    • shows how to Protecting Sensitive Data (e.g. for European General Data Protection Regulation) in Event-Sourced Systems.
    • shows how to use the .NET System.Security.Cryptography library with AES algorithm to encrypt and decrypt events' data.
    • uses EventStoreDB.

    Other changes:

    Updated the CI configuring for showing test results to:

    • not override each other if there are other changes
    • be able to be run by external PR. Unfortunately, that part is only to be verified once it's merged because of how GH is running the workflow triggers (the workflow file has to be on the main branch already).

    See the source codes: https://github.com/EventStore/samples/tree/main/Crypto_Shredding/.NET and Pull Request.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Aug 6, 2021)

    Refactoring of the CQRS Flow .NET example based on the feedback

    • [x] Removed MediatR library not to have a redundant dependency from the external package (no advanced features like pipelines were used)
    • [x] Removed marker interface for Commands, Queries and Events to reduce potential ceremony
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jul 20, 2021)

    Overview

    It uses:

    Write Model

    Read Model

    Tests

    Other

    Source code(tar.gz)
    Source code(zip)
Event capture and querying framework for Java

Eventsourcing for Java Enabling plurality and evolution of domain models Instead of mutating data in a database, Eventsourcing stores all changes (eve

Eventsourcing, Inc. 408 Nov 5, 2022
EventStoreDB is the database for Event Sourcing. This repository provides a sample of event sourced system that uses EventStoreDB as event store.

Event Sourcing with EventStoreDB Introduction Example Domain Event Sourcing and CQRS 101 State-Oriented Persistence Event Sourcing CQRS Advantages of

Evgeniy Khyst 53 Dec 15, 2022
Evgeniy Khyst 54 Dec 28, 2022
PostgreSQL is the world's most advanced open source database. Also, PostgreSQL is suitable for Event Sourcing. This repository provides a sample of event sourced system that uses PostgreSQL as event store.

Event Sourcing with PostgreSQL Introduction Example Domain Event Sourcing and CQRS 101 State-Oriented Persistence Event Sourcing CQRS Advantages of CQ

Evgeniy Khyst 146 Dec 20, 2022
Microservices project with CQRS, Event sourcing and Event-driven design.

for more details about the project, please check the attached pdf document "Walkthrough_SpringBoot_Microservices_Project" To Run the project : downloa

null 2 Jan 31, 2022
Powerful event-bus optimized for high throughput in multi-threaded applications. Features: Sync and Async event publication, weak/strong references, event filtering, annotation driven

MBassador MBassador is a light-weight, high-performance event bus implementing the publish subscribe pattern. It is designed for ease of use and aims

Benjamin Diedrichsen 930 Jan 6, 2023
A short and practical intro into project loom

project-loom Project loom is all about making concurrency easier (for developers) on the JVM. It is in experimental phase. Download the early access b

Ashwin Bhaskar 16 Dec 15, 2021
Log sourcing is method of trying to map all the ERROR and WARN logs you have in your system in a cost effective way.

log-sourcing Log sourcing is method of trying to map all the ERROR and WARN logs you have in your system in a cost effective way. The basic idea is th

Shimon Magal 12 Apr 19, 2021
A practical example to showcase Redis Streams and RediSearch in action

Redis Streams in Action A practical example to showcase Redis Streams in action. The goal is to process Twitter data in real-time for search and query

Abhishek Gupta 35 Dec 19, 2022
This repo contains all the materials for placement as well as Practical lab codes for all subjects and notes. For students graduating in 2023

UEMK_PLACEMENT_2023 This repo contains all the materials for placement as well as Practical lab codes for all subjects and notes. For students graduat

Shambashib Majumdar 8 Mar 5, 2022
Java Practical CO1212 exercises and assignment answers.

CO1212 Exercises Java Practical CO1212 exercises and assignment answers. Contribute to this You can find the questions in their respective directories

Dilshan Karunarathne 4 Apr 12, 2022
This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practical coding example and required JAR dependencies

SpringMVC-Database-Integration This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practic

GowthamRaj K 3 Nov 2, 2021
Java EE 7 Samples

Java EE 7 Samples This workspace consists of Java EE 7 Samples and unit tests. They are categorized in different directories, one for each Technology/

JavaEE Samples 2.5k Dec 20, 2022
Sample application demonstrating an order fulfillment system decomposed into multiple independant components (e.g. microservices). Showing concrete implementation alternatives using e.g. Java, Spring Boot, Apache Kafka, Camunda, Zeebe, ...

Sample application demonstrating an order fulfillment system decomposed into multiple independant components (e.g. microservices). Showing concrete implementation alternatives using e.g. Java, Spring Boot, Apache Kafka, Camunda, Zeebe, ...

Bernd Ruecker 1.2k Dec 14, 2022
The samples of RMI&JNDI Attack

RMI-JNDI-Attack-Samples The samples of RMI&JNDI attack RMI Client Attack Server Server Attack Client Registry Attack Client Registry Attack Server Cli

F4DE@Syclover 7 Aug 24, 2022
This repository consists of the code samples, assignments, and the curriculum for the Community Classroom complete Data Structures & Algorithms Java bootcamp.

DSA-Bootcamp-Java Subscribe to our channel Complete Playlist Syllabus Discord for discussions Telegram for announcements Connect with me     Follow Co

Kunal Kushwaha 10.2k Jan 1, 2023
Forge example mod showing how to implement native hwid.

auth-client What is this? A forge mod showing how to use this How to use? Copy into your mod or use the base and make your own. You have to compile th

Jake Priddle 6 Jul 1, 2021
POC showing how to divide endpoint(s) among different Open-API screens

Multiple Open-API groups: Spring boot POC showing how to divide endpoint(s) among different Open-API screens Demo Link (Select definition from top rig

null 6 Dec 15, 2022
JCuda samples

jcuda-samples This repository contains samples for the JCuda libraries. Note: Some of the samples require third-party libraries, JCuda libraries that

Marco Hutter 69 Nov 13, 2022