Skip to content

hv-ojha/Beverage-Vending-Machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Beverage Vending Machine

Functionalities needed

  1. Display all beverages available
  2. 4 Types of beverages
    1. Black Coffee
      1. Water -> 3 unit
      2. Coffee -> 1 unit
      3. Sugar -> 1 unit
    2. Coffee with Milk
      1. Water -> 1 unit
      2. Coffee -> 1 unit
      3. Milk -> 2 unit
      4. Sugar -> 1 unit
    3. Sugarfree Black Coffee
      1. Water -> 3 unit
      2. Coffee -> 1 unit
    4. Sugarfree Coffee with Milk
      1. Water -> 1 unit
      2. Coffee -> 1 unit
      3. Milk -> 2 unit
  3. Notify staff when it ran out of ingredients

Database Design

Note : italics text are primary keys and bold are foreign keys

  1. Inventories
    • itemId -> integer
    • itemName -> varchar
    • quantity -> integer
  2. Beverage
    • beverageId -> integer
    • beverageName -> varchar
    • available -> boolean
  3. Ingredients
    • beverageIngredientId -> integer (Optional)
    • itemId -> Inventories.itemId
    • beverageId -> Beverage.beverageId
    • quantityNeeded -> integer

Technologies Used

  • Java (Spring Boot Framework)
  • PostgreSQL
  • Github
  • Postman
  • IntelliJ IDEA

How To Run

  • Open PostgreSQL and create Database with name vendingmachine
  • Import Queries from Queries.sql to your PostgreSQL
  • Open/Import project in InteliiJ or Eclipse
  • Click on Run Application
  • Open Postman For best interface for APIs.

REST API

1. Inventories

1.1 Get All Inventories

  • URL - http://localhost:8080/inventories/

  • Method - GET

  • Purpose - Retrieve List of all inventories supported by vending machine.

  • Parameter - NONE

  • Body Params - NONE

  • Result - List of inventories object

1.2 Add Inventory

  • URL - http://localhost:8080/inventories/

  • Method - POST

  • Purpose - Add new inventory to the system

  • Parameters - NONE

  • Body Params :- All parameters are permissible to send with request

Parameters Value Datatype Required
name should contain name of new inventory String YES
quantity should contain quantity inserted in the machine Integer YES
  • Result - Inventories object

1.3 Update Inventory

  • URL - http://localhost:8080/inventories/

  • Method - PUT

  • Purpose - Update existing inventory from the system

  • Parameters - NONE

  • Body Params :- All parameters are permissible to send with request

Parameters Value Datatype Required
inventoryId must be a valid id of existing inventory Integer YES
name should contain name of new inventory String NO
quantity should contain quantity inserted in the machine Integer NO
  • Result - inventories object

1.4 Delete Inventory

  • URL - http://localhost:8080/inventories/{inventoryId}

  • Method - DELETE

  • Purpose - Delete an existing inventory from the system

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
inventoryId must be a valid id of existing inventory Integer YES
  • Body Params :- NONE

  • Result - Boolean

1.5 Get Single Inventory

  • URL - http://localhost:8080/inventories/{inventoryId}

  • Method - GET

  • Purpose - Retrieve an inventory from the system requested by given ID.

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
inventoryId must be a valid id of existing inventory Integer YES
  • Body Params :- NONE

  • Result - inventories object

1.6 Increase Inventory Quantity

  • URL - http://localhost:8080/inventories/increaseQuantity/{inventoryId}/{quantity}

  • Method - GET

  • Purpose - Increase the quantity of an existing inventory from the system

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
inventoryId must be a valid id of existing inventory Integer YES
quantity must be a valid integer quantity Integer YES
  • Body Params :- NONE
  • Result - inventories object

1.7 Check for Empty Inventory

  • URL - http://localhost:8080/inventories/checkEmpty/{inventoryId}

  • Method - GET

  • Purpose - Check whether the asked inventory is empty or not

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
inventoryId must be a valid id of existing inventory Integer YES
  • Body Params :- NONE
  • Result - Boolean

1.8 Check Inventory with given quantity

  • URL - http://localhost:8080/inventories/checkQuantity/{inventoryId}/{quantity}

  • Method - GET

  • Purpose - Check whether the asked inventory possess given quantity or not

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
inventoryId must be a valid id of existing inventory Integer YES
quantity must be a valid integer quantity Integer YES
  • Body Params :- NONE
  • Result - Boolean

1.9 Empty Inventories

  • URL - http://localhost:8080/inventories/emptyInventories

  • Method - GET

  • Purpose - Retrieves all the inventories which are empty

  • Parameters - NONE

  • Body Params :- NONE

  • Result - List of inventories object

2 Beverage

2.1 Add Beverage

  • URL - http://localhost:8080/

  • Method - POST

  • Purpose - Add new beverage to the system

  • Parameters - NONE

  • Body Params :- All parameters are permissible to send with request

Parameters Value Datatype Required
beverageId must be a valid id of existing inventory Integer NO
name should contain name of new inventory String YES
available boolean value for availability of beverage Boolean NO
  • Result - Beverage object

2.2 Get All Beverages

  • URL - http://localhost:8080/

  • Method - GET

  • Purpose - Retrieve all the beverages of the system

  • Parameters - NONE

  • Body Params :- NONE

  • Result - List of Beverage object

2.3 Update Beverage

  • URL - http://localhost:8080/

  • Method - PUT

  • Purpose - Update existing beverage from the system

  • Parameters - NONE

  • Body Params :- All parameters are permissible to send with request

Parameters Value Datatype Required
beverageId must be a valid id of existing inventory Integer YES
name should contain name of new inventory String NO
available boolean value for availability of beverage Boolean NO
  • Result - Beverage object

2.4 Get Single Beverage

  • URL - http://localhost:8080/{beverageId}

  • Method - GET

  • Purpose - Retrieve an beverage from the system requested by given ID.

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
beverageId must be a valid id of existing beverage Integer YES
  • Result - Beverage object
  • Body Params :- NONE

2.5 Delete Beverage

  • URL - http://localhost:8080/{beverageId}

  • Method - DELETE

  • Purpose - Delete an existing beverage from the system

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
beverageId must be a valid id of existing beverage Integer YES
  • Body Params :- NONE
  • Result - Boolean

2.6 Check Availability of Single Beverage

  • URL - http://localhost:8080/available/{beverageId}

  • Method - GET

  • Purpose - Retrieve all beverages which are available in the vending machine

  • Parameters - All parameters are permissible to send with request

    Parameters Value Datatype Required
    beverageId must be a valid id of existing beverage Integer YES
  • Body Params - NONE

  • Result - Boolean

2.7 Check all beverages

  • URL - http://localhost:8080/available

  • Method - GET

  • Purpose - Retrieve all beverages which are available in the vending machine

  • Parameters - NONE

  • Body Params - NONE

  • Result - List of Beverage object

3. Ingredients

3.1 Get All Ingredients

  • URL - http://localhost:8080/ingredient/

  • Method - GET

  • Purpose - Retrieve all ingredients used by all beverages.

  • Parameters - NONE

  • Body Params - NONE

  • Result - List of Ingredients object

Alternative way is to call a single beverage api which will also contain information of ingredients used to create that beverage.

3.2 Add Ingredients

  • URL - http://localhost:8080/ingredient/

  • Method - POST

  • Purpose - Insert ingredient of particular beverage.

  • Parameters - NONE

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
beverage Beverage object with valid beverageId under the field beverageId inside beverage object Integer YES
inventories Beverage object with valid inventoryId under the field inventoryId inside inventories object Integer YES
quantityRequired Quantity required of that inventory to create that beverage Integer YES
  • Result - Ingredients object

3.3 Update Ingredients

  • URL - http://localhost:8080/ingredient/

  • Method - PUT

  • Purpose - Update ingredient of particular beverage.

  • Parameters - NONE

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
beverage Beverage object with valid beverageId under the field beverageId inside beverage object Integer YES
inventories Beverage object with valid inventoryId under the field inventoryId inside inventories object Integer YES
quantityRequired Quantity required of that inventory to create that beverage Integer YES
  • Result - Ingredients object

3.4 Get Single Ingredients

  • URL - http://localhost:8080/ingredient/{ingredientId}

  • Method - GET

  • Purpose - Retrieve information of single ingredient.

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
ingredientId must be a valid id of existing ingredients Integer YES
  • Result - Ingredients object

  • Parameters - NONE

3.5 Delete Ingredients

  • URL - http://localhost:8080/ingredient/{ingredientId}

  • Method - DELETE

  • Purpose - Delete an existing ingredient.

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
ingredientId must be a valid id of existing ingredients Integer YES
  • Parameters - NONE
  • Result - Boolean

3.6 Order Beverage

  • URL - http://localhost:8080/order/{beverageId}

  • Method - GET

  • Purpose - Orders a beverage with valid beverageId

  • Parameters - All parameters are permissible to send with request

Parameters Value Datatype Required
beverageId must be a valid id of existing beverage Integer YES
  • Parameters - NONE

  • Result - Ingredients object