A python service built using Clean Architecture and SOLID principles
This is an example implementation of a python application applying concepts from Clean Architecture and SOLID principles.
This template provides out of the box some commonly used functionalities:
The detailed documentation is available:
make docs
after installing dependencies with make dev-dependencies
Create your GitHub repository using this template (The big green Use this template
button).
Optionally tweak name and authors in the pyproject.toml
file, however the metadata
are not used when building the application, nor are referenced anywhere in the code.
Using Docker:
make containers
: Build containersdocker compose run --rm dev make migrate
: Run database migrationsdocker compose up dev
: Run HTTP application with hot reloaddocker compose up celery-worker
: Run the celery workerdocker compose run --rm test
: Run test suiteLocally:
make migrate
: Run database migrationsmake install-dependencies
: Install requirementsmake dev-dependencies
: Install dev requirementsmake update-dependencies
: Updates requirementsmake migrate
: Run database migrationsmake dev
: Run HTTP application with hot reloadmake test
: Run test suitemake check
: Run tests, code style and lint checksmake fix
: Run tests, code style and lint checks with automatic fixes (where possible)Python docker image tend to become large after installing the application requirements (the slim base is ~150 MB uncompressed), therefore it's important to spend efforts to minimise the image size, even if it produces a slightly more complex multistage Dockerfile.
The following setup makes sure the production image will keep to a minimal size ("only" 390MB):
Using the following pipeline the "test" image is instead ~850MB, more than 400MB that would end up as a cost in traffic on each image pull.