KatInterview

Building a Tenant-Isolated Vault for Confidential PDF Review

System DesignModel answer
MediumModel answerSystem Designsystem-designaccess-controlmulti-tenancy

Last updated

Design a backend for sharing sensitive PDFs across organizations with fast permission revocation, per-viewer watermarks, and a tamper-evident record of every access.

Context

Law firms and corporate teams exchange large numbers of confidential PDFs during acquisitions, lawsuits, and regulatory reviews. They need a hosted vault where outside parties can read documents but cannot freely copy them. Design the backend for such a service.

What the system must do

  1. Hierarchy and tenancy. Organizations own rooms, rooms contain folders, and folders contain PDF documents. Many organizations share the platform.
  2. Fine-grained permissions. Support role-based and attribute-based rules (for example Admin, Collaborator, View-Only, Watermarked-Only). Removing someone's access must take effect right away.
  3. Protected delivery. Viewers must never obtain the raw file unless their role allows it. Every view carries a user-specific watermark (user ID, timestamp, IP address) and pages are displayed in the browser one at a time.
  4. Audit trail. Record every access event (document opened, page viewed, download attempted, permission changed) in an append-only log that makes tampering detectable.

Non-functional targets

  • First page visible in under a second, even for files up to 500 MB.
  • No data leakage between tenants, with cryptographic isolation at rest and in transit.
  • Permission changes and revocations effective globally within 1 second.
  • 99.99% read availability for rooms with active reviews.

Scale assumptions

  • 5,000 organizations and 50,000 active rooms.
  • 50 million PDFs, averaging 25 MB, with a maximum of 500 MB.
  • Peak of 10,000 concurrent reviewers producing about 2,000 document/page requests per second and about 500 audit events per second.

What to cover in your answer

  • How permissions are evaluated, cached, and invalidated.
  • How PDFs are ingested, converted into protected page images, watermarked, and streamed.
  • The data model for tenants, rooms, grants, documents, and audit records.
  • The pipeline that stores high-volume audit events in a tamper-evident way.
  • The trade-offs between direct storage download and proxied delivery, and between client-side and server-side watermarking.

Hints

Hint 1

Work out the numbers first: total storage, rendered page volume, egress bandwidth, and audit bytes per day. Then identify which two requirements (1-second revocation, sub-second first page on huge files) rule out the obvious designs.

Hint 2

Think about why a long-lived pre-signed storage URL conflicts with instant revocation. Consider a short-lived ticket that proves identity, plus a per-request authorization check against a versioned policy that is pushed to every serving node.

Hint 3

Separate the expensive work from the per-user work: render pages once at ingest and store them encrypted, then apply only the cheap watermark overlay per request. For the audit log, consider hash chaining plus write-once storage.

Hint 4

Prefix every storage key and cache key with the tenant ID, and use per-tenant encryption keys, so a single bug cannot expose another tenant's data.