python-clean-architecture
python-clean-architecture is a Python library aiming to bring your code closer to The Clean Architecture. The first goal is to equip you with a set of patterns and good practices. The second one is to provide you a toolbox of adapters for integration with popular frameworks. Using them can make your code more focused on the knowledge you are trying to embody with your application and separation from technical details. A nice side-effects of this approach is an ease of plugging your application to a different variants of your infrastructure and lightweight testing the key fragments of your codebase.
Development Status (Stage 2 - Pre-Alpha Status)
THE LIBRARY IS NOT PRODUCTION- OR DEVELOPMENT-READY. If you want to make it useful, come and help. See CONTRIBUTING for details.
The concept for this library is ambitious and its core team has not as much spare time as it would like to dedicate, so don't expect rapid development here. If you are interested in making its progress more apparent, you are more than welcomed to propose your help. The core team reserves the right to choose focus points and scopes for the library, however.
The library is still in a planning phase, so expect much refactorization and many changes to its API.
Motivation & inspirations
There is a saying that every developer should write his own framework once in a lifetime. Being happily married with our professional jobs, we do this library in our spare time. Why? To show ourselves and fellow developers there is an achievable way to come closer to The Clean Architecture using a finite amount of effort. We try to show that Python community can build well designed applications as well. We treat following lectures as food for thoughts as we strive to implement ideas found there:
- Clean architecture by Robert "Uncle Bob" Martin (2017) (or e.g. Architecture the Lost Years (2011))
- Onion Architecture by Jeffrey Palermo (2008)
- Hexagonal Architecture by Alistair Cockburn (2005)
- Domain-Driven Design by Eric Evans (2003) & Martin Fowler (2002)
The Principles of the Library
Here you can find a short version of The Principles the library is meant to follow. If you want to read more about them, take a look at our docs.
- Domain First Design. Building an application should begin with its business intent and without any decision about a framework or other technical details.
- Keep it simple and straightforward. There's a great value of having simple business objects, like dataclasses. Decompose your every component to make them correspond a specific single responsibility, but only as far as to be straightforward in your intents. Keep your state-transformation functions pure and classes self-contained.
- Layered architecture. Keep domain & application logic pure. Separate them in layers, the same goes for technical details for a framework & the whole system/hardware environment. Dependencies between layers should point only inwards, with domain in the core. You can have more layers if you feel a need, but keep in mind that every layer is a cost to maintain.
- Coupling management. Quite often components don't need to be tightly connected and have knowledge of construction methods of the other one. Use Dependency Injection technique then, along with interfaces that define other component's contract. Dependency Injection may also help to control lifecycle of components.
- Be open to reimplementation. If a component may be implemented in several different manners, keep its design open to be reimplemented in different ways. Use interfaces that define contracts with other components. Use coupling management using these interfaces to interact with other components.
- Batteries included. The library should provide integrations with the key Python projects.
Tiers of the architecture
- Data-level logic: data description objects, factories, serialization, predicates, formulae. [Its not a specific layer]
- Domain layer: bounded contexts (aka domains), entities, value objects, aggregates, repositories, policies, factories, domain services.
- Application-specific logic: use-cases, application services, gateways, CQRS stacks, sagas. Task-, event- and data-driven applications, commands.
Integrations:
One of the goals of this library is to provide integration with popular Python frameworks and libraries. Here are the most notable ones:
Metadata
Release files for python-clean-architecture 0.0.6
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 |
|---|---|---|---|---|
| python-clean-architecture-0.0.6.tar.gz | 59.4 kB | Without provenance | Details for python-clean-architecture-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_clean_architecture-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for python_clean_architecture-0.0.6-py3-none-any.whl |
Total release size: 159.0 kB
Release files / python-clean-architecture-0.0.6.tar.gz
| Download URL | python-clean-architecture-0.0.6.tar.gz |
|---|---|
| Size | 59.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd3ef4d1f2aac4b66a5305583eb1ebbc79390ac1939e1bc5e3d72e91d1b009df
|
|
BLAKE2b-256 checksum How to use checksums |
063cade3f972ef813a8374495fd3094844e2b1eac00963a509964f6649f0da4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
|
Release files / python_clean_architecture-0.0.6-py3-none-any.whl
| Download URL | python_clean_architecture-0.0.6-py3-none-any.whl |
|---|---|
| Size | 99.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de80003a4e2b4fad8814a10efe4ea7705a4f59d53b843b8ac3bd26b5cd45b9e5
|
|
BLAKE2b-256 checksum How to use checksums |
78cd7635d67fba13dc0b2e75178f97a33f9234bceab1fc1cf84a0efcb5b67a2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
|
Security for python-clean-architecture 0.0.6
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.