# reandri-1/winautosort architecture

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

- Interactive diagram: https://gitdiagram.com/reandri-1/winautosort
- Repository: https://github.com/reandri-1/winautosort

## Overview

WinAutoSort is a Windows background file router. Its main workflow loads configuration, acquires a per-folder single-instance guard, watches a directory (and optionally sweeps existing files), filters and queues candidates, checks download readiness, selects a category, then performs a non-overwriting move; it logs activity throughout. The map reflects the sampled caller relationships and README-described behavior. Supporting Windows helpers, logger details, and documented features are included; edges without direct source or README evidence are omitted.

Main entry points: [`watcher.go`](https://github.com/reandri-1/winautosort/blob/main/watcher.go) (Directory Watcher), [`main.go`](https://github.com/reandri-1/winautosort/blob/main/main.go) (App Entrypoint), [`mover.go`](https://github.com/reandri-1/winautosort/blob/main/mover.go) (Safe File Mover), [`config.go`](https://github.com/reandri-1/winautosort/blob/main/config.go) (Config Rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup &amp; Config"]
  node_main["App Entrypoint<br/>[main.go]"]
  node_config["Config Rules<br/>[config.go]"]
end

subgraph group_watching["Watch &amp; Dispatch"]
  node_watcher["Directory Watcher<br/>[watcher.go]"]
  node_queue["Job Queue<br/>[watcher.go]"]
end

subgraph group_routing["Readiness &amp; Routing"]
  node_readiness["Download Readiness<br/>[lock_windows.go]"]
  node_categories["Category Selection<br/>[config.go]"]
  node_mover["Safe File Mover<br/>[mover.go]"]
end

subgraph group_platform["Windows &amp; Logging"]
  node_instance["Instance Guard<br/>[winutil_windows.go]"]
  node_windowsmove["Windows Atomic Move<br/>[winutil_windows.go]"]
  node_log[("Rotating Log<br/>[logger.go]")]
  node_dialogs["Setup Dialogs<br/>[winutil_windows.go]"]
end

node_user(("User"))
node_eventsource["Windows File Events"]
node_configfile["JSON Config<br/>[config.json]"]
node_sortedfiles[("Category Folders")]

node_user -->|"starts"| node_main
node_main -->|"loads"| node_config
node_configfile -->|"configures"| node_config
node_main -->|"prompts"| node_dialogs
node_main -->|"acquires guard"| node_instance
node_main -->|"creates and runs"| node_watcher
node_watcher -->|"receives events"| node_eventsource
node_watcher -->|"dispatches jobs"| node_queue
node_watcher -->|"filters and classifies"| node_config
node_watcher -->|"checks files"| node_readiness
node_watcher -->|"moves ready files"| node_mover
node_mover -->|"attempts atomic rename"| node_windowsmove
node_mover -->|"routes files"| node_sortedfiles
node_main -->|"sets up logging"| node_log
node_watcher -->|"records activity"| node_log

click node_main "https://github.com/reandri-1/winautosort/blob/main/main.go"
click node_config "https://github.com/reandri-1/winautosort/blob/main/config.go"
click node_instance "https://github.com/reandri-1/winautosort/blob/main/winutil_windows.go"
click node_watcher "https://github.com/reandri-1/winautosort/blob/main/watcher.go"
click node_queue "https://github.com/reandri-1/winautosort/blob/main/watcher.go"
click node_readiness "https://github.com/reandri-1/winautosort/blob/main/lock_windows.go"
click node_categories "https://github.com/reandri-1/winautosort/blob/main/config.go"
click node_mover "https://github.com/reandri-1/winautosort/blob/main/mover.go"
click node_windowsmove "https://github.com/reandri-1/winautosort/blob/main/winutil_windows.go"
click node_log "https://github.com/reandri-1/winautosort/blob/main/logger.go"
click node_configfile "https://github.com/reandri-1/winautosort/blob/main/config.json"
click node_dialogs "https://github.com/reandri-1/winautosort/blob/main/winutil_windows.go"

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_main,node_config,node_user toneBlue
class node_watcher,node_queue,node_sortedfiles toneAmber
class node_readiness,node_categories,node_mover toneMint
class node_instance,node_windowsmove,node_log,node_dialogs toneRose
class node_eventsource toneIndigo
class node_configfile toneTeal
```

## Components

### Startup & Config

- [App Entrypoint](https://github.com/reandri-1/winautosort/blob/main/main.go): `main.go`
- [Config Rules](https://github.com/reandri-1/winautosort/blob/main/config.go): `config.go`

### Watch & Dispatch

- [Directory Watcher](https://github.com/reandri-1/winautosort/blob/main/watcher.go): `watcher.go`
- [Job Queue](https://github.com/reandri-1/winautosort/blob/main/watcher.go): `watcher.go`

### Readiness & Routing

- [Download Readiness](https://github.com/reandri-1/winautosort/blob/main/lock_windows.go): `lock_windows.go`
- [Category Selection](https://github.com/reandri-1/winautosort/blob/main/config.go): `config.go`
- [Safe File Mover](https://github.com/reandri-1/winautosort/blob/main/mover.go): `mover.go`

### Windows & Logging

- [Instance Guard](https://github.com/reandri-1/winautosort/blob/main/winutil_windows.go): `winutil_windows.go`
- [Windows Atomic Move](https://github.com/reandri-1/winautosort/blob/main/winutil_windows.go): `winutil_windows.go`
- [Rotating Log](https://github.com/reandri-1/winautosort/blob/main/logger.go): `logger.go`
- [Setup Dialogs](https://github.com/reandri-1/winautosort/blob/main/winutil_windows.go): `winutil_windows.go`

### Other components

- **User**
- **Windows File Events**
- [JSON Config](https://github.com/reandri-1/winautosort/blob/main/config.json): `config.json`
- **Category Folders**

## Connections

- User → App Entrypoint: starts (evidence: `README.md`)
- App Entrypoint → Config Rules: loads (evidence: `main.go`)
- JSON Config → Config Rules: configures (evidence: `README.md`)
- App Entrypoint → Setup Dialogs: prompts (evidence: `main.go`)
- App Entrypoint → Instance Guard: acquires guard (evidence: `main.go`)
- App Entrypoint → Directory Watcher: creates and runs (evidence: `main.go`)
- Directory Watcher → Windows File Events: receives events (evidence: `README.md`)
- Directory Watcher → Job Queue: dispatches jobs (evidence: `watcher.go`)
- Directory Watcher → Config Rules: filters and classifies (evidence: `watcher.go`)
- Directory Watcher → Download Readiness: checks files (evidence: `watcher.go`)
- Directory Watcher → Safe File Mover: moves ready files (evidence: `watcher.go`)
- Safe File Mover → Windows Atomic Move: attempts atomic rename (evidence: `README.md`)
- Safe File Mover → Category Folders: routes files
- App Entrypoint → Rotating Log: sets up logging (evidence: `main.go`)
- Directory Watcher → Rotating Log: records activity
