List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
For a web-based service like Google or Amazon Search, the number of searches per second is very high - 10 million per second approx
Number of search words or phrases in a language = 1 million approx
Average size of 1 word = 10 bytes
Amount of storage for storing 1M words/phrases = 10 MB
This is a read-only system for an end-user. A user never updates the suggestion system. This is a stateless service
Define what APIs are expected from the system...
GET https://
Response - a trie of top ranked suggestions
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
This is a read-heavy system.
Given the volume of data and number of concurrent requests, a NoSQL Database using Key-Value Store is suitable for the system.
Key:
word/phrase. --- String
Value:
rank. ---- long
In-memory, the suggestions are stored using a 'Trie' data structure.
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Overall Architecture
===============
User: End-user which performs the search and gets suggestion. The user may or may not search with the available suggestions.
Client Plugin: The type-ahead suggestion system has a client plugin which runs on the client's browser or app. This is required to avoid latency where each character typed by the client is sent to server and the response is obtained back. This can be an AJAX plugin.
Suggestion Service: Service running on the Server. The client plugin gets a set of suggestions from the service on startup.
Suggestions DB: Persistent store of suggestions for each word and phrase
Search: When the user presses 'Enter' the requested word or phrase is given to the Search service. Search service provides feedback to the Suggestion Service to build its vocabulary and rank the suggestions.
Components in the Suggestion System
===============================
Ranker: Assigns a rank to each word or phrase based on how frequently it is used, most recent searches by a user, trending searches etc. Results with higher rank are displayed first.
Vocabulary Builder: Adds new words and phrases as users use them to Search.
Both Ranker and Vocabulary Builder use feedback from the Search system.
Cache: A cache of trending searches, recent searches etc.
De-duplication: A periodic job which de-duplicates the phrases which mean the same, for example - 'restaurants near me' and 'nearby restaurants'.
Suggestions DB: Persistent Store of words and phrases offered as suggestions.
The suggestion system uses a combination of static and dynamic words/phrases to build the suggestions.
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Initial Startup Before Any Feedback is Available
=====================================
Subsequent Searches
==================
How many suggestions are provided?
The Suggestion system can provide the top 5 suggestions for each phrase to the client, to avoid overflowing the Client's memory.
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
The suggestion system stores suggestions as 'tries'. Each node has an associated rank .
Overall Architecture
===============
User: End-user which performs the search and gets suggestion. The user may or may not search with the available suggestions.
Client Plugin: The type-ahead suggestion system has a client plugin which runs on the client's browser or app. This is required to avoid latency where each character typed by the client is sent to server and the response is obtained back. This can be an AJAX plugin.
Suggestion Service: Service running on the Server. The client plugin gets a set of suggestions from the service on startup.
Suggestions DB: Persistent store of suggestions for each word and phrase
Search: When the user presses 'Enter' the requested word or phrase is given to the Search service. Search service provides feedback to the Suggestion Service to build its vocabulary and rank the suggestions.
Components in the Suggestion System
===============================
Ranker: Assigns a rank to each word or phrase based on how frequently it is used, most recent searches by a user, trending searches etc. Results with higher rank are displayed first.
Vocabulary Builder: Adds new words and phrases as users use them to Search.
Both Ranker and Vocabulary Builder use feedback from the Search system.
Cache: A cache of trending searches, recent searches etc.
De-duplication: A periodic job which de-duplicates the phrases which mean the same, for example - 'restaurants near me' and 'nearby restaurants'.
Suggestions DB: Persistent Store of words and phrases offered as suggestions.
The suggestion system uses a combination of static and dynamic words/phrases to build the suggestions.
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?