How kushal1o1/haul works
1. Repository shape
- This repo is intentionally minimal: the architecture lives almost entirely in two shell scripts, haul.sh and install.sh.
- There is no application framework, package manifest, or multi-module codebase; the system is a Bash-based Linux daemon plus an installer/bootstrapper.
2. Core purpose
- haul is a file-organizing service for Linux that reacts to filesystem events and moves files into categorized destination folders.
- Its main architectural constraint is “event-driven, not polling”: it is designed to wake only when the kernel reports a file arrival.
3. Runtime model
- The daemon depends on inotify-tools for file events and systemd for lifecycle management.
- The watcher is not meant to stay in a long-running application loop; instead it processes an event batch and exits, with systemd expected to restart it.
4. Bootstrap and installation boundary
- install.sh is the setup entrypoint referenced by the README’s one-liner install path.
- Its role is to place haul.sh into the user’s local bin path, make it executable, and install/start the service so the watcher becomes persistent under systemd.
5. Single-script configuration boundary
- The configuration is embedded at the top of ~/.local/bin/haul, not stored in separate config files.
- This block defines the destination root, watched directories, destination folder names, and extension-to-folder routing, making the script itself the primary configuration artifact.
6. Event ingestion subsystem
- The watcher uses inotifywait to observe one or more input folders such as ~/Downloads and ~/Pictures/Screenshots.
- Relevant event types are file completion/move events like close_write and moved_to, which establish the boundary between “file is still being written” and “file is ready to sort.”
7. Routing and categorization subsystem
- Incoming files are classified by the sort_file() logic into category folders under a configurable data root.
- The routing map is extension-based for most files, while screenshots are treated as a special case based on source directory rather than filename extension.
8. Filesystem transfer subsystem
- Once classified, files are moved into the destination hierarchy under ~/Data/ by default.
- The move boundary is important: this is an organizer, not a copier or indexer; the source folder is expected to be cleared as files are processed.
9. Duplicate/conflict handling
- The script explicitly handles two collision cases: identical content with the same name, and same name with different content.
- Identical duplicates are silently discarded, while conflicting files are preserved by renaming with a timestamp suffix before moving.
10. Operational interface
- The user-facing CLI is exposed through commands like install, uninstall, start, stop, restart, status, logs, sweep, and version.
- This suggests a thin command-dispatch layer inside haul.sh that orchestrates service control, one-time sorting, and diagnostics rather than exposing a large API.
11. Observability
- Logging goes to a user-local log file under ~/.local/share/haul/haul.log.
- The log captures lifecycle events, moves, duplicate skips, and conflict renames, which is the main operational trace for the system.
12. External dependencies and environment assumptions
- The architecture is Linux-only and depends on systemd, Bash 4+, and inotify-tools.
- The project assumes local-user installation and user-owned directories, not a multi-user server or cloud service model.
13. Key diagram boundary to draw
- The most accurate architecture diagram would show: watched folders on one side, the Linux kernel/inotify event source in the middle, haul as the sorting engine, and the organized destination tree plus log file on the other side.
- install.sh should be shown as a separate bootstrap path that provisions the daemon and service, while haul.sh remains the runtime and command surface.
Main entry points: haul.sh Command dispatch · install.sh install.sh
Components 14
Bootstrap
Install and lifecycle setup path
- install.sh · Installs the daemon, makes it executable, and wires it into systemd
install.sh - systemd · Keeps the watcher persistent by restarting it after each batch
- Local bin · Target location for the installed haul executable
Runtime
Event-driven file organization service
- haul.sh · Single-script command surface and embedded configuration
haul.sh - Command dispatch · Handles install, uninstall, start, stop, restart, status, logs, sweep, and version
haul.sh - Config block · Defines watched folders, destination root, categories, and routing rules
haul.sh - Event watch · Waits for close_write and moved_to events from watched folders
haul.sh - Sort file · Classifies arrivals into destination folders by extension or source directory
haul.sh - Conflict handling · Drops identical duplicates and renames conflicting files with a timestamp
haul.sh - Move engine · Moves ready files into the organized destination tree
haul.sh - inotify-tools · Provides inotifywait for filesystem event ingestion
Storage
User-owned paths the daemon reads and writes
- Watched folders · Input folders such as Downloads and screenshots
- Data root · Organized output under the user data directory
- haul.log · User-local operational log for lifecycle, moves, duplicates, and conflicts
Connections 18
- install.sh → haul.sh: installs · Copies the runtime script into the user bin path and marks it executable
- install.sh → Local bin: places · Installs the executable into the local user command path
- install.sh → systemd: provisions · Installs and starts the service so the watcher persists
- haul.sh → Command dispatch: exposes · Provides the user-facing command interface
- Command dispatch → Config block: uses · Reads the embedded runtime configuration
- Command dispatch → Event watch: starts · Launches the watcher path for ongoing sorting
- Command dispatch → Move engine: triggers · Runs one-time sweep behavior through the same move pipeline
- Command dispatch → systemd: controls · Delegates service start, stop, restart, and status operations
- Event watch → inotify-tools: depends on · Uses inotifywait to receive filesystem events
- Event watch → Watched folders: observes · Listens on configured input folders
- Event watch → Sort file: hands off to · Passes completed file events into routing logic
- Sort file → Conflict handling: resolves · Applies duplicate and rename policy before moving
- Conflict handling → Move engine: feeds · Sends the final source and destination pair for transfer
- Move engine → Data root: writes to · Moves organized files into the destination hierarchy
- Move engine → haul.log: logs · Records moves, skips, and rename actions
- systemd → Event watch: restarts · Keeps the event-driven watcher alive across batches
- Config block → Watched folders: defines · Declares which directories are monitored
- Config block → Data root: defines · Declares the destination root and category folders