← Grammarly Interview Insights

Grammarly·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Apr 2026

Summary

System design round at Grammarly for a software engineer role. The question was a beast, basically three separate design problems rolled into one, and they wanted wire-level API specs across all of them.

Questions Asked (1)

Q1

Design a Google Sheets-style collaborative spreadsheet with an AI chat interface that can edit the sheet via natural language commands. Cover the real-time collaboration layer, the LLM inference and prompt engineering layer, and a tool-calling protocol layer. Define the wire-level APIs and all parameters across all three.

System DesignAPI & IntegrationsTechnical Trade-offs
Author's notes

This one is basically three system design interviews duct-taped together.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and scale, then architect the system in three layers: real-time collaboration (CRDT/OT, WebSocket sync), LLM inference (prompt engineering, context management, streaming), and tool-calling protocol (function schemas, validation, execution). For each layer, define wire-level APIs with concrete parameters, and discuss trade-offs (consistency vs. latency, cost vs. accuracy, safety vs. flexibility).

Pro tip: Emphasize idempotency and conflict resolution in the tool-calling layer—LLM-generated commands may be retried or duplicated, so design APIs with idempotency keys and version checks to prevent unintended edits. Also, mention that you'd log all LLM interactions for debugging and fine-tuning, but anonymize data to respect privacy.

1. Clarify Requirements and Scope

Ask about expected user scale, latency requirements, supported natural language commands, and security/compliance needs. Define what 'collaborative' means (e.g., concurrent editing, presence, comments).

2. Design Real-Time Collaboration Layer

Choose a sync protocol (CRDT vs. OT), define WebSocket message formats for operations, presence, and cursor updates. Specify parameters like client ID, document version, operation type, and payload.

3. Design LLM Inference and Prompt Engineering Layer

Outline how to convert user chat into structured commands: system prompt design, context window management (sheet state, history), and streaming responses. Define API endpoints for chat and inference with parameters like model, temperature, max tokens.

4. Design Tool-Calling Protocol Layer

Define a set of tools (e.g., updateCell, insertRow) with JSON schemas, validation rules, and execution flow. Specify how the LLM's output is parsed, validated, and applied to the sheet, including error handling and idempotency.

5. Define Wire-Level APIs and Discuss Trade-offs

For each layer, specify REST/WebSocket endpoints, request/response formats, and parameters. Discuss trade-offs: CRDT vs. OT, synchronous vs. asynchronous tool execution, and cost/latency of LLM calls.

Key Points to Mention

  • Real-time collaboration: CRDT (e.g., Yjs) vs. OT, WebSocket for bidirectional sync, presence and cursor tracking, conflict resolution.
  • LLM inference: prompt engineering with few-shot examples, context window management (summarization, retrieval), streaming for responsiveness, fallback strategies.
  • Tool-calling protocol: JSON schema for tools, function calling (OpenAI-style), validation and sanitization, idempotency keys, versioning to prevent stale edits.
  • Wire-level APIs: WebSocket messages for ops (e.g., {type: 'op', clientId, version, op: {type: 'setCell', row, col, value}}), REST for chat (POST /chat with {message, sheetId, history}), and tool execution endpoints.
  • Security and permissions: authentication, authorization (who can edit what), rate limiting, and audit logging.
  • Scalability and performance: sharding by document, caching sheet state, batching operations, and handling LLM latency with optimistic UI updates.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.