Skip to content
CAI
Software that uses CAICheck a score

Finaps/EventSourcing

45.4

Weak · 21 September 2026

3.6k

lines of production code

C#

with JavaScript

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This is a .NET 6 library for implementing event sourcing, providing a structured way to persist and query domain events, snapshots, and projections. It offers a core abstraction for managing aggregate state and building projections, backed by either Entity Framework Core (SQL Server, PostgreSQL) or Azure Cosmos DB. The system supports transactional commits, automatic snapshotting, and bulk projection updates to ensure data consistency and performance.

How it got here

2021 — Initial release and .NET 6 migration

8 changes.

This period marks the initial release of the Finaps.EventSourcing library, establishing the core abstractions, projection system, and example projects. The work focused on implementing backend providers for Entity Framework Core and Azure Cosmos DB, while upgrading the entire solution to .NET 6 and adding comprehensive test coverage.

2022 — Event sourcing core and example implementation

24 changes.

This period focused on implementing the core event sourcing infrastructure, including the AggregateService, RecordStore, and SnapshotFactory, alongside a complete webshop example application. The work established the foundational domain models for products and baskets, supported by comprehensive unit and integration tests across Cosmos DB and Entity Framework backends.

Features

Add EventSourcing webshop example with Postgres and Cosmos DB support

The EventSourcing.Example project introduces a webshop backend implementation using Finaps.EventSourcing, supporting both Cosmos DB and PostgreSQL as event and snapshot stores. The example defines database migrations for event and snapshot tables (BasketEvents, OrderEvents, ProductEvents, and corresponding Snapshots) and configures the application startup to register event sourcing services via AddEventSourcing, enabling event-driven state management for aggregates like Baskets, Orders, and Products.

EventSourcing.Example · medium confidence

Add example infrastructure for event sourcing with Cosmos DB or Entity Framework

The example application now includes startup configuration for event sourcing, supporting either Azure Cosmos DB or a PostgreSQL database via Entity Framework. The new EventSourcingStartup class configures the appropriate event store based on the UseCosmos setting, while the ExampleContext class defines the database schema for product snapshots and reservations.

EventSourcing.Example/EventSourcingStartup · high confidence

Add shared domain constants and item record

The webshop example now includes shared domain building blocks: a Constants class defining expiration times for basket and product reservations, and an Item record representing a product and its quantity.

EventSourcing.Example/Domain/Shared · high confidence

Added Cosmos DB stored procedures for bulk deleting aggregate data

New Azure Cosmos DB stored procedures have been added to the \EventSourcing.Cosmos\ module to support bulk deletion of event and snapshot data. Specifically, \DeleteAggregateAll.js\ provides a generic bulk delete for all documents associated with an aggregate, while \DeleteAllEvents.js\ and \DeleteAllSnapshots.js\ offer targeted bulk deletion for specific record kinds (events and snapshots). These stored procedures handle pagination via continuation tokens to manage large datasets within execution time limits, and the C\# \StoredProcedures.cs\ file now embeds these scripts as constants for deployment.

EventSourcing.Cosmos/StoredProcedures · high confidence

Added REST APIs for managing products, baskets, and orders

The example application now exposes new HTTP endpoints to interact with the domain model. A ProductsController allows creating products, retrieving product details, and adding stock. A BasketsController enables creating shopping carts, adding items to them, and checking out, which triggers the creation of an Order. An OrdersController provides a way to retrieve order details. These controllers demonstrate the usage of the underlying event sourcing infrastructure, specifically utilizing the AggregateService for persistence and transactional commits across multiple aggregates.

EventSourcing.Example/Controllers · high confidence

Added basket domain model and events for the webshop example

The webshop example now includes a new Basket aggregate and its associated domain events (BasketCreated, ProductAddedToBasket, ProductRemovedFromBasket, and BasketCheckedOut). This introduces the core domain logic for managing shopping baskets, including adding/removing items and checking out, within the EventSourcing.Example project.

EventSourcing.Example/Domain/Baskets · high confidence

Added polymorphic serialization for Event Sourcing records

The EventSourcing.Cosmos package now includes a custom JSON converter (RecordConverter) that enables polymorphic serialization and deserialization of Record types. This change allows the system to automatically determine the correct Record type during deserialization based on a 'Type' field in the JSON payload. Additionally, the system can now enforce strict validation for non-nullable properties, throwing a RecordValidationException if required fields are missing or null, controlled by the new RecordConverterOptions.ThrowOnMissingNonNullableProperties setting.

EventSourcing.Cosmos/RecordConverter · high confidence

Added product domain model with stock and reservation tracking

The webshop example now includes a Product aggregate that tracks stock quantity and manages product reservations. The implementation supports creating products, adding stock, purchasing, and reserving items, with logic to validate availability and handle concurrent basket reservations. A corresponding snapshot and snapshot factory are also introduced to optimize state loading for this aggregate.

EventSourcing.Example/Domain/Products · high confidence

Added projection update and factory services

The EventSourcing.Core library introduces new services for managing projections. The IProjectionFactory and ProjectionFactory classes provide a mechanism to create Projection instances from Aggregate states, utilizing a hash-based system to track updates. Additionally, the IProjectionUpdateService and its implementation, ProjectionUpdateService, enable bulk updating of outdated projections by rehydrating and persisting source aggregates. This allows users to refresh projections when the underlying aggregate logic or projection mapping changes.

EventSourcing.Core/Services/ProjectionService · high confidence

Added validation logic for Event Sourcing records

The EventSourcing.Core library now includes a new validation service that enforces integrity rules for Snapshots, Events, and their sequences. Users will now encounter a RecordValidationException if events or snapshots have mismatched PartitionIds, non-consecutive or negative indices, or incompatible Aggregate/Record type mappings. This ensures that all event and snapshot records adhere to strict structural and sequential constraints before processing.

EventSourcing.Core/Services/Validation · high confidence

Initial release of Finaps.EventSourcing for .NET 6

The library now supports event sourcing with Entity Framework Core (SQL Server, PostgreSQL) and Azure Cosmos DB. The release includes the core library, EF and Cosmos providers, and example projects. Users can now install the Finaps.EventSourcing.EF and Finaps.EventSourcing.Cosmos NuGet packages to persist and query domain events, snapshots, and projections.

(repo-wide) · high confidence

Initial release of Finaps.EventSourcing.EF for Entity Framework Core

The Finaps.EventSourcing.EF package is now available, providing an Entity Framework Core implementation of the event sourcing record store. This includes the \RecordContext\ for database mapping, \EntityFrameworkRecordStore\ for persisting and querying events, snapshots, and projections, and \EntityFrameworkRecordTransaction\ for managing ACID-compliant transactions. The package also includes helper extensions for service provider registration and model building.

EventSourcing.EF · high confidence

Introduce AggregateService for event sourcing operations

Added the AggregateService and its associated transaction and interface definitions to the EventSourcing.Core module. This new service layer provides methods to rehydrate aggregates from event streams, persist uncommitted events, and manage ACID-compliant transactions for aggregate state changes. The implementation includes logic to fetch snapshots and events, handle caching for snapshots and projections, and ensure data consistency during commit operations.

EventSourcing.Core/Services/AggregateService · high confidence

Introduce Cosmos DB-backed record store with LINQ query support and bulk delete operations

The EventSourcing.Cosmos package now provides a full implementation of the IRecordStore interface backed by Azure Cosmos DB. This includes a new CosmosRecordStore that supports querying and storing Events, Snapshots, and Projections. The implementation adds support for LINQ-style queries via a custom CosmosAsyncQueryableProvider, enabling efficient data retrieval. Additionally, it introduces stored procedures for bulk deletion of events, snapshots, and aggregates, along with transactional batch support for atomic writes. The package also registers the necessary services via ServiceProviderExtensions for easy integration into .NET applications.

EventSourcing.Cosmos · high confidence

Introduce SnapshotFactory for aggregate state management

Added the ISnapshotFactory interface and the abstract SnapshotFactory\<TAggregate, TSnapshot\> class in the EventSourcing.Core.Services.SnapshotFactory namespace. This new component provides a standardized way to create and manage snapshots for aggregates, including logic to determine when a snapshot should be created based on the number of uncommitted events. The implementation includes a default interval-based check and a method to generate a Snapshot object with the correct metadata.

EventSourcing.Core/Services/SnapshotFactory · high confidence

Introduce core EventSourcing abstractions and projection system

The EventSourcing.Core library now provides the foundational classes for event sourcing, including the abstract Aggregate base class with support for partitioning, versioning, and event application. It introduces a caching system (Cache) that automatically discovers and registers snapshot and projection factories, enabling the creation of projections from aggregates via the Project\<TProjection\>() method. Additionally, it defines the IHashable interface for computing logic hashes to detect when projections are up to date.

EventSourcing.Core · high confidence

Introduce core record types for events, snapshots, and projections

Added new C\# record types for Event, Snapshot, and Projection, all inheriting from a common Record base. This introduces a unified data model for event sourcing, including an Index for ordering, a Timestamp for creation time, and specific fields like Hash and FactoryType for projections to track code state. The Record base class defines a RecordKind enum to differentiate between Events, Snapshots, and Projections in storage.

EventSourcing.Core/Records · high confidence

New RecordStore interface for managing events, snapshots, and projections

The RecordStore service now exposes a new IRecordStore interface that allows applications to query and persist events, snapshots, and projections. The interface provides methods to add, update, and delete these records, including specific delete operations for each type and a bulk delete for all records associated with an aggregate. Additionally, an IRecordTransaction interface is introduced to support ACID-compliant batch operations, allowing multiple events, snapshots, or projections to be committed together. A new RecordStoreException is also added to handle store-specific errors.

EventSourcing.Core/Services/RecordStore · high confidence

Test coverage

Add Postgres integration tests for Event Sourcing; Add SQL Server test infrastructure for event sourcing; Added Cosmos backend tests for the webshop example; Added Cosmos-specific test suite for event sourcing; Added Postgres-based integration tests for the webshop example; Added functional tests for the webshop example; Added mock aggregates and test doubles for the EventSourcing core; Added tests for AggregateService persistence and rehydration; Added tests for EF Core event integrity, aggregate references, and custom DbContext transactions; Added tests for RecordStore operations; Added tests for transactional operations on events, snapshots, and projections; Added unit tests for core event sourcing components; Tests for aggregate transaction persistence and validation.

Dependencies

Upgrade to .NET 6 and add test projects for EF Core and Cosmos backends

The project has been upgraded to target .NET 6.0 across all components, including the core library, the Entity Framework Core and Azure Cosmos DB backend packages, and their respective test suites. This update introduces new .csproj files for testing the EF Core and Cosmos implementations, establishing a consistent .NET 6 runtime environment for the entire solution.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.

Score

  • CAI 42 → 45 (+2.9)
  • Rubric changed (rubric-2026.08.18 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 95 → 93 (-1.9)
  • Architecture 80 → 77 (-2.9)
  • Maturity 43 → 43 (+0.0)
  • Readiness 36 → 36 (+0.0)
  • Security 37 → 58 (+21.1)
  • Domain Modelling 77 → 63 (-14.2)
  • Performance 60 → 60 (+0.0)

Resolved (17)

  • Bounded contexts not declared
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Medium CVE: Azure.Identity 1.3.0
  • Medium CVE: Azure.Identity 1.3.0
  • No ADRs found
  • No exposed public API
  • XML-doc coverage: EventSourcing.Example (EventSourcing.Example/EventSourcing.Example.csproj)
  • createDocument (cognitive 18) (EventSourcing.Cosmos/StoredProcedures/DocDbWrapperScript.js)
  • dormant codebase — no living knowledge left to concentrate
  • redundant comment (EventSourcing.Core/Records/Event.cs)
  • upsertDocument (cognitive 19) (EventSourcing.Cosmos/StoredProcedures/DocDbWrapperScript.js)
  • validateDocumentLink (cognitive 18) (EventSourcing.Cosmos/StoredProcedures/DocDbWrapperScript.js)
  • validateDocumentLink (cyclomatic 22) (EventSourcing.Cosmos/StoredProcedures/DocDbWrapperScript.js)

New (80)

  • AttributeEvent: 1 contract type(s) expose producer-owned ids/enums
  • BankAccountFundsDepositedEvent: 1 contract type(s) expose producer-owned ids/enums
  • BankAccountFundsEvent: 1 contract type(s) expose producer-owned ids/enums
  • BankAccountFundsTransferredEvent: 1 contract type(s) expose producer-owned ids/enums
  • BankAccountFundsWithdrawnEvent: 1 contract type(s) expose producer-owned ids/enums
  • Cross-context type Event (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type Event (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type Event (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type Event (EventSourcing.Core → EventSourcing.EF)
  • Cross-context type Event (EventSourcing.Core → EventSourcing.EF)
  • Cross-context type Event (EventSourcing.Core → EventSourcing.EF)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.Cosmos)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.EF)
  • Cross-context type IRecordTransaction (EventSourcing.Core → EventSourcing.EF)
  • …and 60 more

API surface

  • Unchanged — 8 HTTP endpoints

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

Finaps/EventSourcing was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit a75228f9d7297df948519b65fbed2da16f42e1fd — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-28e75b8e3254.