- Poetry dependency manager
- Pre-build Flask API
- Docker build & execution
- database (models in API + factories in tests)
- lint (black & isort) & style check (black, flake8 & mypy)
Update the name of the project folder flask_template
:
- update folder name (and import paths in folder + in
tests
folder) - replace
flask-template
in network name in network name indocker-compose.yml
anddocker-compose-no-data.yml
- value of project name in
pyproject.toml
Run project initialization.
$ make init
$ make run
Application is available on http://localhost:5000/
1 - Update lockfile
$ make shell
app@xxx:~$ poetry add <your_dependency>
2 - Rebuild application (required?)
$ make init
Run tests with the make command (:bulb: use pytest)
$ make test
Format automatically code (:bulb: use black & isort)
$ make format
Validate automatically code style (:bulb: use flake8 & mypy)
$ make format
In the <flask_template>/models
directories setup your models
- ๐ก use (and remove) the existing <flask_template>/user.py
as an example
$ make shell
# auto-generate migrations from your models
app@xxx:~$ poetry run alembic revision --autogenerate -m "first migration" --rev-id=v001
# check the migration file created in `alembic/versions`
# apply migrations to impact database
app@xxx:~$ poetry run alembic upgrade head
Use the populate_database method from manage.py file to create your objects (use existing example as a reference).
Then apply the database population by running:
$ make shell
# auto-generate migrations from your models
app@xxx:~$ poetry run python manage.py populate-database
- Update factories in
tests/factories
to match your models - Create your tests
- update the database
SQLALCHEMY_DATABASE_URI
in.env
- comment/remove the database service in
docker-compose.yml
- marshmallow/pydantic for serialization/deserialization
- auto openapi generation
- build
- hexagonal architecture