Skip to main content

Domain Event Sourced Repository

Description

A specialized repository for retrieving and persisting Event Sourced Aggregates, typically interacting with an Event Store.

Definition Schema

The definition for a domain_event_sourced_repository component expects the following structure:

{
"example": {
"aggregate_id_type_str": "uuid.UUID",
"aggregate_module_str": "app_root_name.domain.ticketing.event_sourced_aggregates.ticket_aggregate",
"aggregate_name_prefix_for_stream": "ticket",
"aggregate_name_str": "TicketAggregate",
"event_publisher_interface_name": "ExternalEventPublisher",
"event_publisher_module_str": "castlecraft_engineer.abstractions.event_publisher",
"event_store_interface_name": "EventStore",
"event_store_module_str": "castlecraft_engineer.abstractions.event_store",
"repository_name": "TicketEventSourcedRepository",
"snapshot_store_interface_name": "SnapshotStore",
"snapshot_store_module_str": "castlecraft_engineer.abstractions.snapshot_store"
},
"properties": {
"repository_name": {
"description": "Name of the repository class (e.g., 'TicketEventSourcedRepository')",
"title": "Repository Name",
"type": "string"
},
"aggregate_name_str": {
"description": "Name of the EventSourcedAggregate class it manages (e.g., 'TicketAggregate')",
"title": "Aggregate Name Str",
"type": "string"
},
"aggregate_module_str": {
"description": "Full module path to the aggregate class (e.g., 'app_root_name.domain.ticketing.event_sourced_aggregates.ticket_aggregate')",
"title": "Aggregate Module Str",
"type": "string"
},
"aggregate_id_type_str": {
"description": "Type hint for the aggregate's ID (e.g., 'uuid.UUID')",
"title": "Aggregate Id Type Str",
"type": "string"
},
"event_store_interface_name": {
"default": "EventStore",
"description": "Name of the EventStore interface/contract.",
"title": "Event Store Interface Name",
"type": "string"
},
"event_store_module_str": {
"default": "castlecraft_engineer.abstractions.event_store",
"description": "Module for EventStore interface.",
"title": "Event Store Module Str",
"type": "string"
},
"snapshot_store_interface_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": "SnapshotStore",
"description": "Optional: Name of the SnapshotStore interface.",
"title": "Snapshot Store Interface Name"
},
"snapshot_store_module_str": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": "castlecraft_engineer.abstractions.snapshot_store",
"description": "Optional: Module for SnapshotStore interface.",
"title": "Snapshot Store Module Str"
},
"event_publisher_interface_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": "ExternalEventPublisher",
"description": "Optional: Name of the ExternalEventPublisher interface.",
"title": "Event Publisher Interface Name"
},
"event_publisher_module_str": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": "castlecraft_engineer.abstractions.event_publisher",
"description": "Optional: Module for ExternalEventPublisher interface.",
"title": "Event Publisher Module Str"
},
"aggregate_name_prefix_for_stream": {
"description": "Prefix for constructing event stream names (e.g., 'ticket')",
"title": "Aggregate Name Prefix For Stream",
"type": "string"
}
},
"required": [
"repository_name",
"aggregate_name_str",
"aggregate_module_str",
"aggregate_id_type_str",
"aggregate_name_prefix_for_stream"
],
"title": "EventSourcedRepositoryEngineInputDTO",
"type": "object"
}

Naming and Location Conventions

Class: PascalCase, typically ends with 'EventSourcedRepository'. File: ${domain_event_sourced_repository_name}.py (based on ${domain_event_sourced_repository_name}). Location: app/domain/${bounded_ctx}/repositories. (Requires context: ['bounded_ctx'])

Example Definition

{
"repository_name": "TicketEventSourcedRepository",
"aggregate_name_str": "TicketAggregate",
"aggregate_module_str": "app_root_name.domain.ticketing.event_sourced_aggregates.ticket_aggregate",
"aggregate_id_type_str": "uuid.UUID",
"aggregate_name_prefix_for_stream": "ticket",
"event_store_interface_name": "EventStore",
"event_store_module_str": "castlecraft_engineer.abstractions.event_store",
"snapshot_store_interface_name": "SnapshotStore",
"snapshot_store_module_str": "castlecraft_engineer.abstractions.snapshot_store",
"event_publisher_interface_name": "ExternalEventPublisher",
"event_publisher_module_str": "castlecraft_engineer.abstractions.event_publisher"
}