Downloads Cleanup Manager¶
A robust, configurable Python utility built with Domain-Driven Design (DDD) to automatically organize and archive your cluttered downloads directory.
Table of Contents¶
Overview¶
The Downloads Cleanup Manager uses simple, declarative rules to organize cluttered directories.
The Flow¶
The program operates as follows:
- The Cleanup Manager retrieves a list of File Items from the designated Downloads directory.
- For each File Item, the manager evaluates a series of Routing Rules (which check the file's keyword, extension, or MIME type).
- If a Rule successfully matches the file, the manager executes a Move Action, relocating the file to the Rule's target destination.
- If a file does not match any Routing Rules, it is evaluated by the Archive Policy. If the file is older than the maximum allowed age and is not exceptionally large, the policy authorizes an Archive Action, moving the file to a long-term storage directory organized by date.
- If the file is too new or too large to be archived, it is skipped and remains in the Downloads directory.
- After all files are processed, the manager dispatches a Summary Notification detailing every action performed.
High-Level Architecture¶
The project is structured according to strict Domain-Driven Design (DDD) principles employing layered architecture:
- Domain Layer: Contains business entities (Files, Actions), routing rules, and archiving policies.
- Application Layer: Contains the orchestration (Use Cases) and interfaces for external dependencies.
- Infrastructure Layer: Contains concrete implementations for file systems, config parsing, MIME detection, and email notifications.
Setup & Installation¶
The project uses conda for environment and dependency management.
- Clone the repository (if you haven't already).
- Create the conda environment:
- Configure the application:
- Copy or edit
config/config.json. - Update your
paths,routingmaps, andnotificationssettings as required. - Example configuration documentation can be found in the Configuration Docs.
Usage¶
The application is executed via a wrapper script that automatically ensures the conda environment is active.
# Run a dry-run (preview changes without moving files)
./bin/cleanup_manager.sh --dry-run
# Run the actual cleanup
./bin/cleanup_manager.sh
Detailed Documentation¶
To understand the system design or to extend its functionality, please review the detailed documentation for each architectural layer:
- The Domain Layer (
01_domain.md) - Core models, rules, and business logic. - The Application Layer (
02_application.md) - Orchestration, use cases, and system sequence. - The Infrastructure Layer (
03_infrastructure.md) - Concrete adapters and implementation details. - Configuration Reference (
04_configuration.md) - Guide forconfig.json.
Viewing the Documentation Locally¶
This project uses MkDocs with the Material theme for beautifully rendered documentation. To view it locally as a webpage:
- Ensure your conda environment is activated:
- Start the local development server:
- Open your browser and navigate to:
http://127.0.0.1:8000/