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:
- Clone repo via git clone
https://github.com/chidioguejiofor/airtech-api.git
- Start virtual environment via
pipenv shell
- Install dependencies via
pipenv install
- Make bash scripts executable via:
chmod +x hooks/install_hooks.sh hooks/pre_commit.sh
- Install hooks by running:
hooks/install_hooks.sh
- Use the
.env-sample
file to create a.env
file with required environmental variables
The 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:
- Start celery worker by executing
celery -A celery_config.celery_app worker --loglevel=info
- In a separate terminal, spin up the celery beat via
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:
- Download and Install Docker from Docker Getting Started Page
- Ensure that Docker is installed by running
docker --version
. This should display the version of docker on your machine - In Project directory, use docker-compose to build the app by running
docker-compose build
. - Start the app via
docker-compose up
. You could add the-d
(docker-compose -d
) if you don't want to see the logs of the app. - Run
docker ps
to see that the airtech app is running - You should be able to connect to the app via the
localhost
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:
- Make the free_up_memory.sh bash script executable by running
chmod +x scripts/free_up_memory.sh
- Execute the script via:
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