Appendix A. Summary Diagram and Table

Here’s what our architecture looks like by the end of the book:

diagram showing all components: flask+eventconsumer, service layer, adapters, domain etc

Table A-1 recaps each pattern and what it does.

Table A-1. The components of our architecture and what they all do
Layer Component Description

Domain

Defines the business logic.

Entity

A domain object whose attributes may change but that has a recognizable identity over time.

Value object

An immutable domain object whose attributes entirely define it. It is fungible with other identical objects.

Aggregate

Cluster of associated objects that we treat as a unit for the purpose of data changes. Defines and enforces a consistency boundary.

Event

Represents something that happened.

Command

Represents a job the system should perform.

Service Layer

Defines the jobs the system should perform and orchestrates different components.

Handler

Receives a command or an event and performs what needs to happen.

Unit of work

Abstraction around data integrity. Each unit of work represents an atomic update. Makes repositories available. Tracks new events on retrieved aggregates.

Message bus (internal)

Handles commands and events by routing them to the appropriate handler.

Adapters (Secondary)

Concrete implementations of an interface that goes from our system to the outside world (I/O).

Repository

Abstraction around persistent storage. Each aggregate has its own repository. ...

Get Architecture Patterns with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.