Coffee Balance System

to maintain a sustainable fund of coffee bean for the espresso machine.

Background.

We have an espresso machine in the lab and it's perfect to start a productive day with a cup of coffee! In order to make this sustainable, we have to maintain a fund for purchasing coffee beans. Since I rarely use cash for years, I feel inconvenient to put cash in a jar for every espresso. So why not write an app to keep everyone's account balance so that we can just click and enjoy the coffee!

Design.

The convenience and data safety are the first priorities of this coffee balance system. For convenience, we have to sacrifice identity protection which requires extensive authentication procedure like entering a password. However, with data safety we're able to reduce this risk, by sharing all history transactions with users so that they can report a fraud transaction and we can recover that.

Note that this system assumes everyone is honest, so it's simple to design some of the public interfaces. However, it's also important to protect the money of everyone (including the users and also the manager who kept money for us). So I use two separate database tables:

  • coffee_usage for transactions without real money, e.g. getting an espresso. This table is public with web API, so everyone in Yale Secure Network can make a transaction without any authentication.
  • management_transaction for transactions with real money, e.g. purchasing coffee bean, depositing into account, etc. This table is private and can only be accessed with SSH.

Note that both tables are insert-only. Any update on the table is generally forbidden, in order to have a trace of everything. The whole information of the database is dumped everyday at 10:00pm and send a management report email to coffee.balance.system@gmail.com, a gmail account for this system. Also, the same information is send to manager's email every Friday at 10:00pm. Any user who wants a copy of that information can request from the manager, either once or on a weekly basis. The management report email is like this (both database dump and table visualization):

User can choose to receive an email reporting their balance update at the espresso machine, which is like:

Implementation.

TODO:

Avatar
Yue Wu
2-nd Year Ph.D.

My research interests concentrate on computer systems, including quantum control systems, wireless systems and embedded systems.