Design a Mobile Weather Forecast App
Show phone users the weather and forecast for their places in one quick screen, keep working without a connection, and push severe weather warnings to the people in harm's way.
Problem statement
For this exercise, assume you are building a weather app for phones and the backend behind it. Users sign in and save up to 10 places, such as home and work. When a user opens the app, it shows, for the current position or a saved place, the conditions right now, the next 48 hours hour by hour, and the next 7 days.
A user can also turn on severe weather alerts for any saved place and then gets a push notification when a warning covers that place.
For this exercise, assume the company buys its data from one weather data provider. Every hour, the provider publishes a new forecast file for about 1 million points on a grid about 5 km apart, and it sends severe weather warnings as they are issued, each with an ID, an area on the map and an end time.
A warning can later be updated, for example to cover a larger area, or canceled.
On a weak or missing connection, the app should still show the last forecast it loaded and say how old it is. You do not build the forecast model, weather maps, ads or the provider's systems.
Design the app's data flow and the backend, from the provider's files and warnings to the user's screen and notifications.
What to build
- A user can open the app and see current conditions, a 48-hour hourly forecast and a 7-day forecast for their current position or a saved place.
- A signed-in user can save, rename and remove up to 10 places and sees the same list on every phone they sign in on.
- A user who turned on alerts for a saved place gets one push notification when a severe weather warning starts to cover that place.
- Without a connection, the app shows the last forecast it loaded for each place together with the time it was updated.
At scale
- For this exercise, assume 5 million daily users. About half of them open the app between 6:00 and 8:00 a.m. and load about 3 forecast screens each, and the busiest minute of those two hours has about three times their average rate.
- For this exercise, assume a forecast screen should load within 300 milliseconds at p95 on a good connection, and a new hourly forecast should reach users within 10 minutes of the provider's file arriving.
- For this exercise, assume one large warning can need up to 2 million pushes (one for each saved place with alerts on, on each of the user's phones), and every one should go out within 1 minute of the warning arriving.
- For this exercise, assume many users are on a limited data plan or a slow network, so the app should make one small request per screen and avoid downloading data it already has.