Frontend School

Interactive Org Chart Viewer

Machine Coding
easy

Interactive Org Chart Viewer

Easy
Org Chart Tree
Frontend
React
Tree Traversal

Overview

Amazon's scale demands clear visualization of its vast organizational structure. Understanding reporting lines is crucial for team collaboration and navigating internal processes. This problem asks you to build a simple web component to display a hierarchical organizational chart. This exercise assesses your ability to structure UI components, handle hierarchical data, and manage state for interactive elements, which are fundamental skills for building many internal tools at Amazon.

What you need to do / Task

  1. Render the Org Chart: Display a tree-like structure representing the reporting hierarchy. Each node should clearly show the employee's name and title.
  2. Expand/Collapse Functionality: Implement a toggle mechanism (e.g., a button or icon) next to each manager's name. Clicking this toggle should expand or collapse their direct reports. Initially, only the top-level manager should be expanded, showing their direct reports. All other sub-levels should be collapsed.
  3. Visual Indication: When a manager's reports are collapsed, there should be a clear visual indicator (e.g., a + symbol or an arrow pointing right). When expanded, a different indicator (e.g., a - symbol or an arrow pointing down) should be displayed.

UI/UX expectations

  • Layout: Use a simple nested list or div structure to represent the hierarchy. Indentation should clearly show reporting lines.
  • Interactions: The expand/collapse toggle should be easily clickable.
  • Accessibility: Ensure the toggle is keyboard-navigable and has appropriate ARIA attributes (e.g., aria-expanded).
  • Styling: Basic styling for readability and visual hierarchy is sufficient. No need for elaborate designs, but the structure should be clear.

Acceptance criteria

  • The root employee (CEO) is always visible.
  • Initially, only the CEO's direct reports are visible; all other sub-levels are collapsed.
  • Clicking an expand/collapse toggle correctly shows/hides the direct reports of that employee.
  • The visual indicator for expand/collapse accurately reflects the current state.
  • Each employee node displays their name and title.
  • The UI remains responsive and functional during interactions.

Constraints

Constraints & assumptions

  • The input data will be an array of Employee objects, where each employee has a unique id, a name, a title, and an optional managerId pointing to their direct manager. The CEO will have managerId: null.
  • The hierarchy will always be valid (no circular references, a single root).
  • The maximum depth of the org chart is small (e.g., 5-7 levels).
  • Performance for very large trees is not the primary concern, but avoid exponential complexity.
  • You must use React for the UI implementation.
  • No external UI component libraries (e.g., Material UI, Ant Design) are allowed; build components from scratch.

Out of scope

  • Searching or filtering employees.
  • Editing or adding employees to the chart.
  • Drag-and-drop functionality.
  • Deep styling or pixel-perfect design matching Amazon's internal tools.

What interviewers evaluate

  • Component Design: Ability to break down the problem into logical, reusable React components.
  • State Management: Effective use of React state to manage UI interactivity (expand/collapse).
  • Data Handling: Correctly processing and rendering hierarchical data.
  • Clean Code: Readability, maintainability, and adherence to React best practices.

Loading editor...