A repo containing tooling support for the Polylith Architecture in Python.
From the official docs:
... Polylith is a software architecture that applies functional thinking at the system scale. It helps us build simple, maintainable, testable, and scalable backend systems. ...
Polylith is an architecture (with tooling support) originally built for Clojure. The code in this repo brings Polylith to Python!
Polylith is using a components-first architecture. Similar to LEGO, components are building blocks. A component can be shared across apps, tools, libraries, serverless functions and services.
This repo contains a Poetry plugin, that you can install from PyPI. The plugin will add Polylith specific tooling support to Poetry. Have a look in the Poetry Polylith Plugin project folder with details about the Poetry plugin.
Have a look at the Python Polylith Examples repository.
It is a repository with an example Python setup of the Polylith Architecture.
You will find examples of sharing code between different kind of projects, and developer tooling setup such as mypy and the venv.
- Python with the Polylith Architecture - an overview (about 15 minutes)
- Python Poetry Polylith Plugin - the tooling support & commands (about 13 minutes)
In the official docs for the Clojure implementation,
there is a interface.clj file that is used to separate an API from the implementation of a component.
The Python implementation uses the __init__.py to accomplish that. In the Python implementation, the pyproject.toml is used to define bases and components.
In particular, the packages property is used for that.
This is an example of the top level pyproject.toml used when developing. This is where you add all bricks (components and bases).
packages = [
{include = "development"},
{include = "my_namespace/my_component", from = "components"},
{include = "my_namespace/my_example_aws_lambda", from = "bases"},
](using the loose theme, see the Poetry Polylith Plugin docs)
When creating a project, the project specific pyproject.toml will include all the used components and bases.
Note that the packages are referenced relative to the project.
This is where you add the bricks used by the actual project.
packages = [
{include = "my_namespace/my_component", from = "../../components"},
{include = "my_namespace/my_example_aws_lambda", from = "../../bases"},
]