Design the search function for a large-scale food delivery platform similar to Uber Eats.
A user opens the app and types queries such as:
-
Restaurant names (e.g., "Joe's Pizza"),
-
Cuisines (e.g., "Thai", "Sushi"),
-
Dish names (e.g., "cheeseburger", "pad thai").
The system must return a ranked list of relevant restaurants (and possibly dishes) that can deliver to the user's location.
Requirements
Functional requirements
-
Users can search by:
-
Free-text query (restaurant name, cuisine, or dish).
-
Current location; results should be only from restaurants that deliver to that area.
-
Support filters and sort options, such as:
-
Open now / closed.
-
Price range, rating, delivery time estimate, distance.
-
Results should be ranked by:
-
Text relevance.
-
Distance / delivery ETA.
-
Restaurant popularity and rating.
-
(Optionally) user personalization.
-
Data changes that affect search:
-
New restaurants and menus being added.
-
Menu or availability changes (e.g., items out of stock, restaurant closed/open) should reflect in search reasonably quickly.
Non-functional requirements (assume a large city / multi-city deployment)
-
Low latency: P95 search latency under ~200 ms from the service (excluding network to client).
-
High availability: search should continue to work even if some components fail.
-
Scalability: support millions of users, tens/hundreds of thousands of restaurants, and high queries per second.
Describe the high-level design of such a system, covering:
-
Overall architecture and major components.
-
Data modeling and indexing strategy.
-
Query flow from the client to returned results.
-
How you keep the search index fresh when restaurants/menus/availability change.
-
Approaches to ranking and personalization.
-
Scaling and reliability considerations.