How j-tech-japan/sekiban works
Main Components
• Framework Core (Domain and Event Sourcing Engine):
– Components handling aggregates, commands, events, projections, queries, and serializations.
– Modules included under src/Sekiban.Pure (e.g., Aggregates, Commands, Events, Exceptions, Projectors, Repositories, Serialization, etc.).
• Orleans-Enabled Modules:
– The Orleans implementation (src/Sekiban.Pure.Orleans and related surrogates, grains, partitions, executor parts).
– Key components like Grain interfaces and classes (e.g., AggregateEventHandlerGrain, AggregateProjectorGrain, MultiProjectorGrain) that implement event processing and projection.
• Persistence/Infrastructure Providers:
– CosmosDb support (src/Sekiban.Pure.CosmosDb) with event writers/readers, partition generators and cache accessors.
– Postgres support (src/Sekiban.Pure.Postgres) including migrations, context factories, and database event writers/readers.
– Additional providers/tools may be seen for other storage solutions.
• API and Application Hosts:
– API services and AppHost projects (as seen in Samples/AspireEventSample and internalUsages/OrleansSekiban.ApiService/AppHost) that expose endpoints and support HTTP, likely in ASP.NET Core.
• Testing and Templates:
– NUnit/xUnit projects and samples (src/Sekiban.Pure.NUnit, src/Sekiban.Pure.Orleans.xUnit, tests/ directories) to indicate the testing framework and examples for integration tests.
– Template projects and documentation utilities (found in the templates/ folder, docfx documentation resources) for scaffolding new implementations and generating documentation.
• Auxiliary Tools:
– Tools like “ConvertAndCopyCosmosItems” demonstrating how events might be transformed or copied.
– Memory-stat module in src/MemStat.Net – possibly not directly part of the core framework but included for monitoring or auxiliary diagnostic functionality.
Relationships and Interactions
• A layered structure where the Domain Core (Commands, Events, Aggregates) sits at the center.
• Directional flows:
– Commands enter the system via API Services/AppHost; these feed into the framework’s command executor.
– Events are generated by aggregates and are written to the Event Store using different providers.
– Projections and Query components read from the stored events; these might be updated on demand or via Orleans grains.
– Orleans grains interact with the framework core, ensuring scalability by handling aggregate commands and event delivery using the actor model.
• Supporting flows for testing and configuration:
– Testing modules can be shown interacting with almost every layer via mock/external interfaces.
– The templates and tooling support the generation of proper projects that follow the same architectural layout.
Architectural Patterns / Design Principles
• Use of CQRS (Command Query Responsibility Segregation) separating the write (command/aggregate handling) and read (projections/query processing) models.
• Event Sourcing: every change is captured as an event that can then be used to rebuild aggregate state.
• Orleans (actor model) is used to increase scalability and support concurrent multi-threaded operations.
• Dependency inversion and modularization: each infrastructure module (Cosmos, Postgres, etc.) is a plug-in that can be configured with the core business logic.