Design Document for Project 5: macOS Disk Usage Visualizer
Design Document for Project 5: macOS Disk Usage Visualizer
Project Name: macOS Disk Usage Visualizer
Objective:
Build a cross-platform application using Java and C++ that visualizes disk usage in macOS. The project combines a C++ disk usage scanner with a Java-based visualization tool.
- Goals and Non-Goals
Goals:
- Develop a high-performance disk usage scanner in C++.
- Provide a tree-map or bar-chart visualization using JavaFX.
- Ensure compatibility across multiple macOS versions.
Non-Goals:
- Compatibility with Windows or Linux systems.
- Advanced visualization features like zoom or real-time updates.
- Design Overview
- Input: Root directory path provided by the user.
- Output: Visualization of disk usage, including folder sizes and file details.
- Architecture:
- C++ Disk Scanner: Scans the directory and calculates folder sizes.
- Java Frontend: Visualizes the scanned data.
- JNI Interface: Facilitates communication between Java and C++.
- System Design
- Components
- Disk Scanner (C++):
- Traverses the directory recursively to calculate sizes.
- Outputs results in a structured format (e.g., JSON).
- Java Visualizer:
- Parses the JSON output and renders a visualization using JavaFX.
- JNI Bridge:
- Connects the Java application with the C++ scanner for seamless integration.
- Workflow
- Input Handling:
- User provides the root directory path.
- Scanning: • The Disk Scanner processes the directory and generates a JSON file.
- Data Parsing: • The Java Visualizer reads and parses the JSON output.
- Visualization: • JavaFX renders a tree map or bar chart.
- Output: • Disk usage data is displayed, highlighting large files and directories.
- Input Handling:
- Components
- API and Data Structures
5.1 Core Data Structures • FileInfo (C++):
struct FileInfo {
std::string name;
uint64_t size;
std::vector
- JSON Schema:
{ “name”: “root”, “size”: 100000, “children”: [ { “name”: “folder1”, “size”: 50000, “children”: [] }, { “name”: “folder2”, “size”: 50000, “children”: [] } ] }
5.2 Interfaces • Disk Scanner:
FileInfo scanDirectory(const std::string& rootPath);
• Java Parser:
List
• JNI Interface:
public native String scanDisk(String rootPath);
-
Multithreading Strategy • Disk Scanner: Use multithreading for traversing subdirectories concurrently. • Load Balancing: Assign threads based on directory size to prevent bottlenecks.
-
Testing • Unit Testing: Verify the correctness of directory traversal and JSON generation. • Integration Testing: Ensure seamless interaction between C++ and Java components. • Visualization Testing: • Validate chart rendering for large and complex directory structures. • Test responsiveness of JavaFX.