No design is good or bad, it’s just about the fulfilment of the requirement in optimised way

If you have been asked or preparing for system design interviews and looking for perfect system design for food delivery app or service then find out what perfect means for you. So, as the first part of any system design process, we’ll proceed to find what this service or app must perform.

Step 1: Requirement Gathering

So a basic food delivery service should have these features-

  1. Restaurant Listing and Search – Users can search for a restaurant
  2. Food Listing and Search – Can search for foods in the restaurant
  3. Order and Payment – Can order food and make payment
  4. Delivery – Can track the delivery

Now based on the requirements we are having, let’s try to find out the users involved-

  1. Back-end Service Agent – For restaurant listing
  2. Restaurant Owners – Food Listing
  3. Customers – Ordering
  4. Delivery Executive – Delivery of food

Now that we found our end users and also the services we are offering. Let’s try to design the architecture to fulfil it-

Here we have our Service to handle all the requirements and MySQL as database. Its the simplest System design anyone can think of for this type of app.

Is there anything wrong here? No This can serve our needs but what will happen if we grow? Millions of orders? at that point, our system will not able to scale.

So, to design a system we must find out the scalability required, for 10 orders per day our above system is very good. It is a wrong practice to design the above system without having scalability considerations.

So, let’s dive into the next step-

2. Understanding Scalability requirement

This understanding helps us decide how to break our service, which database to use, and other requirements.

For this, we should think of these questions-

What will be the geographical scaling i.e. is this app for the purpose of serving only a city or in future the vision is to grow globally? – Let’s assume it is planned Globally

How many Customers are we expecting in the short and long term?  – 1 billion

How many Restaurants? – 1 million

How many searches and orders a day? – 1 billion searches and 2 million orders a day can go up to 5 million a day

Based on all of these we can calculate which all components are critical and required to have isolated responsibility?

From the above figures, we get to understand that we must build a scalable application that can handle a huge customer base and must make the restaurant searchable and must separate out the order processing service as traffic can vary.

Step 3: Coming up with Design

In the scalable design process, first identify the users and the platform they’ll be using and then move the the service requirement.

Food Delivery Service Design – Step 1 – User Identification

In the second step, Identify from where the primary data will get populated. In this case, restaurants will be listed from the backend team. The data will be store in Restaurant store.

Step 2 – Primary data source

In this case, Primary data i.e. Restaurant owners will be adding and managing food inventory.

Step 3 – Primary Data population

Once the food is listed, Delivery executes are required to pick it from the nearest location and deliver. Their Location is required to be updated at interval of few seconds.

Step 3 – Delivery Executive Location update

Once the primary data is available, the customer who is the consumer of the data is required to search from all the data. These data needs to be searchable. Using a pipeline data to be indexed and made searchable.

Step 4- Data Indexing

Once the data is indexed to be consumed, customer can start searching the data.

Step 5 – Searching the data

Once customer searched the data and selected what to be ordered, they’ll order and make payment.

Step 6 – Ordering

One the order is placed, as a final step, it’ll be assigned to delivery executive and to restaurant owner for preparation. They’ll get notification to prepare and deliver.

Step 7 – Supply Chain

This design suffice the use cases we discussed in the beginning. But there are be multiple possible design and use cases which can be added. Restaurant order acceptance, Customer notification, Customer delivery Update and 100s of use cases are possible. But the important use case is covered in the above design.

Please share review or discuss by commenting in the comments below.

Leave a Reply