Frontend

Nested Folder Explorer (Atlassian Frontend Interview) | Platform Round Problem

A commonly asked frontend problem in interviews at Fleek, Atlassian, and Zepto focuses on building a nested folder/file structure similar to an IDE. The task involves designing a data structure to represent folders and files, and rendering it recursively in JavaScript. It tests your understanding of tree structures, recursion, and UI state handling.

ByteAndBitesยทJul 04, 2026
Nested Folder Explorer (Atlassian Frontend Interview) | Platform Round Problem

This frontend interview problem is commonly posed by companies like Fleek, Atlassian, and Zepto. Candidates are tasked with building a Nested Folder Explorer, akin to the file management system found in Integrated Development Environments (IDEs) such as Visual Studio Code. The challenge assesses a candidate's grasp of tree structures, recursion, and state management in a user interface context.

Concepts

  • Tree Data Structure: The foundational model to represent folders and files hierarchically.
  • Recursion: A method for rendering nested folders, where each folder can contain more folders or files.
  • State Management (Expand/Collapse): Tracking the open or closed state of folders to control the display of their contents.
  • Rendering Nested UI: Properly displaying the hierarchy of files and folders in the UI through indentation.

Problem Breakdown

To build a Nested Folder Explorer, we need to design an effective data structure representing folders and their contents:

Solution

The approach consists of defining a tree-like data structure and employing a recursive function to render each node. Additionally, we'll implement the toggle logic to manage the expand/collapse state of folders.


Nested Folder and File explorer
Nested Folder and File explorer



Here's a simple structure for folders and files:

JavaScript
const data = [
    {
      name: "src",
      isFolder: true,
      children: [
        {
          name: "components",
          isFolder: true,
          children: [
            { name: "Button.js", isFolder: false },
            { name: "Card.js", isFolder: false }
          ]
        },
        {
          name: "utils",
          isFolder: true,
          children: [
            { name: "helper.js", isFolder: false }
          ]
        }
      ]
    },
    { name: "package.json", isFolder: false },
    { name: "index.html", isFolder: false }
  ];

Next, we will render this structure using a recursive function:


JavaScript
const root = document.getElementById("explorer");

function createNode(node) {
const div = document.createElement("div");
div.className = `node ${node.isFolder ? "folder" : "file"}`;
div.textContent = node.name;

if (node.isFolder) {
    const childrenContainer = document.createElement("div");
    childrenContainer.className = "children";

    node.children.forEach(child => {
    childrenContainer.appendChild(createNode(child));
    });

    div.addEventListener("click", (e) => {
    e.stopPropagation();
    childrenContainer.classList.toggle("open");
    });

    const wrapper = document.createElement("div");
    wrapper.appendChild(div);
    wrapper.appendChild(childrenContainer);

    return wrapper;
}

return div;
}

// Render root
data.forEach(item => {
root.appendChild(createNode(item));
});

HTML(index.html)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Folder Explorer</title>
  <style>
    .node {
    cursor: pointer;
    padding: 4px 0;
    }

    .folder::before {
    content: "๐Ÿ“ ";
    }

    .file::before {
    content: "๐Ÿ“„ ";
    }

    .children {
    margin-left: 16px;
    display: none;
    }

    .children.open {
    display: block;
    }
  </style>
</head>
<body>

  <div class="container">
    <h2>Folder Explorer</h2>
    <div id="explorer"></div>
  </div>

  <script src="./index.js"></script>
</body>
</html>

This JavaScript code creates a visual representation of the file system. Each folding element responds to clicks, toggling its expansion and collapse via inline styles.


Conclusion

By approaching this problem, interviewers aim to evaluate your understanding of data structures and how you manage state in a rendering context. Key takeaways include grasping recursive patterns, effectively managing UI states, and developing a minimal yet functional codebase. These skills are essential in real-world application development.


Similar Questions

InterviewJavascriptReactZeptoAtlassianFolder Structure
Frontend Interview Playbook ๐Ÿš€
Series
Frontend Interview Playbook ๐Ÿš€
View series
A curated series of real frontend interview questions from top companies like Google, Amazon, Uber, Atlassian, Roku, etc. Each blog breaks down problems, thought processes, and optimal solutions to help you master concepts, improve problem-solving, and confidently crack frontend interviews at leading tech companies.