---
# System prepended metadata

title: Fresh Food workflow

---

---
title: Fresh Food workflow
---

Fresh Food workflow

```sequence
Admin -> BackOffice: Create Machine
BackOffice -> Backend: Call API Create Machine
Backend -> BackOffice: Response API Create Machine
Admin -> BackOffice: Create Products
BackOffice -> Backend: Call API create products
Backend -> BackOffice: Response API create products
Admin -> Machine: Go to and add products to machine
Admin -> BackOffice: Add products to machine
BackOffice -> Backend: Call API add products to machine
Backend -> BackOffice: Response API add products to machine
User -> Machine: selecte products, amount
Machine -> User: response products's price
User -> Machine: Payment
Note right of Machine: If payment failed, go to screen failed.
Machine -> MQTT Broker: Puslish topic PAYMENT
Backend -> MQTT Broker: Subscrible topic PAYMENT
Backend -> Backend: Save payment info to sales table
Machine -> Machine: Opened door -> dropped products
Machine -> MQTT Broker: Puslish topic OPEN_DOOR, send data product position drop
Backend -> MQTT Broker: Subscrible topic OPEN_DOOR
Backend -> Backend: Update products, position product, status of machine
BackOffice -> MQTT Broker: Subscrible topic OPEN_DOOR
BackOffice -> BackOffice: Update status of machine
Machine -> Machine: Closed door
Machine -> MQTT Broker: Puslish topic CLOSE_DOOR
Backend -> MQTT Broker: Subscrible topic CLOSE_DOOR
Backend -> Backend: Update status of machine
BackOffice -> MQTT Broker: Subscrible topic CLOSE_DOOR
BackOffice -> BackOffice: Update status of machine

Machine -> MQTT Broker: Puslish topic TEMPERATURE, send machine temperature every 15 min
Backend -> MQTT Broker: Subscible topic TEMPERATURE
Backend -> Backend: Save alram
Backend -> Admin: If the temperature rises above +4 Celsius then it has to alarm by send email and SMS to admin
BackOffice -> MQTT Broker: Subscible topic TEMPERATURE
BackOffice -> BackOffice: Show alamr

Backend -> Admin: Send alarm by email and SMS when product expiried
Backend -> Backend: Save alram
Backend -> MQTT Broker: Puslish topic PRODUCT_EXPIRED
BackOffice -> MQTT Broker: Subscrible topic PRODUCTS_EXPIRED
BackOffice -> BackOffice: Show alarm

Backend -> Machine: Check Machine status (online, offline)
Note right of Backend: If machine status is online, not thing.
Backend -> Backend: Save alarm
Backend -> Admin: Send alarm by email and SMS when machine offline
Backend -> MQTT Broker: Puslish topic MACHINE_OFFLINE
BackOffice -> MQTT Broker: Subscrible topic MACHINE_OFFLINE
BackOffice -> BackOffice: Show alarm, update machine status
```