Design a File Filtering System
Problem Statement
Design the Low-Level Design (LLD) for a File Filtering System — a component that scans and filters files based on configurable criteria such as file type, size, date, or content.
Such systems are commonly used in:
The system should be modular, extensible, and efficient at filtering large numbers of files.
🎯 Goal
Design a File Filtering System that can:
✅ Functional Requirements
1. Input Handling
2. Filtering Rules
3. Combinable Filters
Example:
Select all .txt files larger than 5MB that contain the keyword “report”.
4. Extensibility
5. Output
⚙️ Non-Functional Requirements
🧱 Key Classes to Design
ClassResponsibility
File
Represents metadata and attributes of a file.
FileFilter (interface)
Defines a standard method boolean matches(File file).
TypeFilter
Filters files by file extension/type.
SizeFilter
Filters files based on size range.
DateFilter
Filters files by creation/modification date.
ContentFilter
Filters files based on keyword search.
CompositeFilter
Combines multiple filters (AND, OR, NOT).
FileFilteringEngine
Core class that applies filters on a file list and returns matches.
🧩 Suggested Class Relationships
1
2File
3 ├── name
4 ├── size
5 ├── type
6 ├── createdDate
7 ├── content
8
9FileFilter (interface)
10 ├── boolean matches(File file)
11
12TypeFilter implements FileFilter
13 ├── matches(File file)
14
15SizeFilter implements FileFilter
16 ├── matches(File file)
17
18DateFilter implements FileFilter
19 ├── matches(File file)
20
21ContentFilter implements FileFilter
22 ├── matches(File file)
23
24CompositeFilter implements FileFilter
25 ├── List<FileFilter> filters
26 ├── FilterType (AND, OR, NOT)
27 ├── matches(File file)
28
29FileFilteringEngine
30 ├── applyFilters(List<File>, FileFilter)
31 ├── returns filtered list🔄 Example Flow
🧾 Input
List of files:
NameTypeSize (KB)CreatedContent
report1.txt
txt
300
2024-01-15
“Monthly sales report”
data.pdf
1500
2024-03-10
“Confidential”
image.png
png
5000
2023-12-25
“Binary data”
report2.txt
txt
6000
2024-02-01
“Quarterly report”
Filters
CompositeFilter (AND)
🧮 Output
🧠 Design Patterns to Use
⚡ Possible Extensions
✅ Final Summary:
Design a File Filtering System (LLD) that: