0%
Product Architecture Interviews: User Flows, APIs, Data Models, Feeds, Real Time and Privacy
Privacy, Permissions and Abuse
Product architecture interviews nearly always include a moment where the interviewer asks who can see something. Who can see a post from a private account? Does a blocked user still see my comments on a friend's post? If I delete a photo, does it disappear from search? These questions are not side issues. They test whether your design treats privacy as a property of the data that holds everywhere, or as a check that one screen happens to perform.
This lesson covers the rules (visibility, blocking, muting), how to enforce them cheaply on every read, how to delete and export a user's data, how to slow down abuse with rate limits and spam signals, and how moderation and audit trails fit into the architecture. Lesson l04 introduced visibility fields in the schema; here you make them hold under real traffic.
Visibility as a rule, not a field
The schema from l04 might store a visibility value on each post: public, followers, close friends, or only me. That value is necessary but not sufficient. Whether a particular viewer can see a particular post depends on more than the post. It depends on the relationship between viewer and author (do they follow, is the follow approved, has either blocked the other), the author's account state (private, suspended, deactivated), the post's own state (published, under review, removed), and sometimes the context (a post inside a group the viewer has left).
So the real rule is a function: can viewer V see object O right now? Write it down in the interview in plain language, for example:
Writing the rule out makes the edge cases visible, and interviewers often probe exactly those: blocks in both directions, removed posts that only the author can see, and the interaction between a public post and a private account.
Every read path, not just the obvious one
A product has many doors to the same object. The home feed, the author's profile grid, a direct link, search results, hashtag pages, notifications ("Alex liked your photo" shows a thumbnail), comment threads, share sheets that embed previews, the recommendations module, and data exports. A privacy bug almost never happens on the main screen that everyone tested. It happens on the fourth door: search returns a private post because the index was built from an older snapshot, or a notification preview shows a photo after the author blocked the viewer.
The architectural answer is a single policy component that every read path calls, rather than each service reimplementing the rule. It can be a library linked into every service or a small policy service with a batch API; the important property is one implementation of the rule, tested once, and used everywhere. When the product adds a new visibility option, such as close friends, it changes in one place.
Filter at read time or at write time
There are two places to apply the rule. At write time, you only put an object where an authorized viewer will find it: fan out a followers only post only to approved followers' feeds, and index a private account's posts in a search index partition that is queried only on the author's behalf. At read time, you check every object before returning it.
Write time filtering is cheaper per read but goes stale. If someone blocks a follower after fan out, the post is already in the follower's feed store. Read time checks are always current but cost work on every request. Strong designs use both: write time filtering to avoid obviously wrong placements, and a read time check as the final gate, because only the read time check sees the state at the moment of viewing. Say this explicitly. It shows you understand that denormalized data, which l04 and l05 encouraged for speed, carries a privacy cost.
Over fetch to keep pages full
Read time filtering creates a product problem: if the feed fetched 20 candidates and the check removed 4, the page has 16 items and the client may think it has reached the end. The usual fix is to over fetch, for example asking the feed store for 30 candidates to return 20, and to make the cursor point past the last candidate examined, not the last item returned, so the next page does not re show removed items.
If filtering removes a lot, which can happen for a viewer who has blocked many accounts, loop and fetch more, with a cap so a pathological case cannot scan forever. This is a detail worth one sentence in an interview, and it often impresses because it connects privacy to pagination (l03) and feeds (l05).
Changes in visibility
Visibility changes over time, and each change needs a defined effect. When an author switches their account from public to private, existing followers stay, new followers need approval, and the posts disappear from search, hashtag pages and non followers' views. When an author narrows a post from public to followers, the same happens for that post. When a post is removed by moderation, it disappears everywhere except perhaps for its author, who sees a notice.
Because every read path calls the policy at read time, these changes take effect immediately for reads. Caches and indexes catch up asynchronously: an event such as post.visibility_changed triggers search reindexing and cache invalidation. Mention also that CDN copies of media for private content are protected by short lived signed URLs, as covered in l07, so the media itself stops being reachable within the expiry window.
Visibility of derived content
Visibility applies to more than posts. Likes, comments, shares and reposts are content derived from a post, and they inherit its visibility. If a public user comments on a private user's post, that comment is visible only to people who can see the post, even though the commenter's account is public. A notification that says "Sam commented on Alex's photo" must not reach a viewer who cannot see Alex's photo. Counters are a subtle case: showing a follower count for a private account is usually acceptable, but a list of likers on a private post is visible only to people who can see the post. Making derived content inherit visibility from its parent object, through the same policy call, keeps these cases consistent without a special rule for each one.
What the interviewer is checking
In this part of the interview, interviewers commonly look for three things. Can you state the visibility rule precisely, including blocks and account states? Do you enforce it on every read path through one shared component, rather than in each feature? And do you understand the interaction between denormalized read models and privacy, with a read time check as the final gate? A candidate who covers those three in a couple of minutes, then offers to discuss cost, has handled the topic well.
A worked example of a leak
Consider a concrete bug that this design prevents. A user posts a photo publicly, it is indexed in search, and an hour later they switch their account to private. In a design where search results are returned straight from the index, a stranger who searches the user's hashtag still sees the photo until the next reindex, which might be hours away. The user did exactly what the product offered to protect themselves and it did not work, which is the kind of failure that ends up in the press.
With a read time policy check, the search service fetches candidate ids from the index, passes them through the same batch policy call the feed uses, and drops the photo because the author is now private and the stranger is not an approved follower. The index catches up later through the visibility changed event, which reduces wasted candidates, but correctness never depended on it. Telling this story in an interview, in three or four sentences, is a vivid way to show why the final gate sits at read time.
Saying can_see(viewer, object) out loud, with blocks, account state and post state as inputs, turns a vague privacy discussion into a precise one. It also gives you one thing that every read path must call, which is the architecture answer interviewers want.