KatInterview

Design a Context-Aware Restaurant Recommendation Engine

System DesignModel answer
MediumModel answerSystem Designsystem-designrecommendation-systemsmachine-learning

Last updated

Design an end-to-end personalized restaurant discovery and search service balancing geo-constraints, low-latency ranking, real-time context, and hybrid search architectures.

Context

You are building the personalized recommendation and search engine for a large-scale food delivery application. When users launch the application, they expect an instantaneously loaded, personalized home feed featuring local restaurants tailored to their historical preferences, current time of day, weather, and physical location.

Requirements

  • Functional:
    • Deliver a personalized recommendation feed updated in real time based on user context (current delivery location, temporal signals, order history).
    • Provide hybrid search functionality matching text queries (e.g., "spicy ramen", "vegan breakfast") constrained by localized delivery boundaries.
  • Non-Functional:
    • Latency: Latency for the home feed recommendation must remain strictly below 200 ms (p99).
    • Scale: Support peak load (lunch/dinner rushes) reaching up to 12,000 queries per second (QPS) across tens of millions of active users.
    • Freshness: Dynamic factors such as store open/closed state, current estimated delivery time (ETA), and overload status must reflect changes within seconds.

Deliverables

Provide a detailed structural design covering:

  1. Scale Estimation & System Constraints: Throughput, latency budget, and domain data characteristics.
  2. Data Modeling & Storage Strategy: Entities, indexing techniques (especially spatial filtering), and online/offline data separation.
  3. Retrieval & Ranking Architecture: Multi-stage pipeline (candidate retrieval, feature retrieval, ranking, and post-ranking business rules).
  4. Machine Learning & Personalization Strategy: Feature engineering, offline training vs. real-time feature updating, and cold-start mitigations.
  5. Hybrid Search Architecture: Semantic/vector search integration alongside traditional keyword retrieval.
  6. System Evaluation: Offline validation metrics and online A/B testing methodologies.

Hints

Hint 1

Spatial constraints reduce the active candidate pool drastically before any ML ranking takes place. Leverage geospatial indexing (like Uber H3 or S2) to pre-filter.

Hint 2

Split the architecture into multi-stage pipelines: cheap candidate generation (recall-oriented) followed by heavy scoring (precision-oriented).

Hint 3

Never run large LLMs directly on the critical serving path for feed generation. Precompute embeddings and use lightweight online models.