# ahmedkhaleel2004/blitztree architecture

> Architecture diagram of the GitHub repository ahmedkhaleel2004/blitztree, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmedkhaleel2004/blitztree
- Repository: https://github.com/ahmedkhaleel2004/blitztree
- Video tour (about a minute): https://gitdiagram.com/ahmedkhaleel2004/blitztree/video

## Overview

BlitzTree is a native macOS disk-usage visualizer: the user chooses a folder or volume, the Rust engine scans and aggregates its contents, and the Swift app presents the result as a treemap and outline table. The README documents live progress, free-space display, cushion shading, and directory title strips; the sampled UI also supports selection and file actions. The scan crosses the C FFI as flat arrays read by Swift. The README describes the scan strategy; unsampled implementation details are not inferred here.

Main entry points: [`app/ContentView.swift`](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/ContentView.swift) (Scan screen), [`app/Model.swift`](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Model.swift) (Scan model), [`src/ffi.rs`](https://github.com/ahmedkhaleel2004/blitztree/blob/main/src/ffi.rs) (C FFI), [`app/TreemapView.swift`](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/TreemapView.swift) (Treemap canvas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["macOS app"]
  node_app_entry["App entry<br/>[Main.swift]"]
  node_scan_screen["Scan screen<br/>[ContentView.swift]"]
  node_scan_model["Scan model<br/>[Model.swift]"]
  node_tree_model["Tree model<br/>[Model.swift]"]
  node_progress_ui["Progress stats<br/>[ContentView.swift]"]
end

subgraph group_engine["Rust scan engine"]
  node_ffi_bridge["C FFI<br/>[ffi.rs]"]
  node_scan_engine["Directory scan<br/>[lib.rs]"]
end

subgraph group_views["Tree views"]
  node_treemap_layout["Treemap layout<br/>[Treemap.swift]"]
  node_treemap_canvas["Treemap canvas<br/>[TreemapView.swift]"]
  node_outline_table["Outline table<br/>[ContentView.swift]"]
  node_file_actions["File actions<br/>[TreemapView.swift]"]
end

subgraph group_platform["macOS services"]
  node_filesystem[("Filesystem")]
  node_finder["Finder"]
  node_volume_stats["Volume stats"]
end

node_user(("User"))

node_user -->|"chooses target"| node_scan_screen
node_app_entry -->|"shows"| node_scan_screen
node_scan_screen -->|"starts scan"| node_scan_model
node_scan_model -->|"starts scan"| node_ffi_bridge
node_ffi_bridge -->|"runs scan"| node_scan_engine
node_scan_engine -->|"reads entries"| node_filesystem
node_scan_engine -->|"returns tree"| node_ffi_bridge
node_scan_model -->|"polls progress"| node_ffi_bridge
node_ffi_bridge -->|"returns counters"| node_scan_model
node_ffi_bridge -->|"exposes arrays"| node_tree_model
node_scan_model -->|"creates tree"| node_tree_model
node_scan_model -->|"reads capacity"| node_volume_stats
node_scan_screen -->|"shows progress"| node_progress_ui
node_scan_screen -->|"shows map"| node_treemap_canvas
node_tree_model -->|"supplies tree"| node_treemap_layout
node_treemap_canvas -->|"lays out nodes"| node_treemap_layout
node_treemap_canvas -->|"reads tree"| node_tree_model
node_scan_screen -->|"shows outline"| node_outline_table
node_outline_table -->|"reads tree"| node_tree_model
node_user -->|"selects item"| node_treemap_canvas
node_treemap_canvas -->|"dispatches actions"| node_file_actions
node_file_actions -->|"reveals or trashes"| node_finder
node_volume_stats -->|"provides free space"| node_scan_screen

click node_app_entry "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Main.swift"
click node_scan_screen "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/ContentView.swift"
click node_scan_model "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Model.swift"
click node_tree_model "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Model.swift"
click node_ffi_bridge "https://github.com/ahmedkhaleel2004/blitztree/blob/main/src/ffi.rs"
click node_scan_engine "https://github.com/ahmedkhaleel2004/blitztree/blob/main/src/lib.rs"
click node_progress_ui "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/ContentView.swift"
click node_treemap_layout "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Treemap.swift"
click node_treemap_canvas "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/TreemapView.swift"
click node_outline_table "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/ContentView.swift"
click node_file_actions "https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/TreemapView.swift"

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_entry,node_scan_screen,node_scan_model,node_tree_model,node_progress_ui,node_user toneBlue
class node_ffi_bridge,node_scan_engine toneAmber
class node_treemap_layout,node_treemap_canvas,node_outline_table,node_file_actions toneMint
class node_filesystem,node_finder,node_volume_stats toneRose
```

## Components

### macOS app

- [App entry](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Main.swift): `app/Main.swift`
- [Scan screen](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/ContentView.swift): `app/ContentView.swift`
- [Scan model](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Model.swift): `app/Model.swift`
- [Tree model](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Model.swift): `app/Model.swift`
- [Progress stats](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/ContentView.swift): `app/ContentView.swift`

### Rust scan engine

- [C FFI](https://github.com/ahmedkhaleel2004/blitztree/blob/main/src/ffi.rs): `src/ffi.rs`
- [Directory scan](https://github.com/ahmedkhaleel2004/blitztree/blob/main/src/lib.rs): `src/lib.rs`

### Tree views

- [Treemap layout](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/Treemap.swift): `app/Treemap.swift`
- [Treemap canvas](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/TreemapView.swift): `app/TreemapView.swift`
- [Outline table](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/ContentView.swift): `app/ContentView.swift`
- [File actions](https://github.com/ahmedkhaleel2004/blitztree/blob/main/app/TreemapView.swift): `app/TreemapView.swift`

### macOS services

- **Filesystem**
- **Finder**
- **Volume stats**

### Other components

- **User**

## Connections

- User → Scan screen: chooses target
- App entry → Scan screen: shows
- Scan screen → Scan model: starts scan
- Scan model → C FFI: starts scan
- C FFI → Directory scan: runs scan
- Directory scan → Filesystem: reads entries
- Directory scan → C FFI: returns tree
- Scan model → C FFI: polls progress
- C FFI → Scan model: returns counters
- C FFI → Tree model: exposes arrays
- Scan model → Tree model: creates tree
- Scan model → Volume stats: reads capacity
- Scan screen → Progress stats: shows progress
- Scan screen → Treemap canvas: shows map
- Tree model → Treemap layout: supplies tree
- Treemap canvas → Treemap layout: lays out nodes
- Treemap canvas → Tree model: reads tree
- Scan screen → Outline table: shows outline
- Outline table → Tree model: reads tree
- User → Treemap canvas: selects item
- Treemap canvas → File actions: dispatches actions
- File actions → Finder: reveals or trashes
- Volume stats → Scan screen: provides free space
