Skip to main content

Shared Aggregate

Description

An Aggregate that is part of the Shared Kernel, common to multiple Bounded Contexts.

Definition Schema

The definition for a shared_aggregate component expects the following structure:

{
"$defs": {
"AggregateCreationParameterInputDTO": {
"description": "Defines a parameter for the initiate_creation class method.",
"example": {
"param_name": "title",
"param_type_str": "str"
},
"properties": {
"param_name": {
"title": "Param Name",
"type": "string"
},
"param_type_str": {
"title": "Param Type Str",
"type": "string"
}
},
"required": [
"param_name",
"param_type_str"
],
"title": "AggregateCreationParameterInputDTO",
"type": "object"
},
"AggregateCreationParameterOutput": {
"properties": {
"param_name": {
"title": "Param Name",
"type": "string"
},
"param_type_str": {
"title": "Param Type Str",
"type": "string"
}
},
"required": [
"param_name",
"param_type_str"
],
"title": "AggregateCreationParameterOutput",
"type": "object"
},
"AggregateStateParameterInputDTO": {
"description": "Defines a state field within the aggregate.",
"example": {
"param_name": "title",
"param_type_str": "str"
},
"properties": {
"param_name": {
"title": "Param Name",
"type": "string"
},
"param_type_str": {
"title": "Param Type Str",
"type": "string"
}
},
"required": [
"param_name",
"param_type_str"
],
"title": "AggregateStateParameterInputDTO",
"type": "object"
},
"AggregateStateParameterOutput": {
"properties": {
"param_name": {
"title": "Param Name",
"type": "string"
},
"param_type_str": {
"title": "Param Type Str",
"type": "string"
}
},
"required": [
"param_name",
"param_type_str"
],
"title": "AggregateStateParameterOutput",
"type": "object"
}
},
"description": "Input DTO specifically for the AggregateCodeEngine.",
"example": {
"created_event_module": "app_root_name.domain.ordering.events",
"created_event_name": "OrderCreatedEvent",
"creation_parameters": [
{
"param_name": "customer_id",
"param_type_str": "int"
}
],
"id_generation_logic_str": "None # Assuming DB generates ID",
"id_type_str": "int",
"name": "OrderAggregate",
"state_parameters": [
{
"param_name": "status",
"param_type_str": "str"
},
{
"param_name": "total_amount",
"param_type_str": "Decimal"
}
]
},
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"id_type_str": {
"title": "Id Type Str",
"type": "string"
},
"state_parameters": {
"items": {
"anyOf": [
{
"$ref": "#/$defs/AggregateStateParameterInputDTO"
},
{
"$ref": "#/$defs/AggregateStateParameterOutput"
}
]
},
"title": "State Parameters",
"type": "array"
},
"creation_parameters": {
"items": {
"anyOf": [
{
"$ref": "#/$defs/AggregateCreationParameterInputDTO"
},
{
"$ref": "#/$defs/AggregateCreationParameterOutput"
}
]
},
"title": "Creation Parameters",
"type": "array"
},
"created_event_name": {
"title": "Created Event Name",
"type": "string"
},
"created_event_module": {
"title": "Created Event Module",
"type": "string"
},
"id_generation_logic_str": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": "uuid.uuid4()",
"title": "Id Generation Logic Str"
}
},
"required": [
"name",
"id_type_str",
"created_event_name",
"created_event_module"
],
"title": "AggregateEngineInputDTO",
"type": "object"
}

Naming and Location Conventions

Class: PascalCase, typically ends with 'Aggregate'. File: ${shared_aggregate_name}.py (based on ${shared_aggregate_name}). Location: app/domain/shared_kernel/aggregates.

Example Definition

{
"name": "OrderAggregate",
"id_type_str": "int",
"state_parameters": [
{
"param_name": "status",
"param_type_str": "str"
},
{
"param_name": "total_amount",
"param_type_str": "Decimal"
}
],
"creation_parameters": [
{
"param_name": "customer_id",
"param_type_str": "int"
}
],
"created_event_name": "OrderCreatedEvent",
"created_event_module": "app_root_name.domain.ordering.events",
"id_generation_logic_str": "None # Assuming DB generates ID"
}