Skip to content

gretkierewicz/rate-cars-django-app

Repository files navigation

Rate Cars

Simple REST API for creating and rating car models.
Car make and model existence checked with third-party REST API.

Deployed at Heroku platform: link


Deployment

Requires git, docker and heroku clients installed + heroku (free) account registered
Interpreter - Windows PowerShell || git v2.29.2 || docker v20.10.2 || heroku v7.47.11

# create folder for project
mkdir rate_cars
cd rate_cars

# get copy of the application's files
git clone https://github.com/gretkierewicz/rate_cars.git .
# there is empty .env file in repo to make building container straight-forward

# build app with docker-compose
docker-compose build

# login with heroku and create app for deployment
heroku login
heroku create
# login to container
heroku container:login

# create postgresql DB (this creates DATABASE_URL env variable as well)
heroku addons:create heroku-postgresql:hobby-dev

# push and release container
heroku container:push web
heroku container:release web

# create DB tables for cars app
heroku run python manage.py migrate cars

# start app in web-browser
heroku open

# Enjoy!

Endpoints

/cars/ -> post new car
/cars/popular/ -> list 5 most rated car models
/cars/{car_make}
/cars/{car_make}/models/
/cars/{car_make}/models/{model_name}
/cars/{car_make}/models/{model_name}/rate/{rate_value} -> post rate

json format example for posting cars:

{
  "make": "Tesla",
  "models": [
    {"name": "Roadster"},
    {"name": "Model 3"},
    {"name": "Model X"},
    {"name": "Model S"}
  ]
}

json format example for posting rate:

{
  "rate": 5
}

Tests

  • Response's status codes

    • Valid data/url kwargs

      • GET for all endpoints
      • POST for /cars and /rate
      • DELETE for car make and car model
    • Invalid data/url kwargs

      • GET for endpoints with kwargs
      • POST for /cars and /rate
      • DELETE for car make and car model

Tech stack


Sources of knowledge / heplpfull links