This is an API built using python django framework. Tested on a Windows 10 machine, Please follow below steps for local setup
- Install dependencies
pip install -r requirements.txt
-
Create a PostgreSQL database Create a postgres database with the name basketball_league_db
-
Update the .env file Update the .env file with below DataBase credentials
DB_NAME=basketball_league_prod
DB_USER=<username>
DB_PASSWORD=<pwd>
DB_HOST=localhost
DB_PORT=5432
- Apply database migrations
python manage.py makemigrations
python manage.py migrate
- Generate mock data
python manage.py generate_fake_data
This will generate a default ADMIN, Coaches and Few Players with other relavant mappings. Their user credentials follow below structure
username: <"admin" | "coach1" | "player0_team10">
password: <"admin@123" | "coach@123" | "player@123">
- Run the development server
python manage.py runserver
To call the APIs you need to login first as an Admin/Coach/Player. After the successfull login, it will return a user token, which you need to pass as the OAUTH token for other API calls as the authorization header. Also you can register new Coaches, new Players and new Teams as well with the API set. I have authorized the API as per requested User Permission Model. Please check basketball_league/urls.py file for more info.
- Running Integration TestCases:
python manage.py test
Note: Additionally I have exported the Postman API collection as well.