Git Product home page Git Product logo

car-shop-api's Introduction

Overview

Car Shop API is a Restful API project that implements a system to handle sales of Cars to Car Owners. This project is written in Python 3 Django + MySQL

Requirements

Setup

Copy environment variables of the project:

cp .env.example .env

Build container and start development environment:

 docker-compose up --build

Run migrations:

 docker exec -it car-shop-web python manage.py migrate

After all these steps, the project will be running on port 8080: http://localhost:8000. All http requests send and receive JSON data.

To view changes in the database, go to http://localhost:8181/ on browser and you will be able to access phpmyadmin.

ER Database Diagram

(click the image to zoom it or just download the image and zoom it by yourself so you can see better all tables relationships)

Entity Relationship:

  • CarOwners 1 - N Cars

Documentation

You can access the Restful API public documentarion in the link below or clicking here.

https://www.postman.com/paduanton/workspace/antonio-de-pdua-s-public-workspace/collection/5889563-7f6ae96e-f38e-4ee8-971f-a877b996bbde?ctx=documentation

Also in the root dir there is a file called car-shop-api.postman_collection that you can import in your postman in order to see the API requests.

Endpoints

In all http calls you must have the header Accept:application/json. In http requests made with http POST verb you need to set the header Content-Type:application/json.

In order to make any http request data to the API you MUST first have an API secure token. In order to do that you must follow the next steps:

1 - Create a superuser

docker exec -it car-shop-web python manage.py createsuperuser --username paduanton --email [email protected]

2 - Generate API token with username

To create a new token you can run the command below on bash or you can make a POST request to /api-token-auth (request details are on postman API docs)

docker exec -it car-shop-web python manage.py drf_create_token paduanton 

3 - Set Authorization: Token {your-token} header in all API requests

With your API token in hands you must set the Authorization header together with your token, after that your http header shoud look like this:

Authorization: Token 1dd260a72829986fad06988bfe80cc7431d3aa71

4 - Enjoy the API

Testing

The whole models layer and API endpoints are covered by unit/integration tests. To run the automated testing you can use the bash command below:

docker exec -it car-shop-web python manage.py test 

car-shop-api's People

Contributors

paduanton avatar

Watchers

 avatar Kostas Georgiou 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.