Skip to content
Low Level Design Mastery Logo
LowLevelDesign Mastery

Design a File Manager

Design a robust file orchestration system with chunking, indexing, and hierarchical storage.

Design a File Manager system that allows users to perform operations such as creating, reading, updating, and deleting files and directories. The system should efficiently manage file metadata, support file chunking for large files, and provide indexing and search capabilities. The design should use Composite Pattern for hierarchical structure, Strategy Pattern for chunking mechanisms, and Builder Pattern for file construction.

In this problem, you’ll design a system that can manage millions of files across complex hierarchies while ensuring efficient storage and near-instant metadata retrieval.


Design a sophisticated file management engine that supports hierarchical storage, transparent chunking for performance, and a searchable index for metadata.

Functional Requirements:

  • Hierarchical Storage: Support nested directories and uniform file/folder handling.
  • CRUD Operations: Create, read, update, delete, move, and copy files.
  • File Chunking: Automatically break large files into smaller segments for storage.
  • Indexing: Maintain a searchable index of files based on name, size, and date.
  • Metadata Management: Track creation time, modification time, and permissions.
  • Reconstruction: Seamlessly reassemble chunks when a file is read.

Non-Functional Requirements:

  • Performance: Search operations should be $O(1)$ or $O(\log N)$ via indexing.
  • Thread Safety: Multiple users should be able to read/write without corruption.
  • Extensibility: Support different storage backends (Local, Cloud, S3) via strategies.
  • Scalability: Handle massive directory trees without memory exhaustion.

The system coordinates between the DirectoryTree, the ChunkManager, and the MetadataIndex.

Diagram
classDiagram
    class FileSystemComponent {
        <<interface>>
        +getName()
        +getSize()
        +display()
    }
    
    class File {
        -List~Chunk~ chunks
        -Metadata metadata
        +read()
        +write()
    }
    
    class Directory {
        -List~FileSystemComponent~ children
        +addComponent(child)
    }

    class ChunkingStrategy {
        <<interface>>
        +split(data) List~Chunk~
        +merge(chunks) data
    }

    FileSystemComponent <|-- File
    FileSystemComponent <|-- Directory
    File --> ChunkingStrategy
    Directory "1" o-- "many" FileSystemComponent

Diagram

Storing a 10GB file as a single blob is risky and makes “random access” (reading just the middle) impossible.

Solution: Use the Strategy Pattern. Implement FixedSizeChunking or ContentDefinedChunking. The File object holds a list of Chunk identifiers. This allows the system to stream data and recover from partial failures.

Traversing a directory tree with 1 million files just to find one named “invoice.pdf” is too slow.

Solution: Implement a Global Metadata Index. Use a HashMap or a Trie that maps file names (or other attributes) to their location in the DirectoryTree. This turns an $O(N)$ tree search into an average $O(1)$ index lookup.

A file needs metadata, multiple chunks, specific permissions, and a chunking strategy before it’s “ready.”

Solution: Use the Builder Pattern. A FileBuilder handles the step-by-step construction of the File object, ensuring that mandatory fields (like name and root path) are never missed and that the chunking logic is applied correctly during creation.


By solving this problem, you’ll master:

  • Resource Partitioning - Breaking large data into manageable chunks.
  • Composite Patterns - Building complex, recursive organizational structures.
  • Index Design - Optimizing search performance in large datasets.
  • Structural & Creational Patterns - Combining Builder, Strategy, and Composite.

Ready to see the full implementation? Open the interactive playground to access:

  • 🎯 Step-by-step guidance through the 8-step LLD approach
  • 📊 Interactive UML builder to visualize your design
  • 💻 Complete Code Solutions in Python, Java, C++, TypeScript, JavaScript, C#
  • 🤖 AI-powered review of your design and code

After mastering the File Manager, try these similar problems: