Frontend System Design1 min readPremium

Design a Voting Widget – Frontend System Design

Design a Voting Widget - Frontend System Design

We’ll walk through the frontend system design for an embeddable poll widget. Our goal is a question with 2–8 options, one vote per user (or per browser if they are anonymous), results as percentages after voting, and optional live tallies as other people vote. This is a widget interview, not a social network. The hard parts are isolation from the host page, an idempotent vote, and optimistic UI that can roll back.

You’ll see the host snippet, the Shadow DOM versus framed-embed trade-off, the vote API, and how we keep a thousand embeds from polling every second. We’ll stay at widget scale: one poll per embed, a small tally payload, and a uniqueness constraint the client does not get to enforce alone.

Problem Statement

Design a poll widget that can be embedded on any website.

Requirements:

  • A question with 2–8 options
  • One vote per user (or per browser if they are anonymous)
  • Results as percentages after voting
  • Optional live updates as others vote

Describe the embed, the vote API, and optimistic... premium content.

Premium

Keep reading with Premium

Get the rest of this guide plus every premium question, solution, and system design deep dive.

  • All premium solutions
  • System design deep dives
  • Company-specific prep

4.9/5 from our users