Application source code (python) in the app/
directory is divided
in packages as follows:
fixtures
: json file used by tests or the command load fixturescommands
: custom shell commands to manage the application configured in modulemanage.py
covidbed
: buiness packages for api
Package covidbed
is structured as follows:
client
: buiness function to interact with external sourcesmodel
: sqlalchemy modelrepository
: dao functions with simple and comples sqlalchemy queryresource
: implementation of the route with flas-restfulroute
: routes with blueprint using resources modeulesserializer
: objects for flask-restful-swaggervalidator
: mashmallow objects to serialize response and validate request parameters
All config params are defined in the config module.
Dev server is launched with module server
Shell commands are launched with module manage
make build
make run
Note: overall configuration file .env
is initialized from .env-template
and should be fine for most use-cases; update to your liking as needed.
The various api routes should be displayed on localhost:$API_PORT
where API_PORT
is set in the .env
file.
Require Docker >= 1.3
# use 'docker ps' to see the list of your containers
docker-compose exec db psql -Upostgres
docker-compose exec server bash
# Prior to the first migration
docker-compose run --rm server python manage.py db init
# Create a new version of the database
docker-compose run --rm server python manage.py db migrate
# check file + remove comment + improve file if needed
sudo vim migration/versions/<migration_id>.py
# Upgrade your database to the last version
docker-compose run --rm server python manage.py db upgrade
docker-compose run --rm testserver python -m unittest
# Screenshot of python vendors
docker-compose run --rm server pip freeze > requirements.txt
# Run a command in the server container:
docker-compose run --rm server <command>