User interface for translating language
Able to translate inputted language into target language
Supports multiple languages
Able to detect input language
Able to serve thousands of request per second.
Able to support offline translation mode.
Let's calculate the necessary system capacity based on these parameters:
translate(words, targetLanguage)
The translate APIs will take in an array of words and target language and returns the translated array of words.
We will assume that we have an existing translation engine that would perform the translation for us. The main place where we would use a store would be to cache common translations. We can store frequently translated phrases or sentences in a data store, and improve response time by quickly retrieving commonly requested translations.
User interface for user to submit their input for translation. This could be web or mobile.
The load balancer is responsible for balancing request between different instances of the backend service.
This is where the backend service take the request and direct it to the appropriate service. This is essentially a BFF.
Translation service is where it looks up the cache for existing translation or direct the request to the translation engine.
The translation engine is responsible for translation on the fly. This could be a third party service such as amazon translate or google translation service.
The translation engine decides whether to store the response into the Redis cache. The translation service grabs data from the Redis cache is it's able to find it.
The most interesting component is probably the translation engine and translation service.
If we are using third party solution such as amazon translation or google translation then the translation engine would be pretty trivial as we would implement integrate with these services. However if we are rolling our solution we would have incorporate advanced technologies and techniques such as machine learning to translate different languages.
This also means that the client would first utilize offline translation whenever it can and only make request when offline translation isn't sufficient.
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?