This table will slightly change due to region
ChangeInventory{
machine_id: 10 bytes
pennies: 2 bytes
nickels: 2 bytes
dimes: 2 bytes
quarters: 2 bytes
dollar: 2 bytes
5_dollar: 2 bytes
10_dollar: 2 bytes
}
Machine{
machine_id: 10 bytes
uuid: 10 bytes
rows: 70 bytes
columns: 50 bytes
change_inventory: 50 bytes
spot_capacity: 2 bytes
disability_mode: 10 bytes
supported_payments: 30 bytes (cash, card, both)
}
182 bytes
Item{
machine_id: 10 bytes
row: 2 bytes
column: 2 bytes
item_id: 10 bytes
item_name: 50 bytes
item_price: 5 bytes
item_stock: 3 bytes
item_type: 10 bytes
}
92 bytes
Camera{
machine_id: 10 bytes
footage_id: 10 bytes
date: 10 bytes
footage_data: 2GB
}
2GB
Alert{
machine_id: 10 bytes
alert_message: 50 bytes
date: 10 bytes
}
70 bytes
MaintenanceRequest{
machine_id: 10 bytes
reason: 100 bytes (jammed machine, out of stock item etc)
email: 50 bytes
}
MaintenanceAccess{
machine_id: 10 bytes
uuid: 10 bytes
date: 10 bytes
}
20 bytes
Receipt{
receipt_id: 10 bytes
payment_type: 10 bytes
card_information: 10 bytes
date: 10 bytes
}
40 bytes
Lets assume a machine can hold the same amount of an item in every slot. We get an average of 10 users per day. We have around 1000 machines in over 10 countries. A machine can have a max of 7 rows and 5 columns. Assume 10 year lifespan
(182 +92*35)*1000 + 2gb * 10 * 1000 + (40*10)*1000*10 = 20 terabyte (most of this data caused by camera data. We can reduce this by deleting camera footage after uploading it to a storage solution like amazon s3
BuyProduct(machine_id,row,column,money_inserted,card_information) -> Will check if cash inserted into the machine is enough and send an error message if it isn't. Will then call the DispenseChange() endpoint. If the card information goes through, it will charge the card and dispense the product
AccessibilityMode() -> There will be a button lower on the screen that opens up a similar ui at eye level for wheelchair users
RequestMaintenance(machine_id, reason)
RecordCameraFootage(date, footage_data, machine_id) -> If motion is detected infront of the machine, start recording security footage and store it
OpenMachine(uuid, machine_id,date) -> Opens maintenance locks on the machine if a user inputs the machine's unique uuid value
DispenseChange(machine_id, input_money)-> If physical cash is input into the machine and change is needed, this function will check the machine's change deposits to output the required change. If the machine does not have the required change, it will display an error saying so and not accept the payment and return the user's money
GenerateAnalytics(machine_id) -> Uses data on the items on a specific machine to generate graphs and analytics on selling metrics on the items in the machine. Utilzes amazon athena for this
ChangeInventory{
machine_id: 10 bytes
pennies: 2 bytes
nickels: 2 bytes
dimes: 2 bytes
quarters: 2 bytes
dollar: 2 bytes
5_dollar: 2 bytes
10_dollar: 2 bytes
}
SupportedPayments{
'cash':'cash'
'card':'card'
'both':'both'
}
Machine{
machine_id: string
uuid: string
rows: Item[]
columns: int
change_inventory: ChangeInventory
spot_capacity: int
disability_mode: boolean
supported_payments: SupportedPayments
support_email: string
}
Item{
machine_id: string
row: int
column: int
item_id: string
item_name: string
item_price: float
item_stock: int
item_type: string
}
Camera{
machine_id: string
footage_id: string
date: datetime
footage_data: mp4?
}
Alert{
machine_id: string
alert_message: string
date: datetime
}
MaintenanceRequest{
machine_id: string
reason: string (jammed machine, out of stock item etc)
}
MaintenanceAccess{
machine_id: string
uuid: string
date: datetime
}
Payment{
payment_id: string
item_id: string
machine_id:string
date:datetime
}
Receipt{
receipt_id: string
payment_id: string
payment_type: string
card_information: string
date: datetime
}
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
RequestMaintenance -> This function will make use of user input as well as built in sensors the machine has in order to alert an admin of any issues with the machine such as a stuck product or any damage/out of inventory.
RecordCameraFootage -> This function records footage once someone is in range of its built in motion sensor. It records this footage onto its 2GB built in memory. Once the interaction has completed, the footage is uploaded to an online service like Amazon S3 and deleted off the machine's memory. Once on amazon s3, there are further deletion policies based on the traffic of the machine
I chose to trade off dynamic data structures of a non relational database in order for a more structured format of a relational database like sql since we will mostly have static data. Sql also is more efficient at providing analytical data for services like amazon athena. Sql is also able to define relationships between tables for more comprehensive data modelling while also allowing us to scale efficiently if needed by sharding. Relational databases also provide robust security features for sensitive user data
I choose to use an online storage such as amazon s3 to hold camera footage since we will get a lot of footage based on traffic and can adjust the price we pay to store footage based on location. This also further reduces the space needed on our vending machines to hold footage in memory