Skip to content

dyerjos/rewards-backend

Repository files navigation


Rewards App

A backend to handle earning and spending reward points

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contact

About The Project

Built With

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

Installation

  1. Make sure your Docker daemon is running by starting up your Docker Desktop app

  2. Run Docker Compose and build your Docker image by using this line in your terminal:

    docker-compose up -d --build

    Alternatively if the image is already built, you can run:

    docker-compose up -d
  3. Run migrations:

docker-compose exec web python manage.py migrate
  1. Server is now running on http://127.0.0.1:8000/

(back to top)

Usage

There are several endpoints that can be used:

A neat thing about the Django Rest Framework is that if you go directly to directly to one of these URLs (while the server is running) you can see information about the endpoint such as what http request methods are allowed.

Endpoints that allow POST/PUT methods even have text areas for you to add JSON and submit without using a client like Postman or Insomnia.

Endpoint details

http://127.0.0.1:8000/ (the home page)

  • allows a GET request to retrieve a list of all transactions in the database and their initial point amounts
  • allows a POST request to add single transactions:
    { "payer": "DANNON", "points": 1000, "timestamp": "2020-11-02T14:00:00Z" }
    

http://127.0.0.1:8000/spend_points

  • allows a POST request to spend points:
    { "points": 5000 }
    

http://127.0.0.1:8000/get_balance

  • allows a GET request to retrieve total rewards points available per payer

http://127.0.0.1:8000/admin

  • if you are curious about one of my favorite Django features run this in your terminal:
    docker-compose exec web python manage.py createsuperuser
    
    and then follow the prompts that follow. This will add you as a super user to your django server which you will then use to sign in to the admin site. Here you can play around, see existing transactions, and create some new transactions.

(back to top)

Roadmap

  • Setup new Django Project
  • Add Black for code formatting
  • Initial README work
  • Setup project with PostgreSQL
  • Setup endpoints
  • Document the API
  • Add tests if for a production environment

(back to top)

Contact

Joshua Dyer - [email protected]

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published