Skip to content
tezvyn:
Menu

Add a Pro plan and gate features

Source: interviewMediumHow cards are made

Summary

clean feature gating and entitlements.

Key points

model plans and entitlements as data, enforce server-side via a central check, decouple the gate from feature code.

Watch out for

scattering isPro checks through the codebase or trusting the client.

What's really being asked

This examines whether you can design entitlements that scale beyond two tiers and resist becoming spaghetti. The naive approach, a boolean isPro checked inline everywhere, breaks the moment a third plan or a per-feature add-on appears. The interviewer wants a data-driven, server-enforced design.

The full answer

Introduce a subscription or plan entity associated with the user, carrying plan type, status, and renewal data synced from the billing provider. Rather than checking the plan name directly in features, model capabilities as named entitlements, such as can_export or max_projects, and map each plan to a set of entitlements. Features then ask one question, does this user have this entitlement, through a single central authorization service. This decouples feature code from plan structure, so launching a third tier is a data change, not a code sweep. Enforce every gate on the backend; the client may hide a button for UX, but the server is the source of truth because clients can be bypassed. Handle plan changes, downgrades, and lapsed payments by recomputing entitlements from current subscription state.

The mistakes people make

Adding a boolean isPro and writing if checks across the codebase. Gating only in the UI, leaving the API open to anyone who calls it directly. Hard-coding plan names into features, so every new tier touches every feature.

What usually comes next

How do you handle a user who downgrades mid-cycle? Where do you cache entitlements for performance? How does the billing provider's webhook keep plan state current?

A concrete example

A user upgrades to Pro. Stripe sends a webhook; your backend updates the subscription record and recomputes their entitlements to include can_use_advanced_export and a higher project quota. When they hit the export API, a central check confirms the entitlement and allows it. Later you add a Team tier purely by defining a new entitlement set, no feature code changes.

Interview question

Why model paid capabilities as named entitlements mapped to plans instead of checking a boolean isPro flag inside each feature?

  • a.Booleans cannot be stored in a relational database
  • b.Named entitlements are always faster to evaluate than a boolean
  • c.isPro checks must run on the client, which is insecure
  • d.Entitlements decouple features from plan structure, so adding a third tier is a data change, not a code sweepCorrect
Why?

Entitlements let plans map to capability sets, so new tiers require only data changes while features ask one stable question. The distractors are wrong: booleans store fine, evaluation speed is not the issue, and any gate, boolean or not, must be enforced server-side.

Just read this? Test yourself on what you have been reading.

Read the original → veldsystems.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles