How to properly implement a small scale food ordering service?
Answered
Broken Nokia posted this in #help-forum
Context:
Tech Stack is NextJS, Mongo and Express for the http server.
I'm building a food ordering platform for a small community with an in-house cafe/kitchen.
How do I process orders so that every new order is displayed to the kitchen immediately while also logging orders in a database.
I'm relatively inexperienced when it comes to backend development, currently my thoughts are to make a new entry in the database collection for every new order and delete them once the order is completed. The kitchen's frontend will constantly fetch the latest list of "pending orders" from the database collection and will allow the kitchen staff to delete the entry from the database by marking it as served.
All orders will be logged in a separate collection in the database for future reference.
I understand that this is a very inefficient and likely flawed way to go about this task.
Any advice on how to do this is much appreciated.
Tech Stack is NextJS, Mongo and Express for the http server.
I'm building a food ordering platform for a small community with an in-house cafe/kitchen.
How do I process orders so that every new order is displayed to the kitchen immediately while also logging orders in a database.
I'm relatively inexperienced when it comes to backend development, currently my thoughts are to make a new entry in the database collection for every new order and delete them once the order is completed. The kitchen's frontend will constantly fetch the latest list of "pending orders" from the database collection and will allow the kitchen staff to delete the entry from the database by marking it as served.
All orders will be logged in a separate collection in the database for future reference.
I understand that this is a very inefficient and likely flawed way to go about this task.
Any advice on how to do this is much appreciated.
Answered by Yacare Caiman
For a kitchen the “real-time” update doesn’t actually need to be real time, a fifteen or so second delay between a user ordering and it appearing on the screen realistically isn’t gonna matter
7 Replies
Sun bear
I think its common way to have at least two tables:
- orders
- orderitems
So every order has at least on order item. Depending on the size and how you handle products there could also be a product table and a user table as well 😅
I would not delete order entries. Better work with status like "pending, completed, archived"
Then only show pending orders on the screen.
- orders
- orderitems
So every order has at least on order item. Depending on the size and how you handle products there could also be a product table and a user table as well 😅
I would not delete order entries. Better work with status like "pending, completed, archived"
Then only show pending orders on the screen.
@Sun bear I think its common way to have at least two tables:
- orders
- orderitems
So every order has at least on order item. Depending on the size and how you handle products there could also be a product table and a user table as well 😅
I would not delete order entries. Better work with status like "pending, completed, archived"
Then only show pending orders on the screen.
What do you say is the best way to have real time updates on the kitchen's end so that they get an order request as soon as someone places one?
@Broken Nokia What do you say is the best way to have real time updates on the kitchen's end so that they get an order request as soon as someone places one?
Catla
You can get the data updated on the front end for your kitchen staff by polling or using web sockets which is better for real-time updates.
Thank you
Yacare Caiman
For a kitchen the “real-time” update doesn’t actually need to be real time, a fifteen or so second delay between a user ordering and it appearing on the screen realistically isn’t gonna matter
Answer
Yacare Caiman
Just have the kitchen poll every like ten seconds or so