Skip to content

Change State

DDD CQRS ES

Protean provides two paths for changing state: directly through Application Services (in the DDD approach) or through Commands and Command Handlers (in CQRS and Event Sourcing). Both paths ultimately load an aggregate, invoke domain methods, and persist the result.

Process Requests

The request processing pipeline handles incoming intentions to change state, whether from API endpoints, CLI commands, or background jobs.

Application Services DDD

Application services coordinate use cases by orchestrating aggregates and domain services. They bridge the gap between the external world and the domain model. Use these when following the DDD pathway.

Learn more about application services →

Commands CQRS ES

Commands are immutable data transfer objects expressing an intent to change state. They carry the data needed for a specific operation without containing any logic. Use these when following the CQRS or Event Sourcing pathway.

Learn more about commands →

Command Handlers CQRS ES

Command handlers receive commands, load the relevant aggregate, invoke domain methods, and persist the result. Each handler processes a specific command type.

Learn more about command handlers →

Persist Data

Once state has been changed through domain methods, it needs to be persisted. Protean provides a collection-oriented persistence abstraction.

Repositories

Repositories are the persistence abstraction for aggregates. They provide a collection-like interface for adding, retrieving, and removing aggregates.

Learn more about repositories →

Persist Aggregates

Save aggregates through a repository's add method, with automatic transaction management via the Unit of Work pattern.

Learn more about persisting aggregates →

Retrieve Aggregates

Load and query aggregates using QuerySets, filters, Q objects, and lookup expressions.

Learn more about retrieving aggregates →

Temporal Queries ES

Reconstitute event-sourced aggregates at a specific version or point in time, enabling time-travel over the full event history.

Learn more about temporal queries →

Unit of Work

The Unit of Work pattern provides automatic transaction management, ensuring that all changes within a single operation are committed or rolled back together.

Learn more about the Unit of Work →

Custom Database Models DDD CQRS

Override the auto-generated storage schema with adapter-specific field types, custom table names, or multi-database deployments.

Learn more about custom database models →

Event Store Setup ES

Choose, configure, and operate an event store for event-sourced aggregates. Read events, inspect streams, and understand stream naming.

Learn more about event store setup →

Snapshots ES

Optimize event-sourced aggregate loading with periodic state checkpoints. Configure thresholds and manage snapshots via CLI or API.

Learn more about snapshots →