{"id":16514739,"url":"https://github.com/andgineer/fastapi-celery","last_synced_at":"2025-03-21T08:31:37.510Z","repository":{"id":145706739,"uuid":"284882633","full_name":"andgineer/fastapi-celery","owner":"andgineer","description":"Python backend template: FastAPI + SQLAlchemy/Postgres + Celery/Redis","archived":false,"fork":false,"pushed_at":"2024-05-23T04:05:05.000Z","size":1373,"stargazers_count":4,"open_issues_count":6,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-23T04:58:14.659Z","etag":null,"topics":["alembic","celery","fastapi","gunicorn","nginx","postgres","python","redis","sqlalchemy"],"latest_commit_sha":null,"homepage":"https://sorokin.engineer","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/andgineer.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,"publiccode":null,"codemeta":null}},"created_at":"2020-08-04T05:07:28.000Z","updated_at":"2024-05-27T14:42:44.543Z","dependencies_parsed_at":"2023-04-27T20:32:07.350Z","dependency_job_id":"c7dd76c5-a48e-4cba-8f17-01dc25578197","html_url":"https://github.com/andgineer/fastapi-celery","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/andgineer%2Ffastapi-celery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andgineer%2Ffastapi-celery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andgineer%2Ffastapi-celery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andgineer%2Ffastapi-celery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andgineer","download_url":"https://codeload.github.com/andgineer/fastapi-celery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244765199,"owners_count":20506774,"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","celery","fastapi","gunicorn","nginx","postgres","python","redis","sqlalchemy"],"created_at":"2024-10-11T16:13:38.757Z","updated_at":"2025-03-21T08:31:36.029Z","avatar_url":"https://github.com/andgineer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/andgineer/fastapi-celery/workflows/ci/badge.svg)](https://github.com/andgineer/fastapi-celery/actions)\n[![Coverage](https://raw.githubusercontent.com/andgineer/fastapi-celery/python-coverage-comment-action-data/badge.svg)](https://htmlpreview.github.io/?https://github.com/andgineer/fastapi-celery/blob/python-coverage-comment-action-data/htmlcov/index.html)\n# Python backend: FastAPI/Gunicorn + SQLAlchemy/Postgres + Celery/Redis + nginx\n\nApplication template to quick start your API server.\n\nFully Dockerized local development environment.\n\nIn dev mode (`$env=dev``) uses `uvicorn` with live-reload (sources mounted to the\ncontainer). And Celery worker with live reload.\n\n## Installation\n\n### Activate (and/or create) the Python environment\n\n```\n. ./activate.sh\n```\n\n## Local development\n\n### Build and run all containers\n\n```console\n./build.sh\n./up.sh\n```\n\n### Sanity check with hurl\n\nInstall [hurl](https://hurl.dev/)\n\n    hurl docker/words.hurl\n\nThat will get auth token from backend running in the Docker, send `words` request to API and check response\n(it should be number of words in file `docker/words.txt`).\n\n### Local debug\n\nYou can debug backend and celery tasks code locally, outside containers.\nBackend and Celery worker will connect to Postgres and Redis in containers.\nFor that you need in your `/etc/hosts`:\n\n    127.0.0.1   postgres\n    127.0.0.1   redis\n\n## Working with DB\n\nSee docker/postgres/README.md.\n\n### Create migration script\n\n```console\n# compare DB models and current DB and create DB upgrade script in alembic/versions\n./alembic.sh revision --autogenerate -m \"Schema changes.\"\n\n# apply script to the DB so after that DB meta data will reflect DB models\n./alembic.sh upgrade head\n```\n\n## Testing\n\nYou only need `Posgtres` to run test container.\nWe use `fakeredis` to emulate `Redis`, `fastapi` `test client` to emulate fastapi server.\n\n```console\n./up.sh postgres\n```\n\n### Run tests from container\n\n```console\n./run.sh tests  # run all tests\n./run.sh tests python -m pytest -v  # run tests `verbosely`\n```\n\n### Run tests locally (as unit-tests without server running)\n\nin `/etc/hosts` we need\n\n    127.0.0.1   postgres\n\nin folder `/backend` execute\n\n```console\n./test.sh -k token  # run tests with `token` in test name\n./test.sh -m='unittest and not slow'  # run all fast unittests (locally)\n./test.sh -m=benchmark  # run all tests that mesures speed using pytest-benchmark\n./test.sh --markers  # see all markers that we can use with `-m` key\n./test.sh --cov  # run tests with coverage report\n```\n\n### Test local server\n\n```console\n./up.sh backend\n./test.sh --host 127.0.0.1\n```\n\nThis command run local server and test it.\nIt will skip unit tests that cannot be run for external server (marked as `unittest`).\n\n### Stress test\n\nRun tests in parallel in loop as some kind of stress-test using nginx as proxy.\n\nIn folder `backend/` run:\n```console\n./stress.sh\n```\n\n## Swagger / OpenAPI\n\nSwagger UI available at `localhost/docs` after server start (`./up.sh`).\n\n# nginx proxy\n\nNginx proxy at `8001` port.\n\nWithout nginx gunicorn server will drop a lot of incoming connections.\nBecause there are only `\u003cCPU number\u003e + 1` workers in production mode.\nOr even only one worker in live reload (`$env=dev`) mode.\n\nNginx will buffer requests so your server will serve a lot of parallel clients.\n\n## Allure test report\n\n* [Allure report](https://andgineer.github.io/fastapi-celery/builds/tests/)\n\n## Coverage report\n* [Coveralls](https://coveralls.io/github/andgineer/fastapi-celery)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandgineer%2Ffastapi-celery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandgineer%2Ffastapi-celery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandgineer%2Ffastapi-celery/lists"}