The Airtech-API is the backbone of a flight booking application where users can make flight reservations and buy flight tickets.
The API documentation can be found here: Doc
Staging Link: Staging Link
- Register and login users.
- Be a vendor and sell wears.
- Users can upload passport photographs.
- Users can book tickets.
- Users can receive tickets as an email.
- Users can check the status of their flight.
- Users can make flight reservations.
- Users can purchase tickets.
This is a python API built with Django v2.2 and Django Rest Framework framework. Authentication of users is done via JSON Web Tokens.
-
Python 3.7.0
- Download Docker from here
- Set up an account to download Docker
- Install Docker after download
- Go to your terminal run the command
docker login - Input your Docker email and password
To setup for development with Docker after cloning the repository please do/run the following commands in the order stated below:
cd <project dir>to check into the dirdocker-compose buildto build the application imagesdocker-compose upto start the api after the previous command is successful
The docker-compose build command builds the docker image where the api and its postgres database would be situated.
Also this command does the necessary setup that is needed for the API to connect to the database.
The docker-compose up command starts the application.
To stop the running containers run the command docker-compose down
To delete the database volume as well run the command docker-compose down -v
To Clean Up After using docker do the following
- In the
Docker_localdirectory, run the commandsh cleanup.sh - Wait for all images to be deleted.
URGENT WARNING PLEASE DO NOT RUN THE CLEAN-UP COMMAND ABOVE UNLESS YOU ARE ABSOLUTELY SURE YOU ARE DONE WITH THAT DEVELOPMENT SESSION AND HAVE NO DATA THAT WOULD BE LOST IF CLEAN-UP IS DONE!
NOTE: This setup is for MacOS only, Windows setup will be coming soon.
-
Check that python 3 is installed:
python --v >> Python 3.7 -
Install pipenv:
brew install pipenv
-
Check pipenv is installed:
pipenv --version >> pipenv, version 2018.11.26 -
Check that postgres is installed:
postgres --version >> postgres (PostgreSQL) 10.5 -
Clone the Airtech-API repo and cd into it:
git clone https://github.com/veeqtor/Airtech-API.git
-
Install dependencies:
pipenv install -
Install dev dependencies to setup development environment:
pipenv install --dev
-
Rename the .env.sample file to .env and update the variables accordingly:
-
Activate a virtual environment:
pipenv shell
-
Apply migrations and create a superuser:
python manage.py migrate && python manage.py createsuperuser -
Run the application:
python manage.py runserver
-
Should you make changes to the database models, run migrations as follows:
python manage.py makemigrations && python manage.py migrate -
Deactivate the virtual environment once you're done:
exit
On command line run:
pytestTo further view the lines not tested or covered if there is any,
An htmlcov directory will be created, get the index.html file by entering the directory and view it in your browser.
-
Running Redis server : if you are not running docker, then you can simply run the command
sh redis.shin the root project directory, this will install redis for you (if not already installed) and also run/start the redis server for the first time on your local machine.-
Update the
.envwith the redis info, this is usuallylocalhostand6379:REDIS_HOST=<redis_host> REDIS_PORT=<redis port> -
In a new terminal tab run the Celery Message Worker with:
celery worker -A src.celery -l info --concurrency=2
-
-
After setting up the Celery worker, you need to start the
celery-beatused to to triggerceleryscheduled tasks -
In a new terminal tab start
celery-beatwith:celery -A src.celery beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler --pidfile=/tmp/celeryd.pid
-
After setting up the Celery workers and beat, you need to start the
celery-flowerused to monitor celery task in realtime. -
In a new terminal tab start
celery-flowerwith:celery flower -A src.celery --address=0.0.0.0 --port=5555
All proposals for contribution must satisfy the guidelines in the product wiki. When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.This Project shall be utilising a Pivotal Tracker board to track the work done.
This project is authored by Nwokeocha victor and is licensed for your use, modification and distribution under the MIT license.