KatInterview

Architecting a Public and Token-Shared Prompt Library

System DesignModel answer
MediumModel answerSystem Designsystem-designcachingauthorization

Last updated

Design a scalable prompt-sharing platform supporting public, private, and secret-link access with instant token revocation and high-throughput read caching.

Create the technical architecture for a web application where creators can manage, store, and distribute AI prompts. The platform must accommodate public discovery, strict private ownership, and secure, revokable token-based sharing.

Core Requirements

  1. Content Management: Users can create, view, modify, and soft-delete prompts.
  2. Access Control: Prompts can be marked as Public (globally indexed) or Private (restricted to owner).
  3. Link Sharing: Private items can be shared using randomly generated secret URLs. Anyone with a valid link can view the prompt.
  4. Forking: Registered users can duplicate any accessible prompt (public or shared link) into their own personal space.

System Performance & SLA Constraints

  • High read-to-write ratio (~100:1).
  • Near-instant (sub-second) revocation when a shared link is disabled by the owner.
  • Search queries over public prompts must be fast and responsive, never exposing private or newly-revoked items.
  • The platform must handle traffic spikes when individual prompts go viral.

Deliverables

  • Scale & Capacity Estimation: Rough estimates for bandwidth, storage, and throughput.
  • Data Model: Storage paradigm selection, schema details, and authorization design.
  • API Interfaces: Primary endpoints for prompt lifecycle, sharing, and search.
  • Architecture & Caching Strategy: System flow, multi-layer caching, and instantaneous access revocation.
  • Hot-Key Mitigation: Engineering solutions for handling viral public content.

Hints

Hint 1

Decouple prompt identity from access tokens so link revocation doesn't modify prompt IDs.

Hint 2

Distinguish public content caching rules (CDN-friendly) from link-shared content caching rules (never cache at CDN layer).

Hint 3

Hash secret share tokens before storing them in the database to prevent token leakage.