Use Case Diagram for the Vending Machine

Learn how to define use cases and create the corresponding use case diagram for the vending machine.

Let’s build the use case diagram for the vending machine and understand the relationship between its different components.

First, we’ll define the different elements of our vending machine, followed by the complete use case diagram of the system.


Our system is a "Vending machine."


Now, we’ll define the main actors of our vending machine.

Primary actors

  • Customer: This actor can view, select and take products, insert money, and take out change from the machine.

  • Operator: This actor can do everything a "Customer" can do. It can also add or remove products and remove cash from the machine.

Secondary actors

  • System: This actor can search for the selected product and dispatch it after validating money.

Use cases

In this section, we will define the use cases for the vending machine. We have listed down the use cases according to their respective interactions with a particular actor.

Note: You will see some use cases occurring multiple times because they are shared among different actors in the system.


  • View products: To view all available products in the vending machine

  • Select products: To select a product to buy from the vending machine

  • Insert money: To insert money to buy products from the vending machine

  • Take product: To take out products from the vending machine

  • Take change: To take out change from the vending machine


  • Add product: To add new products inside the vending machine

  • Remove product: To remove products from the vending machine

  • Cash remove: To remove collected cash from the vending machine


  • Search product: To search for the selected product in the machine to dispatch it

  • Validate money: To validate that the money is legal

  • Dispense product: To dispense selected products so customers can take them

  • Return change: To return the change to the customer if the inserted amount is less than the purchased product price


This section describes the relationships between and among actors and their use cases.


The customer and operator are two actors who interact with the vending machine. The consumer can only engage with the system to purchase a product. An operator can execute all the duties that a customer can, along with certain administrative responsibilities. Therefore, the “Operator” actor has a generalization relationship with the “Customer” actor.


The below table shows the association relationship between actors and their use cases.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.