Skip to content

aseguragonzalez/python-seedwork

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

About

DDD and Hexagonal (Clean) Architecture building blocks.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors