This release is a pre-release and may not be stable for production use.
Note: This library is currently in alpha stage and is under active development. APIs and features may change before the final release.
py-domain-driven-design
A domain driven design library for Python.
Purpose
The purpose of py-domain-driven-design is to provide a comprehensive toolkit for Python developers to implement domain-driven design (DDD) in their applications. This library focuses on enabling the development of rich domain models that accurately reflect complex business requirements, facilitating better communication between developers and domain experts, and promoting a more maintainable and scalable codebase.
Roadmap
Below is a list of planned features and enhancements for future releases of the py-domain-driven-design library.
- Repository Pattern: Add support for the repository pattern to provide a standard way to access domain objects from a data source.
- Aggregates: Add support for defining and working with aggregates, including aggregate roots and associated objects.
- Value Objects: Implement support for defining value objects to represent immutable domain concepts.
- Entities: Add support for defining entities with distinct identities and lifecycles.
- Domain Events: Implement infrastructure for defining and handling domain events to capture important domain changes.
- Integration Events: Add support for defining and handling integration events for communication between different bounded contexts.
- Domain Services: Support for encapsulating domain logic in services outside of entities or value objects.
- Infrastructure Services: Support for services that provide technical capabilities like data persistence and messaging, supporting the application's infrastructure needs.
- Listeners: Implement listeners to react to domain and integration events, enabling reactive and decoupled systems.
- Documentation: Expand the documentation to cover new features and provide more comprehensive usage examples and best practices.
We welcome feedback and contributions to help shape the future of this library. If you have ideas or suggestions, please [create an issue](
Python Compatibility
This library is compatible and tested with the following Python versions:
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12
Installation:
$ pip install py-domain-driven-design
Example:
Here's an example demonstrating the use of the repository pattern in the library:
from typing import List
from ddd.infrastructure.repository.in_memory.in_memory_repository_base import InMemoryRepositoryBase
from carbusiness.domain.model.vehicle.ivehicle_repository import IVehicleRepository
from carbusiness.domain.model.vehicle.vehicle import Vehicle
class InMemoryVehicleRepository(InMemoryRepositoryBase[Vehicle], IVehicleRepository):
def find_with_colors(self, colors: List[str]) -> List[Vehicle]:
with self._lock:
return [vehicle for vehicle in self._entities.values() if vehicle.color in colors]
# Creating a repository for Vehicle entities
vehicle_repository = InMemoryVehicleRepository()
# Adding some vehicles to the repository
vehicle_repository.save(Vehicle(id="1", color="red"))
vehicle_repository.save(Vehicle(id="2", color="blue"))
vehicle_repository.save(Vehicle(id="3", color="red"))
# Finding vehicles with the color red
red_vehicles = vehicle_repository.find_with_colors(["red"])
for vehicle in red_vehicles:
print(f"Red Vehicle: ID {vehicle.id}, Color {vehicle.color}")
# Output:
# Red Vehicle: ID 1, Color red
# Red Vehicle: ID 3, Color red
For more examples, please refer to the documentation.
Documentation:
You can find the latest documentation at readthedocs.
License
py-domain-driven-design is released under the GPL 3 license. See LICENSE for more details.
Source Code
You can find the source code for py-domain-driven-design on GitHub.
Release Notes
1.0.0-alpha.2 (2024-04-02)
- New Feature: Introduced the repository pattern, providing a base for data access.
- Basic Documentation: An initial set of documentation is provided, focusing on the repository pattern.
- License: Released under the GPL 3 license.
- Compatibility: Ensured compatibility with Python versions 3.7 to 3.12.
Metadata
Release files for py-domain-driven-design 1.0.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py-domain-driven-design-1.0.0a2.tar.gz | 17.0 kB | Without provenance | Details for py-domain-driven-design-1.0.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_domain_driven_design-1.0.0a2-py3-none-any.whl | Python 3 | none | any | Details for py_domain_driven_design-1.0.0a2-py3-none-any.whl |
Total release size: 37.2 kB
Release files / py-domain-driven-design-1.0.0a2.tar.gz
| Download URL | py-domain-driven-design-1.0.0a2.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04f8f31e90b4ab52e053ccb2078b965a789ebed8d19a6994ae6006f63dca538d
|
|
BLAKE2b-256 checksum How to use checksums |
a7d27a4b3b80d113fb4dcbf02bd1f0e67439c2db861800d6eefdce2ffa449f71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8
|
Release files / py_domain_driven_design-1.0.0a2-py3-none-any.whl
| Download URL | py_domain_driven_design-1.0.0a2-py3-none-any.whl |
|---|---|
| Size | 20.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4076793ff9e71daa1daf651ef9d8d2108063ed063dd59a8306173178e058651
|
|
BLAKE2b-256 checksum How to use checksums |
30da6e9f7317c29667471dda0d6e8f0b77f76acd499f647375125ba5301a710c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8
|
Security for py-domain-driven-design 1.0.0a2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.