Design a Photo Search and Download Frontend
Build the browser side of a free photo site: find photos by keyword, narrow them by tags and sort order, scroll a fast grid of images, and download the full-size file.
Problem statement
People visit a free stock-photo website, in the style of Unsplash, to find pictures and save them. Design its web frontend: how a visitor looks for photos, browses them as images, narrows and reorders the results, and gets the full-size file.
For this exercise, assume a search backend already exists. It returns pages of 30 photo summaries for a query, optional tags and a sort order (relevance, newest or most downloaded).
Each summary has an ID, the photographer's name, the width and height of the original, its average color, its tags, and an image URL on a CDN that can resize any photo to a requested width and serve modern image formats.
Photos come in every shape, from tall portraits to wide panoramas, and the grid must show each one in its own shape without cropping. A visitor can pick one or more tags and one sort order.
Downloading saves the original file, which averages 5 MB and can reach 30 MB, and every download must be counted once for the photographer.
Also assume visitors do not need to sign in, and the page must work on phones and desktops. Uploading photos, accounts, collections, likes and the backend's ranking are out of scope.
What to build
- A visitor types a keyword and sees matching photos; the address bar keeps the query, tags and sort so the page can be shared and the back button works.
- Results appear as a grid of images that keeps each photo's shape, shows a placeholder until the image loads, and loads more photos as the visitor scrolls.
- A visitor picks tags and a sort order, and the grid shows only results for the latest choice, never a mix of old and new results.
- A visitor downloads the full-size original with one click, sees that it is in progress, and each download is counted once.
At scale
- For this exercise, assume about 1 million visits a day, two thirds on phones, many on slow mobile networks, and that visitors often scroll through 10 or more pages of 30 photos.
- For this exercise, assume the first screen of photos should be visible within 2.5 seconds on a mid-range phone on a 4G connection, scrolling should stay smooth at 60 frames a second, and the page must not jump as images load.
- For this exercise, assume the search backend answers within 300 ms at the 95th percentile and the first screen should need no more than about 1.5 MB of image data.