Skip to content

Backend

kaiqi-eng edited this page Dec 7, 2024 · 6 revisions

Backend Wiki

the backend uses Express.js and the Node.js framework in order to communicate with a PSQL database

Routes

/chat

Post request Handles queries for the LLM of panda bot. pass in a query param as a string and will recieve a string in JSON

/manager

Get request home of manager

/manager/get_all_employees

Get request gets a list all employee data, returned as a JSON array Example: [{"employeeid":12,"full_name":"Victoria Garcia","email":"[email protected]","phone_number":"625-817-203","hourly_wage":"20.00","position":"Employee"},{"employeeid":13,"full_name":"Joseph Maynard","email":"[email protected]","phone_number":"504-677-338","hourly_wage":"20.00","position":"Employee"}]

/manager/recent_sales_today

Get request gets a list of the 5 most recent orders submitted today (according to system time) returned as a JSON Example:[{"date_time_ordered":"2024-12-07T20:54:13.000Z","order_number":97438,"price":"11.30"},{"date_time_ordered":"2024-12-07T20:51:19.000Z","order_number":97514,"price":"1.00"},{"date_time_ordered":"2024-12-07T20:48:52.000Z","order_number":97599,"price":"5.20"},{"date_time_ordered":"2024-12-07T20:45:56.000Z","order_number":97585,"price":"9.80"},{"date_time_ordered":"2024-12-07T20:42:06.000Z","order_number":97406,"price":"19.30"}]

/manager/combos_today

Get request gets a list of the number of each combo ordered today (according to system time) as a JSON Example: {"bowl":30,"plate":46,"bigger plate":45,"a la carte":148,"family meal":2,"panda cub meal":0,"party platter":9}

/manager/get_menu_items

Get request gets a list of all menu items as a JSON array Example: [{"item_serial_number":1,"item_name":"Chow Mein","item_type":"Sides","availability":true},{"item_serial_number":2,"item_name":"Fried Rice","item_type":"Sides","availability":true},{"item_serial_number":5,"item_name":"Hot Ones Blazing Bourbon Chicken","item_type":"Entrees","availability":true},{"item_serial_number":7,"item_name":"Black Pepper Sirloin Steak","item_type":"Entrees","availability":true},{"item_serial_number":8,"item_name":"Honey Walnut Shrimp","item_type":"Entrees","availability":true}]

/manager/get_menu_item_names

Get request gets a list of the names of all the menu items as a JSON array Example: [{"item_name":"Chow Mein"},{"item_name":"Fried Rice"},{"item_name":"Hot Ones Blazing Bourbon Chicken"},{"item_name":"Black Pepper Sirloin Steak"},{"item_name":"Honey Walnut Shrimp"}]

/manager/get_cheapest_option_prices

Get request gets the price of the cheapest item of a given menu option as a array Example:[8.3,9.8,11.3,5.2,8.5,11.2,43,6.6,41,108,154,194,4.4,5.4]

/manager/get_employee_name/:id

Get request gets the employee name given the ID number in params

/get_employee_id/:name

Get request gets the ID of the employee given the name of the employee in params

/manager/add_employee

Post request adds a new employee to the database given a JSON of the attributes in body Example: {"employeeid":12,"full_name":"Victoria Garcia","email":"[email protected]","phone_number":"625-817 203","hourly_wage":"20.00","position":"Employee"}

/manager/remove_employee/:id

Delete request deletes an employee given the id of the employee in params

/manager/update_name/:id

Put request updates the employee's name given the id in params of the employee and the new name in body

/manager/update_email/:id

Put request updates the employee's email given the id in params of the employee and the new email in body

/manager/update_phone_number/:id

Put request updates the employee's phone number given the id in params of the employee and the new phone number in body

/manager/update_wage/:id

Put request updates the employee's wage given the id in params of the employee and the new wage in body

/manager/update_position/:id

Put request updates the employee's position given the id in params of the employee and the new position in body

/manager/get_ingredients

Get request gets all the ingredients used given the type of combo and the item ordered in query Example: {ingredient_serial_number : ingred_serial, ingredient_servings : ingred_servings, utinsels : servs}

/manager/zReport

Get request creates a zReport given the start and end times in params Example: {"11 AM":201.6,"12 PM":427.6,"1 PM":761.8,"2 PM":979.3,"3 PM":1340.6999999999998,"4 PM":1692.4999999999998,"5 PM":1909.2999999999997,"6 PM":2175.8999999999996,"7 PM":2444.7999999999997,"8 PM":2737.6699999999996,"9 PM":2924.6699999999996}

/manage/xReport

Get request creates a xReport for the current day Example: [{"start_time":"10:00 AM","end_time":"10:59 AM","total_orders":"20","total_cost":"201.60","total_items":45},{"start_time":"11:00 AM","end_time":"11:59 AM","total_orders":"23","total_cost":"226.00","total_items":68},{"start_time":"12:00 PM","end_time":"12:59 PM","total_orders":"24","total_cost":"334.20","total_items":70},{"start_time":"01:00 PM","end_time":"01:59 PM","total_orders":"17","total_cost":"217.50","total_items":53},{"start_time":"02:00 PM","end_time":"02:59 PM","total_orders":"20","total_cost":"361.40","total_items":65},{"start_time":"03:00 PM","end_time":"03:59 PM","total_orders":"24","total_cost":"351.80","total_items":57},{"start_time":"04:00 PM","end_time":"04:59 PM","total_orders":"20","total_cost":"216.80","total_items":64},{"start_time":"05:00 PM","end_time":"05:59 PM","total_orders":"13","total_cost":"266.60","total_items":33},{"start_time":"06:00 PM","end_time":"06:59 PM","total_orders":"17","total_cost":"268.90","total_items":61},{"start_time":"07:00 PM","end_time":"07:59 PM","total_orders":"22","total_cost":"292.87","total_items":85},{"start_time":"08:00 PM","end_time":"08:59 PM","total_orders":"18","total_cost":"187.00","total_items":49}]

/manager/add_menu_item/:name/:type/:availability

Get request adds menu item given params

/manager/add_ingredients/:name/:type/:ingredients/:servings

Get request adds an ingredient entry to the database given params

/manager/edit_price/:item/:option/:price

Get request changes the price of an item given params

/manager/getInventoryUsage

Get request gets the inventory usage given a time range in query Example usage: startTime : "00:00:00" endTime : "11:11:11"

/manager/getInventoryUsage

Get request gets the sales report list of items given a time range in query Example usage: startTime : "00:00:00" endTime : "11:11:11"

/submit

home of submit order

/submit/submit order

Post request submits an order given the cart in body Example usage: types = ['bowl', 'plate'] -> options items = 'mushroom chicken','chow mein'] ,['orange chicken', 'fried rice', 'super greens' -> items asscoiated with each option

/total-price

Get request gets the total price of the order given params in query Example usage: types = ['bowl', 'plate'] -> options items = 'mushroom chicken','chow mein'] ,['orange chicken', 'fried rice', 'super greens' -> items asscoiated with each option