Product design

Figma Specs: keep the design and the reason behind it together

Figma Specs is a collaborative document on the design canvas. Teams can bring requirements, screens and discussion together, then pass that context to developers or AI.

Break down the problem and try your own design and implementation first. Then explore the reasoning to check states, edge cases, trade-offs, and ways to test your approach. The guide offers a reasoning path, not a complete implementation.

01
CODE EXERCISEAdvanced

How can a document export follow references without omissions or endless loops?

Scenario: Design a handoff exporter for your own collaborative document system. A document can refer to other documents or design screens. The export needs to include all accessible referenced objects.

  1. Input contract: The input is an object table and starting ID from one fixed version snapshot. Each object has a unique non-empty ID, body and ordered list of reference IDs. There are at most 100,000 objects and 200,000 references. Access is checked per object; the snapshot and permission results remain fixed during export.
  2. Small example: A refers to B, C, D and E in that order. B refers to C; C refers back to A. D is inaccessible and E is missing. Explain how A’s export avoids duplicates and reports D and E.
  3. Constraints: Cycles are allowed. Collect only accessible objects. Do not read an inaccessible object’s body or traverse its references. Do not reveal whether an unavailable object exists by distinguishing “missing” from “no permission” to the user.
  4. Deliver: Traversal and deduplication reasoning, a deterministic output-order rule, a missing-item report, time and space complexity, and a test table. Do not provide a complete implementation.
Explore the reasoning
  1. Define the output order first. One option is breadth-first traversal in reference order, using a queue and a visited set. Mark an ID when it is discovered so it is not queued repeatedly. A, B and C each appear once.
  2. Check access before reading content. Present missing and inaccessible targets with the same “reference unavailable” result. Point only to a reference location the user could already see; do not return the restricted object’s title, body or number of references.
  3. Keep relationships without forcing the graph into a tree. An object list and reference relationships can represent shared nodes and references back to already visited objects. A cycle is not itself an error; endless traversal is.
  4. A fixed snapshot makes the result explainable. The exercise fixes both content and permissions. A real system without that guarantee needs version checks or an abort-and-retry policy; separate reads are not automatically consistent.
  5. Account for cost and test counterexamples. Assume amortized constant-time object lookup and permission checks. Let V be the number of input objects, E all input reference entries, and B the total bytes of exported bodies. Building an index and traversing has a safe upper bound of O(V+E); copying bodies adds O(B) time. The index, sets and output together take O(V+E+B) space. Restricted references must not be expanded, so actual work may be smaller. Test empty references, duplicate references, self-links, long chains and all targets unavailable. Explain how slower permission checks change the estimate.