{"id":16085713,"url":"https://github.com/febus982/bootstrap-python-fastapi","last_synced_at":"2025-10-16T21:28:48.258Z","repository":{"id":65693569,"uuid":"563757733","full_name":"febus982/bootstrap-python-fastapi","owner":"febus982","description":"A python service built using Clean Architecture and SOLID principles","archived":false,"fork":false,"pushed_at":"2024-04-17T22:14:52.000Z","size":2138,"stargazers_count":27,"open_issues_count":11,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-18T17:05:41.214Z","etag":null,"topics":["alembic","clean-architecture","fastapi","grpc","python","software-architecture","sqlalchemy","template","template-repository","template-repository-python"],"latest_commit_sha":null,"homepage":"https://febus982.github.io/bootstrap-python-fastapi","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/febus982.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-11-09T09:17:19.000Z","updated_at":"2024-04-19T20:39:26.107Z","dependencies_parsed_at":"2024-04-19T20:39:09.170Z","dependency_job_id":"faad1ee1-e660-4d21-b980-99f5f5ee0e33","html_url":"https://github.com/febus982/bootstrap-python-fastapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fbootstrap-python-fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fbootstrap-python-fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fbootstrap-python-fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fbootstrap-python-fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/febus982","download_url":"https://codeload.github.com/febus982/bootstrap-python-fastapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871904,"owners_count":20361380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alembic","clean-architecture","fastapi","grpc","python","software-architecture","sqlalchemy","template","template-repository","template-repository-python"],"created_at":"2024-10-09T13:09:07.106Z","updated_at":"2025-10-16T21:28:48.251Z","avatar_url":"https://github.com/febus982.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bootstrap python service\n[![CI Pipeline](https://github.com/febus982/bootstrap-python-fastapi/actions/workflows/ci-pipeline.yml/badge.svg)](https://github.com/febus982/bootstrap-python-fastapi/actions/workflows/ci-pipeline.yml)\n[![Python tests](https://github.com/febus982/bootstrap-python-fastapi/actions/workflows/python-tests.yml/badge.svg?branch=main)](https://github.com/febus982/bootstrap-python-fastapi/actions/workflows/python-tests.yml)\n[![Code Coverage](https://qlty.sh/badges/8b83a4d5-bb29-402c-828b-7e6bb5fffde7/test_coverage.svg)](https://qlty.sh/gh/febus982/projects/bootstrap-python-fastapi)\n[![Maintainability](https://qlty.sh/badges/8b83a4d5-bb29-402c-828b-7e6bb5fffde7/maintainability.svg)](https://qlty.sh/gh/febus982/projects/bootstrap-python-fastapi)\n\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n\nThis is an example implementation of a python application applying\nconcepts from [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)\nand [SOLID principles](https://en.wikipedia.org/wiki/SOLID).\n\n* The repository classes are isolated behind interfaces, enforcing the [Interface Segregation principle](https://en.wikipedia.org/wiki/Interface_segregation_principle) \n  and the [Inversion of Control](https://en.wikipedia.org/wiki/Inversion_of_control) design pattern\n* The application frameworks are decoupled from the domain logic\n* The storage layer is decoupled from the domain logic\n\nThis template provides out of the box some commonly used functionalities:\n\n* Sync and Async API Documentation using [FastAPI](https://fastapi.tiangolo.com/) and [AsyncAPI](https://www.asyncapi.com/en)\n* Async tasks execution using [Dramatiq](https://dramatiq.io/index.html)\n* Websocket application using [Socket.io](https://python-socketio.readthedocs.io/en/stable/index.html)\n* Repository pattern for databases using [SQLAlchemy](https://www.sqlalchemy.org/) and [SQLAlchemy bind manager](https://febus982.github.io/sqlalchemy-bind-manager/stable/)\n* Database migrations using [Alembic](https://alembic.sqlalchemy.org/en/latest/) (configured supporting both sync and async SQLAlchemy engines)\n* Database fixtures support using customized [Alembic](https://alembic.sqlalchemy.org/en/latest/) configuration\n* Authentication and Identity Provider using [ORY Zero Trust architecture](https://www.ory.sh/docs/kratos/guides/zero-trust-iap-proxy-identity-access-proxy)\n* Full observability setup using [OpenTelemetry](https://opentelemetry.io/) (Metrics, Traces and Logs)\n* Example CI/CD deployment pipeline for GitLab (The focus for this repository is still GitHub but, in case you want to use GitLab 🤷)\n* [TODO] Producer and consumer to emit and consume events using [CloudEvents](https://cloudevents.io/) format using HTTP, to be used with [Knative Eventing](https://knative.dev/docs/eventing/)\n\n## Documentation\n\nThe detailed documentation is available:\n\n* Online on [GitHub pages](https://febus982.github.io/bootstrap-python-fastapi/)\n* Offline by running `make docs` after installing dependencies with `make dev-dependencies`\n\n## How to use\n\nCreate your GitHub repository using this template (The big green `Use this template` button).\nOptionally tweak name and authors in the `pyproject.toml` file, however the metadata\nare not used when building the application, nor are referenced anywhere in the code.\n\nBefore running any commands, install `uv` and `Docker`:\n\n- You can install `uv` on Mac using `brew`: `brew install uv`\n- Download and install Docker: https://www.docker.com/products/docker-desktop/\n\nUsing Docker:\n\n* `make containers`: Build containers\n* `docker compose up dev-http`: Run HTTP application with hot reload\n* `docker compose up dev-socketio`: Run HTTP application with hot reload\n* `docker compose up dramatiq-worker`: Run the dramatiq worker\n* `docker compose run --rm test`: Run test suite\n* `docker compose run --rm migrate`: Run database migrations\n* `docker compose run --rm autogenerate-migration`: Generate a new migration file\n\nUsing Make (you still need Docker for most of them):\n\n* `make install-dependencies`: Install requirements\n* `make dev-dependencies`: Install dev requirements\n* `make update-dependencies`: Updates requirements\n* `make dev-http`: Run HTTP application with hot reload\n* `make dev-socketio`: Run HTTP application with hot reload\n* `make test`: Run test suite\n* `make migrate`: Run database migrations\n* `make autogenerate-migration`: Generate a new migration file\n\n## Other commands for development\n\n* `make check`: Run tests, code style and lint checks\n* `make fix`: Run tests, code style and lint checks with automatic fixes (where possible)\n\n## Multistage dockerfile configuration\n\nPython docker image tend to become large after installing the application requirements\n(the slim base is ~150 MB uncompressed), therefore it's important to spend efforts\nto minimise the image size, even if it produces a slightly more complex multistage\nDockerfile.\n\nThe following setup makes sure the production image will keep to a minimal size (\"only\" 360MB):\n * 150MB base image\n * 210MB python installed dependencies\n\nUsing the following pipeline the \"test\" image is instead ~850MB, more than 400MB that would\nend up as a cost in traffic on each image pull.\n\n![](docs/puml/docker-container.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffebus982%2Fbootstrap-python-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffebus982%2Fbootstrap-python-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffebus982%2Fbootstrap-python-fastapi/lists"}