/lucky-draw-gaming-service

This is a Lucky Draw Gaming Service which allows the customers to participate in the events and win some cool prizes.

Primary LanguagePython

Setting Up locally

  • Install pipenv using command pip install pipenv
  • Clone the repository.
  • Activate virtual environment using command pipenv shell
  • Install all dependecies using command pipenv install
  • Navigate to the server directory and type
python manage.py migrate
  • Create super user to access admin dashboard
python manage.py createsuperuser
  • Start the development server
python manage.py runserver
  • Open 127.0.0.1:8000 into the browser to see things in action

Database Schema and relationships

Screenshot (9)

API Documentation and automated testing

Once the development server is up and running then you can visit http://127.0.0.1:8000/swagger/ to see API documentation.

Models and Views(API) automated testing
python manage.py test

Endpoints response screenshots

  1. GET method: Getting tickets for a user ( By default : 2 Tickets )

http://127.0.0.1:8000/api/tickets/<user_id> e.g. http://127.0.0.1:8000/api/tickets/3

image

Tickets with count, http://127.0.0.1:8000/api/tickets/2?count=5

image

  1. GET method: Getting list of upcoming events

http://127.0.0.1:8000/api/upcoming-events

image

  1. POST method: Participating in an event ( event_id and ticket_id required in body)

http://127.0.0.1:8000/api/participate

Body
{
	"event_id" : 5,
	"ticket_id" : 7
}

image

  1. GET method: Get all past winners

http://127.0.0.1:8000/api/past-winners

image

  1. GET method: Announce winner of an event. ( event_id is required )

http://127.0.0.1:8000/api/event-winner/<event_id> e.g. http://127.0.0.1:8000/api/event-winner/6

image