← Stripe Interview Insights

Stripe·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Jun 2026

Summary

Stripe system design round for a software engineer role. The main problem was about role-based access control with hierarchical accounts, which sounds clean on paper but gets messy fast when you start thinking about scale.

Questions Asked (1)

Q1

You have a list of (userId, accountId, role) assignments and a tree of parent-child account relationships where roles inherit downward. Given a userId and accountId, return all effective roles that user has on that account, including inherited ones from ancestor accounts. Then discuss the tradeoffs between walking the ancestor chain at query time versus precomputing a rolled-up role table, and how hierarchy depth affects complexity.

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

I started with the naive ancestor walk because it felt more intuitive to explain.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and defining the data structures, then walk through the query-time ancestor traversal algorithm and its complexity. Next, propose a precomputed rolled-up role table and compare tradeoffs, emphasizing how hierarchy depth impacts performance and consistency. Finally, discuss hybrid approaches and practical considerations for Stripe's scale.

Pro tip: Mention that in real systems, role assignments and hierarchy changes are relatively infrequent compared to reads, so precomputing with incremental updates is often the better choice. Also, highlight the importance of handling cycles and orphaned accounts gracefully.

1. Clarify requirements and data model

Ask about the scale (number of users, accounts, depth), read/write ratio, and whether the hierarchy is static or dynamic. Define the input structures: a list of direct role assignments and a tree (or forest) of account relationships.

2. Design query-time ancestor traversal

Explain how to find all ancestor accounts of the given accountId (e.g., via parent pointers or a recursive CTE), then collect roles from direct assignments on those ancestors. Analyze time complexity: O(d * r) where d is depth and r is roles per account, plus O(d) for traversal.

3. Design precomputed rolled-up role table

Propose a table that stores, for each (userId, accountId), the set of effective roles including inherited ones. Describe how to build it (e.g., DFS from roots, propagating roles downward) and how to update it incrementally when assignments or hierarchy change.

4. Compare tradeoffs and complexity

Discuss query-time traversal: simple, always consistent, but slow for deep hierarchies and high read volume. Precomputed table: fast reads, but requires maintenance and can become stale; updates may be expensive if hierarchy changes affect many descendants. Complexity: query-time O(d), precomputed O(1) read but O(n) update in worst case.

5. Recommend a hybrid or optimized approach

Suggest a hybrid: precompute for frequently accessed accounts or cache results with invalidation on changes. Alternatively, use materialized paths or closure tables to speed up ancestor queries. Emphasize monitoring and adapting based on actual depth and access patterns.

Key Points to Mention

  • Time complexity of query-time traversal: O(d * r) where d is depth and r is roles per account; space complexity O(1) extra.
  • Precomputed table tradeoffs: O(1) read, but update cost O(k) where k is number of affected descendants; risk of stale data.
  • Hierarchy depth impact: deep trees make query-time traversal slow; precomputation update cost grows with subtree size.
  • Handling dynamic changes: incremental updates vs. full rebuild; use of versioning or timestamps for consistency.
  • Cycle detection and orphaned accounts: ensure tree is valid; handle missing parents gracefully.
  • Caching strategies: memoize ancestor chains or role sets per account; use LRU cache with TTL or invalidation on writes.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.