ddd-for-python
This is a framework for developing apps based on domain-driven design.
The design is inspired by Vaughn Vernon's reference implementation of DDD in Java.
A little bit of inspiration also comes from django.
Purpose:
The goal of this project is to provide a complete framework for implementing DDD bounded contexts in Python.
Read the user guide in the documentation to get started. You can also look at the example code of the 'shipping' context.
Star and/or follow the project to receive notifications when version 1.0.0 is released.
Design:
The design is based on these patterns:
- DDD (collection of patterns)
- Hexagonal Architecture
- Near-infinite Scalability ("Entity" concept)
- xUnit (for testing)
Theory:
The following sources are recommended:
- Domain-Driven Design: Tackling Complexity in the Heart of Software - Eric Evans
- Implementing Domain-Driven Design - Vaughn Vernon
- Hexagonal Architecture - Alistair Cockburn
- Life Beyond Distributed Transactions - Pat Helland
- xUnit - Wikipedia
Supported Python Versions:
- Tested with python 3.8.5.
- Should work with any version >= 3.8.0 (not tested).
Installation:
$ pip install ddd-for-python
Example:
# This is the "main.py" file that
# starts the bounded context in a container.
from ddd.application.config import Config
from ddd.infrastructure.container import Container
from shipping.utils.dep_mgr import DependencyManager
from shipping.application.shipping_application_service import \
ShippingApplicationService
if __name__ == "__main__":
"""
This is the container entry point.
Creates the application service and runs it in the container.
"""
# Config
config = Config()
# Dependency manager
dep_mgr = \
DependencyManager(
config=config,
)
# Application service
service = \
ShippingApplicationService(
customer_repository=dep_mgr.get_customer_repository(),
db_service=dep_mgr.get_db_service(),
domain_adapter=dep_mgr.get_domain_adapter(),
domain_publisher=dep_mgr.get_domain_publisher(),
event_repository=dep_mgr.get_event_repository(),
interchange_adapter=dep_mgr.get_interchange_adapter(),
interchange_publisher=dep_mgr.get_interchange_publisher(),
job_adapter=dep_mgr.get_job_adapter(),
job_service=dep_mgr.get_job_service(),
log_service=dep_mgr.get_log_service(),
scheduler_adapter=dep_mgr.get_scheduler_adapter(),
shipment_repository=dep_mgr.get_shipment_repository(),
max_concurrent_actions=config.max_concurrent_actions,
loop=config.loop.instance,
)
# ..register
dep_mgr.set_service(service)
# Container
container = \
Container(
app_service=service,
log_service=dep_mgr.get_log_service(),
)
# ..run
loop = config.loop.instance
loop.run_until_complete(container.run())
loop.close()
For the full code, see: "examples/webshop/shipping".
Documentation:
You can find the latest documentation at readthedocs.
Contribution:
If you want to contribute to the code base, create a pull request on the develop branch.
Release Notes:
0.9.5 - 2022-03-13
- Added documentation.
- Moved db_service related classes.
- Moved event related classes.
- Added MemoryPostgresDbService to be able to run tests against an in-memory postgres database.
- Fixed bug: container kwarg in example main.py (thanks euri10).
0.9.4 - 2021-05-17
- Added 'context' to log service's log messages.
- Moved record filtering methods to base repository class.
- Added 'uses_service' to Task class. Deprecate 'makes_requests'.
0.9.3 - 2021-03-27
- Searching env file from cwd by default in tests, (when no path specified).
- Refactored Task class to make it more simple.
- Refactored the configuration solution by adding a Config class.
- Added example code for 'shipping' context of a webshop application.
- Added get_all_jobs() and get_job_count() to scheduler adapter & service.
- Added missing call to _migrate() in a couple of Repository class functions.
0.9.2 - 2021-03-15
- Fixed bug: Env file wasn't loaded in certain circumstances.
0.9.1 - 2021-03-14
- Initial commit.
Metadata
Release files for ddd-for-python 0.9.5
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 |
|---|---|---|---|---|
| ddd-for-python-0.9.5.tar.gz | 41.2 kB | Without provenance | Details for ddd-for-python-0.9.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ddd_for_python-0.9.5-py3-none-any.whl | Python 3 | none | any | Details for ddd_for_python-0.9.5-py3-none-any.whl |
Total release size: 116.1 kB
Release files / ddd-for-python-0.9.5.tar.gz
| Download URL | ddd-for-python-0.9.5.tar.gz |
|---|---|
| Size | 41.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8add102c9ff1949bafc2ad60d89508a28853fefce386df68acf39f7b2d3788d
|
|
BLAKE2b-256 checksum How to use checksums |
5d11a8df0b24e63679b894ef3577f205f82e4af434230b7e1f8b7e0a42df6ce9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Release files / ddd_for_python-0.9.5-py3-none-any.whl
| Download URL | ddd_for_python-0.9.5-py3-none-any.whl |
|---|---|
| Size | 74.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
469d8c05d7efc7796db452de23985be94ec2c2b91ab250c2511f0278e1849453
|
|
BLAKE2b-256 checksum How to use checksums |
f7376a5115a38982bf9b92bf0f00147b7680f49027f4bbaef5bd8d50ecaab75e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Security for ddd-for-python 0.9.5
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.