A dockerised Air reservation api built with django and django rest framework
MIT License
has had their challenges using spreadsheets to manage their flight booking system. They are ready to automate their processes with an application and have reached out to you to build a flight booking application for the company.
Run the following commands:
https://github.com/chidioguejiofor/airtech-api.git
pipenv shell
pipenv install
chmod +x hooks/install_hooks.sh hooks/pre_commit.sh
hooks/install_hooks.sh
.env-sample
file to create a .env
file with required environmental variablesThe app is configured to automatically lint your files once you do a git commit
. However you can decide to lint all
python files by running yapf -ir $(find . -name '*.py')
.
Linting follows the PE8 Style Guide
In order to start the app locally, run python manage.py runserver
.
You can all the endpoints in the postman documentation here
Celery is used as the message broker for the API. We use it to run heavy task(via celery-workers) and run cronjobs(via celery-beat).
In order to run celery, you would need to ensure that a redis
is running.
Using docker, you can achieve this by running docker run -p 6379:6379 redis
. This would spin up a redis server in port 6379
in your machine.
If your redis server
is running on a different port/host, you must specify the URL in the .env
file via key REDIS_SERVER_URL
Once Redis is up and running, you can now spin up celery in these steps:
celery -A celery_config.celery_app worker --loglevel=info
celery -A celery_config.celery_schedules beat --loglevel=info
You could also easily start the API, Celery and Redis by using docker in the following steps:
docker --version
. This should display the version of docker on your machinedocker-compose build
.docker-compose up
. You could add the -d
(docker-compose -d
) if you don't want to see the logs of the app. docker ps
to see that the airtech app is runninglocalhost
When you are done running your app with docker, it is best to free up resources that is used. To do this follow these steps:
chmod +x scripts/free_up_memory.sh
scripts/free_up_memory.sh
The above would free up memory that is used in your docker instance
You can run tests for the app via: pytest --cov=airtech_api --cov-report=html