Design Suggestion Underlines Over Text Fields You Do Not Own

Last updated: November 29, 2026

Quick Overview

Design the frontend architecture for a browser extension that draws suggestion underlines and cards over arbitrary text inputs, textareas and contentEditable editors on third-party sites, keeping them aligned as the user types, scrolls and resizes.

Grammarly
System Design
Frontend Engineer
Grammarly
November 29, 2026
Frontend Engineer
System Design Round
System Design
Medium

0

0

0 solved


Design the frontend architecture for a browser extension that draws suggestion underlines and cards over arbitrary text inputs, textareas and contentEditable editors on third-party sites, keeping them aligned as the user types, scrolls and resizes.

Grammarly's extension has to work inside Gmail, Google Docs, LinkedIn and thousands of sites whose DOM it cannot change safely. The interviewer is checking whether you understand overlay rendering versus DOM mutation, how to map text offsets to screen rectangles, and how to stay fast on heavy pages.

What the Interviewer Expects
  • Prefer an overlay layer over mutating the host editor's DOM
  • Explain how to map text offsets to rectangles for textarea versus contentEditable
  • Keep positions in sync on input, scroll, resize and layout shifts efficiently
  • Isolate styles with Shadow DOM so host CSS cannot break the UI
  • Discuss per-site adapters and a fallback when an editor is unsupported
Key Topics to Cover
overlay rendering
Range.getClientRects
MutationObserver
Shadow DOM
performance budgets
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • How do you handle editors like Google Docs that render text to canvas?
  • How do you avoid fighting the host editor's own undo stack when applying a fix?
  • How do you measure that underlines are misaligned in the field?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Detect editable fields, extract text with stable offsets, draw underlines per suggestion, open a card on hover or click, apply a replacement as if the user typed it. Must not break the site, must not ...

High-Level Design

A content script discovers fields via focus events. A field adapter per editor type exposes getText(), offsetToRects(start, end), and replace(start, end, text). Text and deltas go to a backg...


Submit Your Answer
Markdown supported

Related Questions