# amitr05/smartdiskanalyser architecture

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

- Interactive diagram: https://gitdiagram.com/amitr05/smartdiskanalyser
- Repository: https://github.com/amitr05/smartdiskanalyser

## Overview

DiskLens is a local, CLI-first filesystem intelligence tool. Its main workflow discovers or accepts a scan root, streams read-only filesystem metadata into SQLite, then answers analysis and review requests from saved snapshots; cleanup remains advisory and deletion is disabled. Separate branches support duplicate verification, application inventory, offline knowledge, queries, and learned classifications, anomalies, and forecasts. The graph follows shown imports/calls and README capabilities; unsampled implementation details are represented only at supported directory or module paths.

Main entry points: [`src/disklens/cli.py`](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/cli.py) (Command interface), [`src/disklens/ml/training.py`](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/training.py) (Model training and inference), [`src/disklens/analysis.py`](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/analysis.py) (Snapshot analysis), [`src/disklens/database.py`](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/database.py) (SQLite scan history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["CLI and queries"]
  node_cli["Command interface<br/>[cli.py]"]
  node_query["Intent router<br/>[query.py]"]
end

subgraph group_scanning["Scanning and state"]
  node_drives["Drive discovery<br/>[drives.py]"]
  node_scanner["Filesystem traversal<br/>[scanner.py]"]
  node_records["File metadata records<br/>[records.py]"]
  node_database[("SQLite scan history<br/>[database.py]")]
end

subgraph group_insight["Storage insights"]
  node_analysis["Snapshot analysis<br/>[analysis.py]"]
  node_visualization["Storage visualizations<br/>[visualization.py]"]
  node_duplicates["Verified duplicates<br/>[duplicates.py]"]
  node_identification["File identification<br/>[identification.py]"]
  node_apps["Application storage<br/>[apps.py]"]
end

subgraph group_knowledge_safety["Knowledge and safety"]
  node_knowledge["Filesystem knowledge<br/>[knowledge.py]"]
  node_safety["Safety vetoes<br/>[safety.py]"]
end

subgraph group_learning["Learning and models"]
  node_ml_data["Training data validation<br/>[data.py]"]
  node_features["Feature extraction<br/>[features.py]"]
  node_policy["Abstention policy<br/>[policy.py]"]
  node_training["Model training and inference<br/>[training.py]"]
end

node_user(("DiskLens user"))

node_user -->|"issues commands"| node_cli
node_cli -->|"discovers drives"| node_drives
node_cli -->|"starts scans"| node_database
node_database -->|"streams traversal"| node_scanner
node_scanner -->|"yields records"| node_records
node_cli -->|"requests analysis"| node_analysis
node_cli -->|"requests hashing"| node_duplicates
node_cli -->|"identifies formats"| node_identification
node_cli -->|"requests inventory"| node_apps
node_cli -->|"assesses risk"| node_safety
node_cli -->|"trains or predicts"| node_training
node_cli -->|"routes questions"| node_query
node_query -->|"calls handlers"| node_analysis
node_analysis -->|"reads snapshots"| node_database
node_analysis -->|"uses summaries"| node_visualization
node_analysis -->|"uses location rules"| node_knowledge
node_apps -->|"uses path rules"| node_knowledge
node_apps -->|"reads scan records"| node_database
node_duplicates -->|"reads scan metadata"| node_database
node_training -->|"validates datasets"| node_ml_data
node_training -->|"extracts features"| node_features
node_training -->|"selects abstention"| node_policy
node_training -->|"applies vetoes"| node_safety
node_features -->|"uses location"| node_knowledge
node_cli -->|"renders reports"| node_visualization

click node_cli "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/cli.py"
click node_query "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/query.py"
click node_drives "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/drives.py"
click node_scanner "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/scanner.py"
click node_records "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/records.py"
click node_database "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/database.py"
click node_analysis "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/analysis.py"
click node_visualization "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/visualization.py"
click node_duplicates "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/duplicates.py"
click node_identification "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/identification.py"
click node_apps "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/apps.py"
click node_knowledge "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/knowledge.py"
click node_safety "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/safety.py"
click node_ml_data "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/data.py"
click node_features "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/features.py"
click node_policy "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/policy.py"
click node_training "https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/training.py"

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_cli,node_query,node_user toneBlue
class node_drives,node_scanner,node_records,node_database toneAmber
class node_analysis,node_visualization,node_duplicates,node_identification,node_apps toneMint
class node_knowledge,node_safety toneRose
class node_ml_data,node_features,node_policy,node_training toneIndigo
```

## Components

### CLI and queries

- [Command interface](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/cli.py): `src/disklens/cli.py`
- [Intent router](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/query.py): `src/disklens/query.py`

### Scanning and state

- [Drive discovery](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/drives.py): `src/disklens/drives.py`
- [Filesystem traversal](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/scanner.py): `src/disklens/scanner.py`
- [File metadata records](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/records.py): `src/disklens/records.py`
- [SQLite scan history](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/database.py): `src/disklens/database.py`

### Storage insights

- [Snapshot analysis](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/analysis.py): `src/disklens/analysis.py`
- [Storage visualizations](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/visualization.py): `src/disklens/visualization.py`
- [Verified duplicates](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/duplicates.py): `src/disklens/duplicates.py`
- [File identification](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/identification.py): `src/disklens/identification.py`
- [Application storage](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/apps.py): `src/disklens/apps.py`

### Knowledge and safety

- [Filesystem knowledge](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/knowledge.py): `src/disklens/knowledge.py`
- [Safety vetoes](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/safety.py): `src/disklens/safety.py`

### Learning and models

- [Training data validation](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/data.py): `src/disklens/ml/data.py`
- [Feature extraction](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/features.py): `src/disklens/ml/features.py`
- [Abstention policy](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/policy.py): `src/disklens/ml/policy.py`
- [Model training and inference](https://github.com/amitr05/smartdiskanalyser/blob/main/src/disklens/ml/training.py): `src/disklens/ml/training.py`

### Other components

- **DiskLens user**

## Connections

- DiskLens user → Command interface: issues commands (evidence: `README.md`)
- Command interface → Drive discovery: discovers drives (evidence: `src/disklens/cli.py`)
- Command interface → SQLite scan history: starts scans (evidence: `src/disklens/cli.py`)
- SQLite scan history → Filesystem traversal: streams traversal (evidence: `src/disklens/database.py`)
- Filesystem traversal → File metadata records: yields records (evidence: `src/disklens/scanner.py`)
- Command interface → Snapshot analysis: requests analysis (evidence: `src/disklens/cli.py`)
- Command interface → Verified duplicates: requests hashing (evidence: `src/disklens/cli.py`)
- Command interface → File identification: identifies formats (evidence: `src/disklens/cli.py`)
- Command interface → Application storage: requests inventory (evidence: `src/disklens/cli.py`)
- Command interface → Safety vetoes: assesses risk (evidence: `src/disklens/cli.py`)
- Command interface → Model training and inference: trains or predicts (evidence: `src/disklens/cli.py`)
- Command interface → Intent router: routes questions (evidence: `src/disklens/cli.py`)
- Intent router → Snapshot analysis: calls handlers (evidence: `src/disklens/query.py`)
- Snapshot analysis → SQLite scan history: reads snapshots (evidence: `src/disklens/analysis.py`)
- Snapshot analysis → Storage visualizations: uses summaries (evidence: `src/disklens/analysis.py`)
- Snapshot analysis → Filesystem knowledge: uses location rules (evidence: `src/disklens/analysis.py`)
- Application storage → Filesystem knowledge: uses path rules (evidence: `src/disklens/apps.py`)
- Application storage → SQLite scan history: reads scan records (evidence: `src/disklens/apps.py`)
- Verified duplicates → SQLite scan history: reads scan metadata (evidence: `src/disklens/duplicates.py`)
- Model training and inference → Training data validation: validates datasets (evidence: `src/disklens/ml/training.py`)
- Model training and inference → Feature extraction: extracts features (evidence: `src/disklens/ml/training.py`)
- Model training and inference → Abstention policy: selects abstention (evidence: `src/disklens/ml/training.py`)
- Model training and inference → Safety vetoes: applies vetoes (evidence: `src/disklens/ml/training.py`)
- Feature extraction → Filesystem knowledge: uses location (evidence: `src/disklens/ml/features.py`)
- Command interface → Storage visualizations: renders reports (evidence: `src/disklens/cli.py`)
