Skip to the guide

Design an in-memory file system

IntermediateCase study11 pages

The interviewer asks you to build a small file system in memory, with folders, files, move and find. Picture a family's storage room full of boxes, where a box can hold papers and smaller boxes. Each box has a list on its lid that names what is inside. To move a box, you cross one line off one lid and write one line on another, and nothing inside the box changes.

It is also asked as "design the Unix find command". The closest other case study is the key-value store, which keeps flat keys where this page keeps a tree. Interviewers like it because a tree tests Composite, a search tests how you combine rules, and a move has edge cases most people miss. Once files must outlive the process or reach many machines, it stops being a class question, and File storage and sync owns that system.

Below is a full 45-minute round on the LLD framework. At each Guess before you read on, stop and answer first. The full runnable project is a download in Java, JavaScript and Python.

Run the full project

This design as a project you can run, with its tests and a demo. You only need Java 21, Node 24 or Python 3.13. The README says how to run it.

Step 1 · Clarify the requirements and cut the scope

Minutes 0–5 · How this step works

Interviewer: Build an in-memory file system.

You: What must it do?

Interviewer: Make folders, write and read files, list, delete, move, give the size of anything, and find files by name and size.

You: What do paths look like? Is there a ..?

Interviewer: Full paths only, like /docs/a.txt, with no ... Names use letters, digits, dots, dashes and underscores.

You: What if a move's new name is taken, and what does a delete do to a full folder?

Interviewer: A move onto a taken name is refused, and a delete takes everything in the folder.

You: How big is it, and do many threads call it?

Interviewer: About 100,000 files in 10,000 folders, about ten levels deep, and one folder can hold 5,000 entries. Many threads share one process.