Design Trending Collaborative Files
Company: Figma
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
# Design Trending Collaborative Files
Design a service that ranks currently trending collaborative files. Use the following scale and product rules as practice assumptions rather than claims about a particular product.
### Constraints & Assumptions
- Events include qualified opens, edits, comments, shares, and unique active users.
- Rankings are personalized only by access control and locale; the core trend score is global or workspace-local.
- The list refreshes within five minutes and supports hourly, daily, and weekly windows.
- Billions of raw events arrive per day.
- Private file activity must never reveal a file to an unauthorized user.
### Clarifying Questions to Ask
- What behavior should "trending" reward instead of merely "popular"?
- Is the ranking global, per workspace, per locale, or per user?
- How fresh and stable should the list be?
- How should bots, repeated refreshes, deleted files, and newly created files be treated?
### Part 1: Metric and Contract
Define a trend score, windows, eligibility, tie-breaking, and the read API. Explain how you would validate the metric before launch.
#### Hints
- Separate recent acceleration from lifetime popularity.
#### What This Part Should Cover
- Measurable product objective
- Deterministic ranking semantics
- Privacy and eligibility
### Part 2: Streaming Aggregation and Ranking
Design ingestion, deduplication, windowed aggregation, top-k computation, storage, and backfill.
#### Hints
- Exact global sorting of every file on every event is unlikely to be necessary.
#### What This Part Should Cover
- Scalable event and window model
- Candidate reduction
- Late-event and replay strategy
### Part 3: Abuse, Reliability, and Serving
Handle event spikes, hot files, manipulation, permission changes, stale data, and observability.
#### Hints
- A ranking can be available while a particular result is no longer eligible.
#### What This Part Should Cover
- Defense in depth against gaming
- Fail-safe serving behavior
- Quality and pipeline monitoring
### What a Strong Answer Covers
- A trend definition tied to a product goal
- Windowed streaming architecture with deterministic replay
- Efficient top-k computation and permission-safe serving
- Abuse controls, backfill, degradation, and online/offline validation
### Follow-up Questions
- How would you personalize trends without creating a per-user stream job?
- How would you explain why a file is trending?
- How would you prevent a single huge workspace from dominating a global list?
- How would you change the design for second-level freshness?
Quick Answer: Design a service that ranks currently trending collaborative files from billions of daily events. Define a trend metric, windowed streaming aggregation, deterministic top-k computation, late-event replay, abuse controls, and permission-safe serving that never exposes private activity.