KatInterview

Design a Prompt Editor with Versioning and Collaboration

System DesignModel answer
HardModel answerSystem Designdatabase-schemaversioningobject-storage

Last updated

Build a web app for writing, executing, and versioning LLM prompts with efficient storage for large documents and incremental edits.

You're building a web application that lets users compose prompts for large language models, execute them, and manage their work over time. Users need to create new prompts, modify them iteratively, run them against an LLM to see results, and collaborate with colleagues.

Your system must handle the full lifecycle: drafting, running, saving versions, retrieving past work, and enabling others to view or build upon existing prompts.

Begin with the fundamental architecture and database schema. The discussion will then progress through specific challenges: handling documents that may reach hundreds of kilobytes, enabling collaboration features, and optimizing storage when users make small character-level changes to large documents repeatedly.

Requirements

Work through each section in order, keeping responses focused on the current challenge:

Section 1: Foundation Design the core system components and database schema. Cover APIs for creating, modifying, saving, listing, and executing prompts. Show how you'd structure entities, relationships, and indexes.

Section 2: Scale Considerations Some documents grow quite large. Explain how your design adapts to store and retrieve them efficiently without degrading performance.

Section 3: Collaboration Add functionality for users to grant others access to their prompts. Define the semantics (snapshot vs live, read vs write permissions) and show how you'd implement access control.

Section 4: Incremental Changes When a user makes dozens of single-character edits to a 500KB document, saving after each one, naive approaches waste enormous storage. Present storage strategies—full copies versus deltas—and discuss where each lives (database vs object storage) with their trade-offs.

Clarification Points

Before diving in, consider:

  • Does a prompt include just text, or also model selection and generation parameters?
  • What's a realistic size range and hard limit for prompt documents?
  • Should all historical versions be preserved and accessible indefinitely?
  • Must every execution be perfectly reproducible with its exact input and configuration?
  • When collaborating, can recipients modify the original, or do they work with copies?

State your assumptions where specifics aren't provided.

Hints

Hint 1

Think about when to use relational storage versus blob storage based on size thresholds and access patterns

Hint 2

For versioning with small edits, consider delta encoding but also when to materialize full snapshots to bound reconstruction cost

Hint 3

Separate the concept of a prompt template from individual execution runs—they have different lifecycles and access patterns