# barun-saha/drive-sonar architecture

> Architecture diagram of the GitHub repository barun-saha/drive-sonar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/barun-saha/drive-sonar
- Repository: https://github.com/barun-saha/drive-sonar

## Overview

Drive Sonar is a Tauri desktop disk-usage explorer. The user chooses a directory in the frontend, starts a scan, and explores the resulting directory tree, usage visualizations, and file-age/extension summaries; they can also open or trash items and export a report. The backend coordinates platform-specific scanning, builds an arena tree, and serves directory payloads to the UI. The graph preserves the README’s major features; some frontend wiring and command details were not excerpted, so those links are marked unverified.

Main entry points: [`src/App.tsx`](https://github.com/barun-saha/drive-sonar/blob/main/src/App.tsx) (App workflow), [`src-tauri/src/commands/scan.rs`](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/commands/scan.rs) (Scan and navigation), [`src/components/VisualizationPanel.tsx`](https://github.com/barun-saha/drive-sonar/blob/main/src/components/VisualizationPanel.tsx) (Visualization panel), [`src/components/ExtensionChart.tsx`](https://github.com/barun-saha/drive-sonar/blob/main/src/components/ExtensionChart.tsx) (Extension chart)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Desktop interface"]
  node_app["App workflow<br/>[App.tsx]"]
  node_toolbar["Scan toolbar<br/>[Toolbar.tsx]"]
  node_itemlist["Directory browser<br/>[ItemList.tsx]"]
  node_pathnav["Path navigation<br/>[PathNav.tsx]"]
end

subgraph group_backend["Scan backend"]
  node_commandreg["Tauri command registry<br/>[lib.rs]"]
  node_scancommand["Scan and navigation<br/>[scan.rs]"]
  node_scanner["Parallel scanner<br/>[scanner.rs]"]
  node_platformscan["Platform readers"]
  node_tree["Tree and summaries<br/>[tree.rs]"]
  node_models["Scan data models<br/>[models.rs]"]
  node_diskcommand["Disk information<br/>[disk.rs]"]
end

subgraph group_analysis["Usage analysis"]
  node_visualpanel["Visualization panel"]
  node_sizechart["Space map<br/>[SizeChart.tsx]"]
  node_extensionchart["Extension chart<br/>[ExtensionChart.tsx]"]
  node_agechart["File age chart"]
  node_chartheader["Chart controls<br/>[ChartHeader.tsx]"]
  node_logscale["Log scale hook<br/>[useLogScale.ts]"]
  node_format["Byte formatting<br/>[format.ts]"]
end

subgraph group_actions["File actions and reports"]
  node_report["Report export<br/>[exportReport.ts]"]
  node_fileops["Open and trash<br/>[file_ops.rs]"]
end

node_user(("Desktop user"))

node_user -->|"uses"| node_app
node_app -->|"presents"| node_toolbar
node_app -->|"presents"| node_itemlist
node_app -->|"presents"| node_visualpanel
node_app -.->|"invokes scan"| node_scancommand
node_app -->|"requests navigation"| node_scancommand
node_app -->|"requests disk info"| node_diskcommand
node_app -->|"cancels scan"| node_scancommand
node_app -->|"exports report"| node_report
node_itemlist -->|"renders"| node_pathnav
node_itemlist -->|"opens or trashes"| node_fileops
node_visualpanel -->|"renders"| node_sizechart
node_visualpanel -->|"renders"| node_extensionchart
node_visualpanel -->|"renders"| node_agechart
node_agechart -->|"uses controls"| node_chartheader
node_extensionchart -->|"uses controls"| node_chartheader
node_agechart -->|"uses scale"| node_logscale
node_extensionchart -->|"uses scale"| node_logscale
node_agechart -->|"formats values"| node_format
node_extensionchart -->|"formats values"| node_format
node_report -->|"formats values"| node_format
node_commandreg -->|"registers commands"| node_scancommand
node_commandreg -->|"registers command"| node_diskcommand
node_commandreg -->|"registers commands"| node_fileops
node_scancommand -->|"runs scan"| node_scanner
node_scanner -->|"dispatches reads"| node_platformscan
node_scancommand -->|"builds payload"| node_tree
node_scancommand -->|"uses state and payloads"| node_models
node_tree -->|"builds tree payloads"| node_models
node_fileops -->|"checks tree items"| node_tree
node_diskcommand -->|"returns disk info"| node_models
node_fileops -->|"uses item data"| node_models

click node_app "https://github.com/barun-saha/drive-sonar/blob/main/src/App.tsx"
click node_toolbar "https://github.com/barun-saha/drive-sonar/blob/main/src/components/Toolbar.tsx"
click node_itemlist "https://github.com/barun-saha/drive-sonar/blob/main/src/components/ItemList.tsx"
click node_pathnav "https://github.com/barun-saha/drive-sonar/blob/main/src/components/PathNav.tsx"
click node_visualpanel "https://github.com/barun-saha/drive-sonar/blob/main/src/components/VisualizationPanel.tsx"
click node_sizechart "https://github.com/barun-saha/drive-sonar/blob/main/src/components/SizeChart.tsx"
click node_extensionchart "https://github.com/barun-saha/drive-sonar/blob/main/src/components/ExtensionChart.tsx"
click node_agechart "https://github.com/barun-saha/drive-sonar/blob/main/src/components/AgeScatterChart.tsx"
click node_chartheader "https://github.com/barun-saha/drive-sonar/blob/main/src/components/ChartHeader.tsx"
click node_logscale "https://github.com/barun-saha/drive-sonar/blob/main/src/hooks/useLogScale.ts"
click node_format "https://github.com/barun-saha/drive-sonar/blob/main/src/utils/format.ts"
click node_report "https://github.com/barun-saha/drive-sonar/blob/main/src/utils/exportReport.ts"
click node_commandreg "https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/lib.rs"
click node_scancommand "https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/commands/scan.rs"
click node_scanner "https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/scanner.rs"
click node_platformscan "https://github.com/barun-saha/drive-sonar/tree/main/src-tauri/src/scanner"
click node_tree "https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/tree.rs"
click node_models "https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/models.rs"
click node_diskcommand "https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/commands/disk.rs"
click node_fileops "https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/commands/file_ops.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_toolbar,node_itemlist,node_pathnav,node_user toneBlue
class node_commandreg,node_scancommand,node_scanner,node_platformscan,node_tree,node_models,node_diskcommand toneAmber
class node_visualpanel,node_sizechart,node_extensionchart,node_agechart,node_chartheader,node_logscale,node_format toneMint
class node_report,node_fileops toneRose
```

## Components

### Desktop interface

- [App workflow](https://github.com/barun-saha/drive-sonar/blob/main/src/App.tsx): `src/App.tsx`
- [Scan toolbar](https://github.com/barun-saha/drive-sonar/blob/main/src/components/Toolbar.tsx): `src/components/Toolbar.tsx`
- [Directory browser](https://github.com/barun-saha/drive-sonar/blob/main/src/components/ItemList.tsx): `src/components/ItemList.tsx`
- [Path navigation](https://github.com/barun-saha/drive-sonar/blob/main/src/components/PathNav.tsx): `src/components/PathNav.tsx`

### Scan backend

- [Tauri command registry](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [Scan and navigation](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/commands/scan.rs): `src-tauri/src/commands/scan.rs`
- [Parallel scanner](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/scanner.rs): `src-tauri/src/scanner.rs`
- [Platform readers](https://github.com/barun-saha/drive-sonar/tree/main/src-tauri/src/scanner): `src-tauri/src/scanner`
- [Tree and summaries](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/tree.rs): `src-tauri/src/tree.rs`
- [Scan data models](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/models.rs): `src-tauri/src/models.rs`
- [Disk information](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/commands/disk.rs): `src-tauri/src/commands/disk.rs`

### Usage analysis

- [Visualization panel](https://github.com/barun-saha/drive-sonar/blob/main/src/components/VisualizationPanel.tsx): `src/components/VisualizationPanel.tsx`
- [Space map](https://github.com/barun-saha/drive-sonar/blob/main/src/components/SizeChart.tsx): `src/components/SizeChart.tsx`
- [Extension chart](https://github.com/barun-saha/drive-sonar/blob/main/src/components/ExtensionChart.tsx): `src/components/ExtensionChart.tsx`
- [File age chart](https://github.com/barun-saha/drive-sonar/blob/main/src/components/AgeScatterChart.tsx): `src/components/AgeScatterChart.tsx`
- [Chart controls](https://github.com/barun-saha/drive-sonar/blob/main/src/components/ChartHeader.tsx): `src/components/ChartHeader.tsx`
- [Log scale hook](https://github.com/barun-saha/drive-sonar/blob/main/src/hooks/useLogScale.ts): `src/hooks/useLogScale.ts`
- [Byte formatting](https://github.com/barun-saha/drive-sonar/blob/main/src/utils/format.ts): `src/utils/format.ts`

### File actions and reports

- [Report export](https://github.com/barun-saha/drive-sonar/blob/main/src/utils/exportReport.ts): `src/utils/exportReport.ts`
- [Open and trash](https://github.com/barun-saha/drive-sonar/blob/main/src-tauri/src/commands/file_ops.rs): `src-tauri/src/commands/file_ops.rs`

### Other components

- **Desktop user**

## Connections

- Desktop user → App workflow: uses (evidence: `README.md`)
- App workflow → Scan toolbar: presents (evidence: `src/App.tsx`)
- App workflow → Directory browser: presents (evidence: `src/App.tsx`)
- App workflow → Visualization panel: presents (evidence: `src/App.tsx`)
- App workflow → Scan and navigation: invokes scan
- App workflow → Scan and navigation: requests navigation (evidence: `src/App.tsx`)
- App workflow → Disk information: requests disk info (evidence: `src/App.tsx`)
- App workflow → Scan and navigation: cancels scan (evidence: `src/App.tsx`)
- App workflow → Report export: exports report (evidence: `src/App.tsx`)
- Directory browser → Path navigation: renders (evidence: `src/components/ItemList.tsx`)
- Directory browser → Open and trash: opens or trashes (evidence: `src/components/ItemList.tsx`)
- Visualization panel → Space map: renders (evidence: `src/components/VisualizationPanel.tsx`)
- Visualization panel → Extension chart: renders (evidence: `src/components/VisualizationPanel.tsx`)
- Visualization panel → File age chart: renders (evidence: `src/components/VisualizationPanel.tsx`)
- File age chart → Chart controls: uses controls (evidence: `src/components/AgeScatterChart.tsx`)
- Extension chart → Chart controls: uses controls (evidence: `src/components/ExtensionChart.tsx`)
- File age chart → Log scale hook: uses scale (evidence: `src/components/AgeScatterChart.tsx`)
- Extension chart → Log scale hook: uses scale (evidence: `src/components/ExtensionChart.tsx`)
- File age chart → Byte formatting: formats values (evidence: `src/components/AgeScatterChart.tsx`)
- Extension chart → Byte formatting: formats values (evidence: `src/components/ExtensionChart.tsx`)
- Report export → Byte formatting: formats values (evidence: `src/utils/exportReport.ts`)
- Tauri command registry → Scan and navigation: registers commands (evidence: `src-tauri/src/lib.rs`)
- Tauri command registry → Disk information: registers command (evidence: `src-tauri/src/lib.rs`)
- Tauri command registry → Open and trash: registers commands (evidence: `src-tauri/src/lib.rs`)
- Scan and navigation → Parallel scanner: runs scan (evidence: `src-tauri/src/commands/scan.rs`)
- Parallel scanner → Platform readers: dispatches reads (evidence: `src-tauri/src/scanner.rs`)
- Scan and navigation → Tree and summaries: builds payload (evidence: `src-tauri/src/commands/scan.rs`)
- Scan and navigation → Scan data models: uses state and payloads (evidence: `src-tauri/src/commands/scan.rs`)
- Tree and summaries → Scan data models: builds tree payloads (evidence: `src-tauri/src/tree.rs`)
- Open and trash → Tree and summaries: checks tree items (evidence: `src-tauri/src/commands/file_ops.rs`)
- Disk information → Scan data models: returns disk info (evidence: `src-tauri/src/commands/disk.rs`)
- Open and trash → Scan data models: uses item data (evidence: `src-tauri/src/commands/file_ops.rs`)
