Skip to content

Web service built using Python/Django that simulates a vending machine behavior.

License

Notifications You must be signed in to change notification settings

mustafa-kamel/vending-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Vending Machine

Web APIs that simulates a vending machine behaviour.

The app consists of RESTful APIs for managing users (registration, authentication, authorization) and Products CRUD. The users can register a new account and use it to add deposit and buy from the vending machine, the users can have one of two types (seller or buyer) a seller can manage products and a buyer can add deposit and buy a product.

Requirements

  • Python >= 3.8
  • Django >= 3.2

Included Features

  • User CRUD.
  • API Authentecation using JWT token.
  • Authorization using user roles.
  • Product CRUD for Sellers.
  • Add/Reset deposit for Buyers.
  • Buy a product for Buyers.
  • 100% Test coverage.
  • The app is dockerized.

Installation

  1. Clone the project.
git clone https://github.com/mustafa-kamel/vending-machine.git
  1. Change the active directory to the project directory.
cd vending-machine
  1. Create a virtual environment.
python3 -m venv venv
  1. Activate the virtual environment.
source venv/bin/activate
  1. Install the app requirements.
pip install -r requirements.txt
  1. Run the migrations.
./manage.py migrate
  1. Run the local server.
./manage.py runserver
  1. The app should now be accessible through http://localhost:8000.

Or simply you can run the app in a docker container.

  1. Build the docker image.
docker build -t vending:latest .
  1. Run the container.
docker run -it -p 8000:8000 vending:latest .

Testing

Their is test coverage to almost all possible scenarios.

To test the app is working properly run the following command:

./manage.py test

APIs

API documentation is available here

License

This software is licensed under the MIT License. See the LICENSE file in the top distribution directory for the full license text.