# shehreenzainab/file-organizer-bot architecture

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

- Interactive diagram: https://gitdiagram.com/shehreenzainab/file-organizer-bot
- Repository: https://github.com/shehreenzainab/file-organizer-bot

## Overview

File Organizer Bot is a command-line folder organizer. The user selects preview, one-time sorting, or live watching; files are categorized by extension and either previewed or moved into category folders. The single runtime module owns configuration loading, both processing modes, collision handling, and moves. README capabilities such as configurable rules, fallback categorization, and duplicate-safe moves are reflected; future improvements are excluded.

Main entry points: [`organizer.py`](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py) (Organize file), [`config.json`](https://github.com/shehreenzainab/file-organizer-bot/blob/main/config.json) (Rules config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Startup and modes"]
  node_cli["CLI startup<br/>[organizer.py]"]
  node_config["Rules config<br/>[config.json]"]
  node_config_load["Load config<br/>[organizer.py]"]
  node_mode["Mode selection<br/>[organizer.py]"]
end

subgraph group_processing["File processing"]
  node_organize["Organize file<br/>[organizer.py]"]
  node_categorize["Extension categories<br/>[organizer.py]"]
  node_destination["Unique destination<br/>[organizer.py]"]
end

subgraph group_filesystem["Filesystem monitoring"]
  node_existing_scan["Existing-file scan<br/>[organizer.py]"]
  node_watchdog["Watchdog observer<br/>[organizer.py]"]
  node_file_events(("File creation events"))
  node_event_handler["Event handler<br/>[organizer.py]"]
  node_file_store["Watch folder"]
  node_watchdog_library["watchdog library"]
end

node_user(("User"))

node_user -->|"starts mode"| node_cli
node_cli -->|"loads rules"| node_config_load
node_config -->|"provides rules"| node_config_load
node_cli -->|"passes options"| node_mode
node_config_load -->|"returns settings"| node_mode
node_mode -->|"sort-existing"| node_existing_scan
node_mode -->|"starts watching"| node_watchdog
node_existing_scan -->|"lists files"| node_file_store
node_existing_scan -->|"organizes each file"| node_organize
node_watchdog -->|"uses observer"| node_watchdog_library
node_watchdog_library -->|"detects creation"| node_file_events
node_file_events -->|"dispatches event"| node_event_handler
node_event_handler -->|"organizes file"| node_organize
node_organize -->|"classifies extension"| node_categorize
node_organize -->|"chooses destination"| node_destination
node_destination -->|"checks collision"| node_file_store
node_organize -->|"moves file"| node_file_store

click node_cli "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_config "https://github.com/shehreenzainab/file-organizer-bot/blob/main/config.json"
click node_config_load "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_mode "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_existing_scan "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_watchdog "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_event_handler "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_organize "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_categorize "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py"
click node_destination "https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.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_config,node_config_load,node_mode,node_user toneBlue
class node_organize,node_categorize,node_destination toneAmber
class node_existing_scan,node_watchdog,node_file_events,node_event_handler,node_file_store,node_watchdog_library toneMint
```

## Components

### Startup and modes

- [CLI startup](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`
- [Rules config](https://github.com/shehreenzainab/file-organizer-bot/blob/main/config.json): `config.json`
- [Load config](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`
- [Mode selection](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`

### File processing

- [Organize file](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`
- [Extension categories](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`
- [Unique destination](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`

### Filesystem monitoring

- [Existing-file scan](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`
- [Watchdog observer](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`
- **File creation events**
- [Event handler](https://github.com/shehreenzainab/file-organizer-bot/blob/main/organizer.py): `organizer.py`
- **Watch folder**
- **watchdog library**

### Other components

- **User**

## Connections

- User → CLI startup: starts mode
- CLI startup → Load config: loads rules
- Rules config → Load config: provides rules
- CLI startup → Mode selection: passes options
- Load config → Mode selection: returns settings
- Mode selection → Existing-file scan: sort-existing
- Mode selection → Watchdog observer: starts watching
- Existing-file scan → Watch folder: lists files
- Existing-file scan → Organize file: organizes each file
- Watchdog observer → watchdog library: uses observer
- watchdog library → File creation events: detects creation
- File creation events → Event handler: dispatches event
- Event handler → Organize file: organizes file
- Organize file → Extension categories: classifies extension
- Organize file → Unique destination: chooses destination
- Unique destination → Watch folder: checks collision
- Organize file → Watch folder: moves file
