Sekiban Event Sourcing Framework

repository·main·Indexed 43 days ago

https://github.com/j-tech-japan/sekiban

An event sourcing and CQRS framework for .NET that provides high scalability through Microsoft Orleans integration. It features Dynamic Consistency Boundary (DCB) for tag-based consistency and supports multiple event stores including Azure Cosmos DB, PostgreSQL, DynamoDB, and SQLite, as well as snapshot storage via Azure Blob and Amazon S3.

Tokens
549.6K
Snippets
1.2K
Records
2K
Agent score
56%

What's inside Sekiban

  1. Overview of the Sekiban DCB CLI Tool

    main

    The Sekiban DCB CLI tool is designed for managing projection states, inspecting events, and working with local SQLite caches. It is primarily used for:

    • Building and rebuilding multi-projection states.
    • Debugging by inspecting events and projection states.
    • Managing local SQLite caches to enable offline development.
    • Environment management via multi-profile configurations (e.g., dev, staging, production).
  2. Overview of Sekiban.Dcb.DynamoDB implementation

    main

    The Sekiban.Dcb.DynamoDB package provides an Amazon DynamoDB event store implementation for the Sekiban.Dcb framework. It is designed to maintain API parity with the existing Cosmos DB provider while leveraging DynamoDB-specific features for performance.

    Key Requirements for Large States: Because DynamoDB has a 400 KB item size limit, any projection states exceeding ~350KB must be offloaded to S3. To support this, you must use the Sekiban.Dcb.BlobStorage.S3 package alongside the DynamoDB implementation.

  3. Overview of the Commands Module contents

    main

    The Commands Module provides the utilities necessary for executing commands within the Sekiban TypeScript ecosystem. It consists of three primary components:

    • unified-executor.ts: The command executor designed to work with schema-based commands.
    • validation.ts: Utilities for validating command input against their defined schemas.
    • types.ts: Basic type definitions for command execution options.
  4. What is Sekiban?

    main

    Sekiban is an application development framework leveraging Event Sourcing and CQRS (Command Query Responsibility Segregation). It is built using C# .NET Core 7+ and provides a declarative API for creating event-sourced applications.

    Key characteristics:

    • Event Store Support: Supports various event stores including Microsoft Azure Cosmos DB and Amazon DynamoDB.
    • Cloud Native: Designed for easy deployment on Azure or AWS.
    • Developer Focus: Aims to allow developers to focus on business logic by providing tools for commands, events, projections, and testing, rather than managing the underlying event-sourcing infrastructure.
  5. Overview of Sekiban TypeScript implementation roadmap

    main

    The Sekiban TypeScript implementation is organized into distinct phases, moving from core event sourcing primitives to production-ready features:

    Core Foundation (Phases 1-10)

    • Base Utilities: Date production, UUID, and validation.
    • Core Types: SortableUniqueId, PartitionKeys, and Metadata.
    • Event Management: EventDocument and InMemoryEventStore.
    • CQRS Core: Aggregates, Projectors, Command Handling, Query Processing, and the SekibanExecutor.

    Persistent Storage & Evolution (Phases 11-13)

    • Storage: PostgreSQL (@sekiban/postgres) and CosmosDB (@sekiban/cosmos) implementations.
    • Configuration: @sekiban/config using Zod for validation.
    • Snapshots: Configurable snapshotting strategies for performance.
    • Versioning: Schema registry and upcasting tools via @sekiban/migration.

    Advanced Features (Phases 14-20)

    • Orchestration: Process Managers and Sagas for long-running workflows.
    • Observability: OpenTelemetry integration for distributed tracing and metrics.
    • Security: Multi-tenancy, tenant isolation, and encryption.
    • Integration: Message bus support (Kafka/RabbitMQ) and REST/GraphQL APIs.
  6. Overview of Sekiban TypeScript packages

    main

    The Sekiban TypeScript ecosystem is divided into the core framework and several provider/integration packages:

    • @sekiban/core: The central framework implementing event sourcing and CQRS patterns.
    • @sekiban/postgres: Storage provider for PostgreSQL.
    • @sekiban/cosmos: Storage provider for Azure Cosmos DB.
    • @sekiban/dapr: Integration for Dapr actors with snapshot support.
  7. Current scope of Materialized View implementation

    main

    The current implementation of Materialized Views in Sekiban supports the following runtime configuration:

    • Supported DB Backends: PostgreSQL, SQL Server, MySQL, and SQLite.
    • Execution Host: Orleans.
    • Event Source: Existing DCB event stores resolved by ServiceId.

    In a typical sample implementation (e.g., DcbOrleans.WithoutResult.ApiService), the architecture consists of:

    • A Postgres instance for the Event Store.
    • A separate Postgres connection for managing Materialized View tables.
    • Orleans managing status, buffering, and refresh logic.
  8. Understand the Sekiban project structure

    main

    The sekiban-orleans-aspire template generates a multi-project solution organized as follows:

    • [ProjectName].Domain: Contains the core domain models, events, commands, and queries.
    • [ProjectName].ApiService: Provides API endpoints for executing commands and performing queries.
    • [ProjectName].Web: A Blazor-based web frontend.
    • [ProjectName].AppHost: The .NET Aspire host used to orchestrate all services.
    • [ProjectName].ServiceDefaults: Contains common service configurations used across the solution.
  9. Package Structure and Scopes

    main

    The Sekiban TypeScript ecosystem is organized into scoped npm packages under the @sekiban/* namespace. The planned package structure is:

    • @sekiban/core: The main framework functionality (equivalent to Sekiban.Pure).
    • @sekiban/dapr: Integration with Dapr (equivalent to Sekiban.Pure.Dapr).
    • @sekiban/testing: Test utilities for the framework.
    • @sekiban/cosmos: Integration with Azure Cosmos DB.
    • @sekiban/postgres: Integration with PostgreSQL.
  10. Supported Cloud Platforms for Sekiban DCB

    main

    Sekiban DCB supports multiple storage providers across Azure and AWS. Use the following matrix to plan your architecture:

    PlatformEvent StoreSnapshotOrleans ClusteringOrleans Stream
    AzureCosmos DB / PostgresAzure Blob StorageCosmos DB / Azure TableAzure Queue
    AWSDynamoDB / PostgresAmazon S3RDS PostgreSQLAmazon SQS
  11. Key features of the Sekiban framework

    main

    Sekiban provides several built-in capabilities to manage the complexities of Event Sourcing and CQRS:

    Command and Event Management

    • Simple Commands and Events: Declarative API for defining application functionality.
    • Publish-only Commands and Events: Ability to persist events without the need to project aggregates.
    • Optimistic Aggregate Version Check: Built-in conflict detection for concurrent environments.
    • Event Versions: Support for versioned events to improve forward compatibility.

    Projections and Querying

    • Single/Multi Aggregate Projections: Supports projections at both individual and multiple aggregate levels.
    • Projections Snapshots: Ability to capture the state of a projection at specific points in time.
    • Large Snapshot Storage: Integration with Azure Blob Storage or Amazon S3 for handling sizable snapshots.
    • Query from Multiple Projections: Enables dynamic data analysis by querying across a range of projections.

    Infrastructure and Tooling

    • Scalable Datastores: Native support for Azure Cosmos DB and Dynamo DB.
    • Tenant Partitions: Built-in support for separating data by tenant for easier management.
    • Built-in Testing Framework: Integrated suite for testing event-sourced logic.
    • API Generation: Automatic generation of Command and Query Web APIs with Swagger support.