Git Product home page Git Product logo

febus982 / bootstrap-python-fastapi Goto Github PK

View Code? Open in Web Editor NEW
27.0 1.0 1.0 1.74 MB

A python service built using Clean Architecture and SOLID principles

Home Page: https://febus982.github.io/bootstrap-python-fastapi

Python 89.86% Mako 1.50% Dockerfile 5.28% Makefile 2.34% Shell 0.86% HTML 0.16%
clean-architecture python alembic fastapi grpc sqlalchemy software-architecture template template-repository template-repository-python

bootstrap-python-fastapi's Introduction

Bootstrap python service

CI Pipeline Python tests Test Coverage Maintainability

Checked with mypy Ruff Code style: black security: bandit

This is an example implementation of a python application applying concepts from Clean Architecture and SOLID principles.

  • The repository classes are isolated behind interfaces, enforcing the Interface Segregation principle and the Inversion of Control design pattern
  • The application frameworks are decoupled from the domain logic
  • The storage layer is decoupled from the domain logic

This template provides out of the box some commonly used functionalities:

Documentation

The detailed documentation is available:

  • Online on GitHub pages
  • Offline by running make docs after installing dependencies with make dev-dependencies

How to use

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 containers
  • docker compose run --rm dev make migrate: Run database migrations
  • docker compose up dev: Run HTTP application with hot reload
  • docker compose up celery-worker: Run the celery worker
  • docker compose run --rm test: Run test suite

Locally:

  • make migrate: Run database migrations
  • make install-dependencies: Install requirements
  • make dev-dependencies: Install dev requirements
  • make update-dependencies: Updates requirements
  • make migrate: Run database migrations
  • make dev: Run HTTP application with hot reload
  • make test: Run test suite

Other commands for development

  • make check: Run tests, code style and lint checks
  • make fix: Run tests, code style and lint checks with automatic fixes (where possible)

Multistage dockerfile configuration

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):

  • 150MB base image
  • 165MB python installed dependencies
  • 73MB poetry + updated pip

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.

bootstrap-python-fastapi's People

Contributors

febus982 avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

whenessel

bootstrap-python-fastapi's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency coverage to v7.5.0
  • Update dependency mypy to v1.10.0
  • Update paambaati/codeclimate-action action to v6
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

docker-compose
docker-compose.yaml
dockerfile
Dockerfile
  • python 3.11-slim
docs/dockerfile.md
github-actions
.github/workflows/ci-pipeline.yml
  • actions/checkout v4
  • docker/setup-qemu-action v3
  • sigstore/cosign-installer v3.5.0
  • docker/setup-buildx-action v3.2.0
  • docker/login-action v3.1.0
  • docker/build-push-action v5.3.0
  • docker/metadata-action v5.5.1
  • docker/build-push-action v5.3.0
.github/workflows/github-pages.yml
  • actions/checkout v4
  • actions/setup-python v5
  • actions/configure-pages v5
  • actions/upload-pages-artifact v3
  • actions/deploy-pages v4
.github/workflows/python-code-style.yml
  • actions/checkout v4
  • actions/setup-python v5
.github/workflows/python-lint.yml
  • actions/checkout v4
  • actions/setup-python v5
.github/workflows/python-quality.yml
  • actions/checkout v4
  • actions/setup-python v5
  • paambaati/codeclimate-action v5.0.0
.github/workflows/python-tests.yml
  • actions/checkout v4
  • actions/setup-python v5
.github/workflows/python-typing.yml
  • actions/checkout v4
  • actions/setup-python v5
pep621
pyproject.toml
poetry
pyproject.toml
  • aiosqlite >=0.18.0
  • alembic ^1.11.1
  • asgiref ^3.7.2
  • celery ^5.3.1
  • cloudevents ^1.9.0
  • dependency-injector ^4.41.0
  • httpx >=0.23.0
  • opentelemetry-distro *
  • opentelemetry-instrumentation *
  • opentelemetry-instrumentation-celery *
  • opentelemetry-instrumentation-httpx *
  • opentelemetry-instrumentation-sqlalchemy *
  • pydantic ^2.2.1
  • pydantic-settings ^2.0.3
  • python >=3.9,<3.12
  • rich ^13.2.0
  • SQLAlchemy ^2.0.0
  • sqlalchemy-bind-manager *
  • structlog ^24.0.0
  • fastapi >=0.99.0
  • jinja2 ^3.1.2
  • opentelemetry-instrumentation-fastapi *
  • starlette-prometheus ^0.9.0
  • strawberry-graphql >=0.204.0
  • uvicorn ^0.29.0
  • asynctest *
  • coverage *
  • mkdocs *
  • mkdocs-awesome-pages-plugin *
  • mkdocs-macros-adr-summary *
  • mkdocs-material *
  • mkdocs-mermaid2-plugin *
  • mypy *
  • mypy-protobuf *
  • pytest *
  • pytest-cov *
  • pytest-factoryboy *
  • pytest-xdist *
  • ruff *
  • strawberry-graphql *
  • pymdown-extensions *

  • Check this box to trigger a request for Renovate to run again on this repository

Find alternative to dependency-injector framework

The project is not actively maintained except for urgent requirements: ets-labs/python-dependency-injector#742

Once python 3.12 is released it will pin pydantic to v1, making the package incompatible (ets-labs/python-dependency-injector#765 ets-labs/python-dependency-injector#752)

Potential candidates (https://github.com/sfermigier/awesome-dependency-injection-in-python)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.