DDD and Hexagonal Architecture building blocks for Python
Project description
python-seedwork
DDD and Hexagonal Architecture building blocks for Python.
Goals
- Unify design patterns. Provide a shared vocabulary — entities, aggregates, value objects, domain events, CQRS buses — so every bounded context starts from the same foundation.
- Keep domain logic pure. The domain layer has zero framework or infrastructure imports. Business rules live in the domain; everything else lives in infrastructure.
- Clear layer boundaries. Protocols define contracts; implementations satisfy them structurally. The dependency direction is enforced: domain ← application ← infrastructure.
Components
| Layer | Package | Components |
|---|---|---|
| Domain | seedwork.domain |
Entity, AggregateRoot, ValueObject, DomainEvent, DomainEventRecord, DomainError, Repository, UnitOfWork |
| Application | seedwork.application |
Command, Query[TResult], CommandHandler, QueryHandler, CommandBus, QueryBus, Result, DomainEventBusPublisher, DomainEventBusSubscriber, DomainEventBus, DomainEventHandler, BaseIntegrationEvent, IntegrationEvent, IntegrationEventPublisher, IntegrationEventHandler, BackgroundTask, TaskScheduler |
| Infrastructure | seedwork.infrastructure |
RegistryCommandBus, RegistryQueryBus, TransactionalCommandBus, DomainEventCoordinatorCommandBus, CommandBusBuilder, QueryBusBuilder, DeferredDomainEventBus, DomainEventPublishingRepository, InMemoryRepository |
All components are also re-exported from the top-level seedwork package.
Installation
pip install python-seedwork
Requires Python 3.12+. Ships a py.typed marker (PEP 561) — mypy and pyright pick up the inline types automatically.
Documentation
Comprehensive guides are available in the docs/ directory:
A complete Bank Account example demonstrates all patterns end-to-end.
Requirements
Python 3.12+, uv
Built With
- Python 3.12+
- uv — dependency management and packaging
- Ruff — linting and formatting
- Pyright — strict static type checking
- pytest — testing with coverage gate
- python-semantic-release — automated versioning and changelog
Development
git clone https://github.com/aseguragonzalez/python-seedwork.git
cd python-seedwork
make install
| Command | Description |
|---|---|
make check |
Lint, typecheck, and tests (what CI runs) |
make lint |
Run ruff linter |
make format |
Format and auto-fix with ruff |
make typecheck |
Run pyright |
make test |
Run tests with coverage (90% gate) |
make test-no-cov |
Run tests without coverage |
make clean |
Remove build artifacts and caches |
Contributing
This project follows the Conventional Commits specification. The commit-msg pre-commit hook enforces the format; python-semantic-release derives versions and the changelog from commit prefixes automatically.
References
This package draws on the following literature and on the experience of building solid, scalable, and maintainable systems in different stacks (PHP, C#, Python, TypeScript).
- Eric Evans, Domain-Driven Design: Tackling Complexity in the Heart of Software 1
- Vaughn Vernon, Implementing Domain-Driven Design 2
- Robert C. Martin, Clean Architecture: A Craftsman's Guide to Software Structure and Design 3
- .NET Microservices: Architecture for Containerized .NET Applications 4
- Architecture Patterns with Python, Harry Percival & Bob Gregory 5
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_seedwork-0.4.0.tar.gz.
File metadata
- Download URL: python_seedwork-0.4.0.tar.gz
- Upload date:
- Size: 114.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90dc60180aa7c696cb9edc8012f4d8ff2a30612dd4dd7d3d63089f593ebec78b
|
|
| MD5 |
d8b17a871025e5e5153d82f45aa0c8e0
|
|
| BLAKE2b-256 |
02799df1a12b180bfce89676e991299e377307a87484893f6ad951305e46076e
|
Provenance
The following attestation bundles were made for python_seedwork-0.4.0.tar.gz:
Publisher:
release.yml on aseguragonzalez/python-seedwork
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_seedwork-0.4.0.tar.gz -
Subject digest:
90dc60180aa7c696cb9edc8012f4d8ff2a30612dd4dd7d3d63089f593ebec78b - Sigstore transparency entry: 1569201394
- Sigstore integration time:
-
Permalink:
aseguragonzalez/python-seedwork@688f036b8835a269fca7eda3ba54f64cad0ae790 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aseguragonzalez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@688f036b8835a269fca7eda3ba54f64cad0ae790 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_seedwork-0.4.0-py3-none-any.whl.
File metadata
- Download URL: python_seedwork-0.4.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a45e476fb743a000eacf1f40b4bbb8a26f712c1751047e31a79e28c6ecbfe4fb
|
|
| MD5 |
6dec559d3e2299f6fa886ed282307d74
|
|
| BLAKE2b-256 |
0069ee3d580375ef135343546f5b33eda7c3d28120a14ea08042981c30cdc33e
|
Provenance
The following attestation bundles were made for python_seedwork-0.4.0-py3-none-any.whl:
Publisher:
release.yml on aseguragonzalez/python-seedwork
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_seedwork-0.4.0-py3-none-any.whl -
Subject digest:
a45e476fb743a000eacf1f40b4bbb8a26f712c1751047e31a79e28c6ecbfe4fb - Sigstore transparency entry: 1569201422
- Sigstore integration time:
-
Permalink:
aseguragonzalez/python-seedwork@688f036b8835a269fca7eda3ba54f64cad0ae790 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aseguragonzalez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@688f036b8835a269fca7eda3ba54f64cad0ae790 -
Trigger Event:
push
-
Statement type: