KatInterview

Design a User Photo Library and Album Service

System DesignModel answer
MediumModel answerSystem Designobject-storagecdnsharding

Last updated

Design a scalable backend for storing, organizing, and retrieving user photos and albums, covering API design, storage, data modeling, and reliability.

Problem

Build the backend for a personal photo library product. Users need to upload photos, browse their collection, and keep things organized with named albums.

Core features your design must support

  • Upload a photo (JPEG, HEIC, or PNG, up to ~50 MB per file).
  • View a photo in its original form as well as smaller resized versions, along with its metadata: dimensions, file size, capture timestamp, camera model, and GPS coordinates.
  • Create, rename, and delete albums. Deleting an album does not delete the photos inside it.
  • Add and remove photos from albums. One photo can appear in multiple albums (many-to-many relationship).
  • List photos in an album, or browse the full personal library, in reverse chronological order with pagination.
  • Delete a photo. It must disappear from every album it belongs to.

What to cover in your answer

  1. Requirements and scale — state your assumptions, then derive rough numbers for upload rate, storage growth, and read throughput.
  2. API design — endpoints, request/response shapes, and any important protocol choices.
  3. Data model — tables or collections, primary keys, indexes, and how you handle the many-to-many relationship between photos and albums.
  4. High-level architecture — how the components fit together from upload to delivery.
  5. Two or more deep dives — pick the areas with the most interesting trade-offs, for example: durability guarantees, consistency after writes, media processing pipeline, storage cost at scale, or CDN caching strategy.

Explicit constraints

  • Losing a user's photo is unacceptable. Durability is the highest priority.
  • Library and album listings should be fast: target p99 under 200 ms.
  • After a user uploads a photo or adds it to an album, that user must see the change immediately (read-after-write consistency for the owner).
  • Photo content is private by default. Sharing, search, and face recognition are out of scope, but briefly note how you would extend toward them.

Hints

Hint 1

Blob bytes and metadata have very different access patterns and scale characteristics — split them into different storage systems from the start, and think about what each one is optimized for.

Hint 2

Almost every query is scoped to a single user (list my photos, list my album). That constraint should directly inform how you partition or shard the metadata store.

Hint 3

A pre-signed URL pattern lets clients upload directly to object storage, keeping large binary data off your application servers entirely — think through what the client and server each do in that flow, and what happens if the client never finishes the upload.