Skip to main content

DDD and Hexagonal Architecture building blocks for Python

Project description

python-seedwork

PyPI version Python License: MIT CI codecov Ruff Checked with pyright

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

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

MIT

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

python_seedwork-0.3.0.tar.gz (114.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_seedwork-0.3.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file python_seedwork-0.3.0.tar.gz.

File metadata

  • Download URL: python_seedwork-0.3.0.tar.gz
  • Upload date:
  • Size: 114.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for python_seedwork-0.3.0.tar.gz
Algorithm Hash digest
SHA256 78dec11d59a01b7a4e1388951eabb2c9e9611a380d4e70b254882a288d4d41c9
MD5 a29e50c4226cc1e8f45df88fb217edf1
BLAKE2b-256 75112fa5c8dd78ef9fd55495a87cec32b3efd7f326d289d282a70b1cd4fef202

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_seedwork-0.3.0.tar.gz:

Publisher: release.yml on aseguragonzalez/python-seedwork

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_seedwork-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: python_seedwork-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for python_seedwork-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 663454e66d0030b9d150e5d551e642900b605729e4a18e4d9d5aa3bb6a675ea2
MD5 7b0520dd45f0bb30b6081622b7901952
BLAKE2b-256 6ddd9489589db59c6d3f4775f895e4ac4a198dc8472868b5814f4f2add3837ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_seedwork-0.3.0-py3-none-any.whl:

Publisher: release.yml on aseguragonzalez/python-seedwork

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page