Table of Contents
Guest post by Pavlo Sidelov, CTO of Cloud Wallet project.
Coffee vending machines, whether you love or hate them, are very convenient. That is when they are operational and not out of order because one of the ingredients has run out. After our coffee vending machine was left unstocked one too many times, I wanted to find a way to fix this.
After digging around online for a few very productive working hours, I understood that timely restocking is paramount in this low margin business. Restock too late, and there are many unhappy unserved customers. Too early, and you are running unnecessary costly deliveries to refill 20 ml of milk.
Lost sales and delivery costs add up very quickly when you manage more than a few machines. However, I found a way to address these shortfalls by implementing real-time inventory accounting using our latest development, the Cloud Wallet.
Here’s How I Built a Smart Coffee Machine with Cloud Wallet
Our coffee vending machine has four ingredients we can monitor: coffee beans, water, milk, and cups. When we brew a cup of coffee, some or all of those are consumed in exchange for payment in cash. We can monitor ingredient expenses and cash income by attaching separate wallets to each of those variables.
The dashboard provides a quick overview of all wallets in your project.
Our wallets act just like accounts. They record the currently available amount of something valuable, as well as all incoming and outgoing movements of value. This functionality allows us to access real-time inventory data and all of the previous transactions as well.
The Customer wallet section shows the real-time balance and status of your wallets.
We began by preloading the machine with all the necessary ingredients. Each available drink type has its price and uses up a different amount of ingredients. For example, an americano won’t consume milk, but a cappuccino will.
Wallet balances for ingredients are loaded, and the coffee machine is ready to go.
"Wallet API state:", "waterwallet : 1000000", "milkwallet : 1000000", "beanswallet : 1000000", "cupswallet : 1000000", "cashwallet : 0",
The same balances are shown as data from the server.
Making a Purchase
We modeled a purchase as a complex transaction. First, it consumes the required amount of each ingredient by removing (redeeming) value from its wallets. Second, it creates (issues) value and adds it to the cash wallet as a reflection of the accepted payment.
Purchasing any drink will show that the balances of the ingredients have been reduced and the cash balance has increased. In the example below, we have purchased a $4.00 americano, which consumed a dose of beans, one cup, some water, and added value to the cash wallet.
A purchase of a $4.00 americano redeems value from ingredient wallets and adds value to the cash wallet.
Wallet history shows water consumption on a given day. Every transaction is recorded, timestamped, and can be accessed at any point in time.
Inventory wallets after multiple transactions.
Restocking the Machine
When the machine is restocked, the supplier’s wallet will be credited for the value of the goods that were restocked from the machine’s cash wallet. The restock transaction will also create value in the inventory wallets.
Each complex transaction will follow one basic rule: the whole transaction will be completed only if each operation in it can be performed. Should any single operation be impossible (for instance, if one of the wallets had a low balance) the whole transaction will fail without affecting any wallet.
Efficient inventory control can ensure that consumers get their coffee when they need it. Vendors, on the other hand, can minimize the time vending machines spend unstocked and maximize the number of potential sales.
One quick and easy integration with Cloud Wallet can not only improve the inventory management process but maximize returns with intelligent vending.
Interested in making your own IoT project? Check out Cloud Wallet on the RapidAPI Marketplace.