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.
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.
How to Use
See Getting Started for a step-by-step walkthrough: define a value object, build an aggregate root, create a command handler, and wire a bus.
The Component Reference covers every class and protocol in detail. A complete working example lives in docs/examples/bank_account/.
What's Included
| 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, DomainEventPublisher, DomainEventHandler |
| Infrastructure | seedwork.infrastructure |
RegistryCommandBus, RegistryQueryBus, TransactionalCommandBus, CommandBusBuilder, QueryBusBuilder, DomainEventPublishingRepository, InMemoryRepository |
All components are also re-exported from the top-level seedwork package.
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
Requirements: Python 3.12+, uv
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 |
Documentation
- Getting Started — step-by-step guide for building with this library
- Component Reference — every class, protocol, and method
- Best Practices — patterns and idioms for effective use
- Coding Standards — conventions aligned with DDD and Clean Architecture
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
- Evans, E. — Domain-Driven Design: Tackling Complexity in the Heart of Software (2003)
- Vernon, V. — Implementing Domain-Driven Design (2013)
- Martin, R. C. — Clean Architecture: A Craftsman's Guide to Software Structure and Design (2017)
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.2.0.tar.gz.
File metadata
- Download URL: python_seedwork-0.2.0.tar.gz
- Upload date:
- Size: 111.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
074ebdf8803192d5a17f6388b51595d26750db76b8299ff60067a469a6d08cd6
|
|
| MD5 |
8bb7f79ce3279c8062e3e979f20decc0
|
|
| BLAKE2b-256 |
aa187713a2bf4cae9202f725fcea655653ed5978d4bfeb7b9e574bc408447e26
|
Provenance
The following attestation bundles were made for python_seedwork-0.2.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.2.0.tar.gz -
Subject digest:
074ebdf8803192d5a17f6388b51595d26750db76b8299ff60067a469a6d08cd6 - Sigstore transparency entry: 1525518293
- Sigstore integration time:
-
Permalink:
aseguragonzalez/python-seedwork@eae54cc0ccde0d70eb00b40f75cc2b7a4bc91b84 -
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@eae54cc0ccde0d70eb00b40f75cc2b7a4bc91b84 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_seedwork-0.2.0-py3-none-any.whl.
File metadata
- Download URL: python_seedwork-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.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 |
bd1b4fdd2bc3d166323ccd8bde64f769e61b3822e8637c37a4a0a24077e84cfd
|
|
| MD5 |
31d72e0c205993e3e7605752a88c2669
|
|
| BLAKE2b-256 |
18c3f0ae8045e798ae0f2596ab16ac6a36091bf8d97e4db680a3f4348da54b5c
|
Provenance
The following attestation bundles were made for python_seedwork-0.2.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.2.0-py3-none-any.whl -
Subject digest:
bd1b4fdd2bc3d166323ccd8bde64f769e61b3822e8637c37a4a0a24077e84cfd - Sigstore transparency entry: 1525518341
- Sigstore integration time:
-
Permalink:
aseguragonzalez/python-seedwork@eae54cc0ccde0d70eb00b40f75cc2b7a4bc91b84 -
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@eae54cc0ccde0d70eb00b40f75cc2b7a4bc91b84 -
Trigger Event:
push
-
Statement type: