Giter Site home page Giter Site logo

restapi's Introduction

Exercise Scheduler Rest API

The project consist of a Backend service using Django REST framework which allows user to login/signup create their workout schedule and save it.The system provide RESTAPI for frontend to consume them for each task.

Table Of Content

Database Structure

db Image Image created using Graphiz

  • Main component of Database are:
    1. A User Table which stores user Info
    2. A Exercise table which store exercises and their details
    3. A schedule table that has User table as foreign key to store a customize user schedule

User Authentication

  • User data is saved in Django default User database with some addition of fields.
  • User is authenticated with a JWT on login which expires in 5 minutes.
  • User can refresh token on a http://127.0.0.1:8000/token/refresh endpoint. refresh token is valid for 1 day.
  • For more details about refer to JWT authentication

API Endpoints

Login Endpoint

POST request to the http://127.0.0.1:8000/token/ endpoint with username and password field in json format. This provide us an access token and a refresh token to access other endpoints.

{
    "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYyMjM3NDY4MiwianRpIjoiODExNjMzMzFkMTJiNDc5MzgwMTkzZWRiMjhmYzg2NTkiLCJ1c2VyX2lkIjo1fQ.STPJYGJSjVH8ZneLDl0hx47vDNHXwS2A6B63rDq3tGA",
    "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjIyMjg4NTgyLCJqdGkiOiJiMTgzYzQyYTY4Y2Q0NzAyYTExOGZiN2EzYjEzMTQ4NiIsInVzZXJfaWQiOjV9.PQlYK1T0yjMK3E1n3fAHOAQBnT6dslX9fsFOC6LbI8o"
}

Signup Endpoint

POST request to http://127.0.0.1:8000/signup/ endpoint with username, password, email and Goal in json format will result in user creation in database. New user data will be returned if user is created

Output on successful user creation include everything except password field

{
    "id": 6,
    "email": "[email protected]",
    "username": "sample",
    "goal": "random goal"
}

Exercises Endpoint

GET request to http://127.0.0.1:8000/exercises/ endpoint will return all the EXERCISES and their info saved in database.

Output
[
    {
        "id": 1,
        "name": "crunches",
        "details": "Crunches are for abs only and best one"
    },
    {
        "id": 2,
        "name": "pushups",
        "details": "pushups are for shoulder and chest"
    }
]

Schedule Endpoints

GET request to http://127.0.0.1:8000/schedule/ endpoint will provide the all the schedule provided by current user. This endpoint is authenticated and require access token to access the data. Access token can be provide in header Authorization: 'JWT <token>'

Output
[
    {
        "User": 5,
        "time_rest": "10",
        "exc_time": "60",
        "exerciselist": [
            1
        ]
    },
    {
        "User": 5,          #user id 
        "time_rest": "20",
        "exc_time": "120",
        "exerciselist": [
            1               #exercise id
        ]
    }
]

POST request to http://127.0.0.1:8000/schedule/ endpoint will create a schedule for current user. This endpoint is authenticated and require access token to access the data. Access token can be provide in header Authorization: 'JWT <token>'

Output 
{
    "User": 5,
    "time_rest": "20",
    "exc_time": "120",
    "exerciselist": [
        1,
        2
    ]
}

restapi's People

Contributors

rajeshsingh127 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.