← Lessons

quiz vs the machine

Gold1350

System Design

User Preference And Opt Out

Storing per user per category choices so notifications respect what people want.

5 min read · core · beat Gold to climb

Preferences as a matrix

Users want control over what they hear about and how. The model is usually a matrix of category by channel: marketing email on, product push off, security alerts always on.

Storing choices

  • A preference store keyed by user and category holds the allowed channels.
  • Defaults apply when a user has never chosen, often opt in for marketing and on for critical alerts.
  • Some categories are mandatory, like security or legal notices, and cannot be disabled.

Enforcing at send time

Before any channel worker runs, the processing layer checks preferences and drops or reroutes the message. Doing this once in the core prevents teams from accidentally bypassing a user opt out.

Edge cases

A user may opt out of a channel entirely, like all SMS, which overrides per category settings. Preference changes must take effect quickly, so caches need short lifetimes or invalidation.

Key idea

User preferences form a category by channel matrix the core enforces at send time so opt outs are always respected.

Check yourself

Answer to earn rating on the learn ladder.

1. How are preferences usually modeled?

2. Why enforce preferences in the core processing layer?

3. What is special about mandatory categories?