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.
- Python >= 3.8
- Django >= 3.2
- 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.
- Clone the project.
git clone https://github.com/mustafa-kamel/vending-machine.git
- Change the active directory to the project directory.
cd vending-machine
- Create a virtual environment.
python3 -m venv venv
- Activate the virtual environment.
source venv/bin/activate
- Install the app requirements.
pip install -r requirements.txt
- Run the migrations.
./manage.py migrate
- Run the local server.
./manage.py runserver
- The app should now be accessible through http://localhost:8000.
Or simply you can run the app in a docker container.
- Build the docker image.
docker build -t vending:latest .
- Run the container.
docker run -it -p 8000:8000 vending:latest .
Their is test coverage to almost all possible scenarios.
To test the app is working properly run the following command:
./manage.py test
API documentation is available here
This software is licensed under the MIT License
. See the LICENSE
file in the top distribution directory for the full license text.