- install
pyenv
first to able to usepyenv install 3.10.1
- then use
pyenv use 3.10.2
andpip install poetry
poetry install
to init your envpoetry run pre-commit install
to autoformat your code
poetry run test
-> runs docker compose containers and then runs testspoetry run server
-> runs docker compose and starts dev server with auto reloadpoetry run recreatemigrations
-> recreates initial migration, we can use this when service not deployedpoetry run makemigration {description}
-> create migration for dbpoetry run migrate
-> upgrades to heads migration
- use
poetry add {name}
to add package - use
poetry add -D {name}
to add package only for development
- for first level module variables use
UPPER_CASE = 1
API
etc. - all new features should be placed at
features
module - db tables always lower case
some_table_name
- branch management: -> production branch (last production version with tag of latest release) -> auto commit creates a tag (not pushed into prod, only manually from github workflow -> workflow creates pull request into main rebase) -> hotfix/someshing needs to be fixed -> main branch (all stuff goes here) -> (feature or bugfix)/example-button branch from develop branch (service will create feautre-env -> all from develop + service for feature, all other services auto updated) -> could be fast forward
- add pipeline (python build with deps -> gitlab ci runner + cache)
- init
git branch production
- New features located at
app.features
module -> to create new feature you can use commandpoetry run feature <name>
- This will create new folder with stub
API
and wired module inside app/init.py - Feature structure:
__init__.py
- includes global instances that could not be initialized by container, likeAPI
ofFastAPI
APIRouter
instancemodels.py
- defines pydantic models for endpoints, DB objects and general object validationtables.py
- defines DB tables with keys, relations, indexes etc.services.py
- defines incapsulated part of reused or isolated part of logicmanagers.py
- defines aggregated flows usingservices,resources
into business logiccontainers.py
- defines construction of all dependencies (services, managers, tables, etc.)api.py
- defines endpoints with injected container dependencies