Documentation Index
Fetch the complete documentation index at: https://mintlify.com/adileo/squirreldisk/llms.txt
Use this file to discover all available pages before exploring further.
Architecture
SquirrelDisk is built using a modern, cross-platform architecture that combines the performance of Rust with the flexibility of React. This page provides an overview of how the application is structured and how data flows through the system.High-Level Architecture
SquirrelDisk uses the Tauri framework, which creates a bridge between a Rust backend and a web-based frontend: Key Benefits:- Native performance for disk scanning (Rust)
- Rich, interactive UI (React + D3.js)
- Small bundle size (~10MB installer)
- Cross-platform support (Windows, macOS, Linux)
Technology Stack
- Frontend
- Backend
React + Vite + TypeScript
The frontend is a single-page application built with modern web technologies:| Technology | Purpose | Version |
|---|---|---|
| React | UI framework | 18.2.0 |
| TypeScript | Type safety | 4.6.4 |
| Vite | Build tool & dev server | 4.0.0 |
| Tailwind CSS | Styling framework | 3.2.4 |
| D3.js | Sunburst chart visualization | 7.8.2 |
| React Router | Client-side routing | 6.8.0 |
| react-beautiful-dnd | Drag-and-drop functionality | 13.1.1 |
@tauri-apps/api- Communication with Rust backendpretty-bytes- Human-readable file sizesvscode-icons-js- File type iconsshade-blend-color- Color manipulation for chart
Core Components
Frontend Components
The React frontend is organized into several key components:DiskList.tsx
Purpose: Main screen that displays available disks and drivesKey Features:
- Lists all mounted disks using
get_diskscommand - Shows disk capacity and usage
- Filters system disks on macOS/Linux
- Folder picker for custom scans
- Version display and navigation
src/components/DiskList.tsxDiskDetail.tsx
Purpose: Detailed view of a disk with interactive sunburst chartKey Features:
- Manages scan lifecycle (start/stop)
- Renders D3.js sunburst visualization
- Handles chart interactions (click, hover)
- File/folder deletion via drag-and-drop
- Real-time scan progress updates
- Breadcrumb navigation
src/components/DiskDetail.tsxTitleBar.tsx
Purpose: Custom window title barKey Features:
- Platform-specific window controls
- Drag region for moving window
- Minimize/maximize/close buttons
- Native look and feel
src/components/TitleBar.tsxFileLine.tsx
Purpose: Individual file/folder item in the listKey Features:
- Draggable for deletion
- File type icons
- Size formatting
- Right-click context menu
- “Show in folder” action
src/components/FileLine.tsxDiskItem.tsx
Purpose: Individual disk/drive item in the main listKey Features:
- Displays disk name, mount point, and capacity
- Shows usage percentage with color-coded progress bar
- Click to start quick scan (min-ratio: 0.001)
- Right-click to start full scan (min-ratio: 0)
- Distinguishes removable drives with special icon
src/components/DiskItem.tsxParentFolder.tsx
Purpose: Breadcrumb navigation for current folder in detail viewKey Features:
- Shows current folder path and size
- Click to navigate to parent folder
- Right-click to open in file explorer
- Synchronized with sunburst chart focus
src/components/ParentFolder.tsxd3chart.ts - Sunburst Visualization
The core visualization logic is insrc/d3chart.ts. This module creates the interactive sunburst chart that shows disk space usage:
Key Functions:
getChart()- Initializes and returns the D3 chart instancepartition()- Computes hierarchical layout usingd3.partition()arcVisible()- Determines which arcs should be visiblesetTargetAngles()- Calculates animation targets for zoomanimateToTarget()- Animates transitions between states
- Hierarchical sunburst layout with up to 4 depth levels
- Color-coded by depth (using
shade-blend-color) - Click to zoom into folders
- Hover to see file details
- Smooth animations between states
- Responsive sizing
Backend Components
- main.rs
- scan.rs
- window_style.rs
src-tauri/src/main.rs
The entry point for the Rust backend. Handles Tauri setup and command registration.Key Responsibilities:- Initialize Tauri application
- Apply platform-specific window styling (transparency, shadows, rounded corners)
- Register Tauri commands
- Manage global state
Data Flow
Here’s how data flows through SquirrelDisk from start to finish:User Selects Disk
User clicks on a disk in
DiskList component or picks a folder.Frontend navigates to DiskDetail with disk information.Rust Backend Processes Request
main.rs receives the command and calls scan::start().scan.rs spawns the pdu sidecar process with appropriate arguments.Real-Time Progress Updates
As
pdu scans the disk:- Progress messages are parsed from stderr
- Backend emits
scan_statusevents to frontend - Frontend updates the progress indicator
Scan Completion
When scan finishes:
pduoutputs JSON to stdout- Backend emits
scan_completedevent - Frontend receives hierarchical disk data
Data Processing
Frontend processes the raw data:
pruneData.tsconverts to D3 hierarchy format- Filters out files below minimum ratio
- Builds path mappings for navigation
- Creates indexed item map
Visualization
d3chart.ts renders the sunburst chart:- Uses
d3.partition()for hierarchical layout - Calculates arc positions (angles and radii)
- Applies color scheme based on depth
- Enables interactive zooming and hovering
Key Dependencies
Frontend
D3.js - Visualization
D3.js - Visualization
Version: 7.8.2D3.js powers the sunburst chart visualization. Key D3 modules used:
d3.hierarchy()- Convert flat data to hierarchyd3.partition()- Compute sunburst layoutd3.arc()- Generate SVG arc pathsd3.select()- DOM manipulationd3.transition()- Smooth animations
- 4 levels of depth
- Click to zoom
- Hover interactions
- Breadcrumb navigation
react-beautiful-dnd - Drag and Drop
react-beautiful-dnd - Drag and Drop
Version: 13.1.1Enables drag-and-drop functionality for marking files for deletion:
- Drag files from the list
- Drop into delete zone
- Visual feedback during drag
- Batch deletion support
DragDropContext- Wraps the entire drag contextDroppable- Defines drop zonesDraggable- Makes items draggable
@tauri-apps/api - IPC Communication
@tauri-apps/api - IPC Communication
Version: 1.2.0Provides the bridge between React and Rust:Commands (React → Rust):Events (Rust → React):Other APIs:
dialog.open()- Native file pickerapp.getVersion()- App version infoos.platform()- Platform detectionfs.removeFile()- File operations
Backend
parallel-disk-usage - Fast Scanning
parallel-disk-usage - Fast Scanning
Version: 0.8.3High-performance disk space analyzer written in Rust:
- Multi-threaded scanning
- Progress reporting
- JSON output format
- Configurable minimum ratio (filter small files)
- Bottom-up traversal
pdu as a sidecar process for maximum performance.Why sidecar?- Independent process lifecycle
- Easy to cancel
- Isolates crashes
- Pre-compiled binary
sysinfo - System Information
sysinfo - System Information
Version: 0.27.7Cross-platform system information library:
- List mounted disks
- Total and available space
- Disk type detection (HDD, SSD, removable)
- Mount point paths
- Disk names
get_disks command to populate the disk list.walkdir - Directory Traversal
walkdir - Directory Traversal
Version: 2Recursive directory iterator:
- Fast, memory-efficient
- Follows symlinks (optional)
- Error handling
- Filter support
pdu.window-vibrancy & window-shadows
window-vibrancy & window-shadows
window-vibrancy: 0.3.2
window-shadows: Custom forkNative window effects:
window-shadows: Custom forkNative window effects:
- Blur/transparency (Windows, macOS)
- Rounded corners (Windows 11)
- Drop shadows (Windows, macOS)
- Vibrancy materials (macOS)
Platform Differences
SquirrelDisk adapts to each platform:- Windows
- macOS
- Linux
Window Styling:
- Blur effect with semi-transparent background
- Rounded corners on Windows 11
- Custom border color
- Native window shadows
- Uses
explorer /select,to show files - Backslash path separators
- Drive letters (C:, D:, etc.)
- Scans from drive root (C:, D:, etc.)
- No system directory filtering needed
Performance Considerations
Fast Scanning
- Multi-threaded Rust backend
- Parallel directory traversal
- Minimal ratio filtering (skip small files)
- Sidecar process isolation
Memory Efficiency
- Streaming progress updates
- Pruned data structure
- Limited chart depth (4 levels)
- Lazy rendering in D3
UI Responsiveness
- React state management
- Vite HMR for development
- Debounced events
- Smooth D3 transitions
Bundle Size
- ~10MB installer
- Tauri native webview
- No Electron overhead
- Tree-shaken dependencies
Testing Strategy
While SquirrelDisk doesn’t currently have a comprehensive test suite, here are recommended testing approaches:- Manual Testing
- Rust Unit Tests
- Integration Tests
Disk Scanning:
- Test on different disk types (HDD, SSD, USB)
- Scan various directory sizes (small, large, massive)
- Test cancellation mid-scan
- Verify progress accuracy
- Click through chart depths
- Hover over different arcs
- Drag and drop files
- Navigate breadcrumbs
- Test “show in folder”
- Test on Windows 10 and 11
- Test on macOS (Intel and Apple Silicon)
- Test on Ubuntu, Fedora, Arch Linux
Future Improvements
The codebase has several areas marked for improvement: Potential Refactoring:- Extract shared logic into utilities
- Improve TypeScript type definitions
- Add comprehensive error handling
- Implement proper state management (Redux, Zustand)
- Add unit and integration tests
- Optimize D3 rendering for large datasets
- Improve Rust code organization
- Add logging framework
- Multiple disk comparison
- Export reports (CSV, PDF)
- Search functionality
- File filtering by type
- Duplicate file detection
- Historical disk usage tracking
Resources
Tauri Docs
Official Tauri framework documentation
D3.js Examples
D3.js visualization examples and tutorials
parallel-disk-usage
The disk scanning library used by SquirrelDisk
Rust Book
Learn Rust programming language
Next Steps
Now that you understand the architecture:Start Contributing
Follow the GitHub workflow to contribute code
Browse Issues
Find an issue to work on

