Define what APIs are expected from the system...
# upload/download photo
uploadPhoto(user_id, photo_content, created_at) -> photo_id
downloadPhoto(photo_id) -> photo_content (bytesIO)
# user searches for specific photo/s
getPhotos(user_id, search_query) -> list of photo_ids matching search criteria
# follow other users
followUser(user_id, target_user_id) -> boolean
unfollowUser(user_id, target_user_id) -> boolean
# personalized feed
getPersonalizedFeed(user_id) -> list of photo_ids
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...
Photo table:
User Table:
UserFollow table:
Key observations:
Decisions:
Relational vs Non-relational
Photo Storage
Data Size estimation per table :
for 10 years, total storage -> 3.7TB
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...
flowchart TD
B[client] -- upload image --> IHS(Image Hosting Service)
IHS --> D[(Image Storage)]
IHS --> M[(Image Metadata)]
B[client] -- View/search image --> IHS(Image Hosting Service)
IHS -- search result --> B
R(Recommendation Service) --> D
R(Recommendation Service) --> M
R(Recommendation Service) -- news feed --> B
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...
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...
Image hosting Service (IHS) :
CDN :
Caching :
News Feed ranking:
flowchart TD
B[client] -- request --> LB{Load Balancer}
LB --> IHS(Image Hosting Service)
IHS --> readAPI
IHS --> writeAPI
readAPI --> D[(Image Storage)]
readAPI --> M[(Image Metadata)]
writeAPI --> D[(Image Storage)]
writeAPI --> M[(Image Metadata)]
B --> Cache[Cache]
Cache --> CDN(Content Delivery Network)
CDN --> D
B --> R[Recommend service servers]
R --> UNF[(user news feed)]
B -- get latest feed --> UNF
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?