# catvox/smartzip architecture

> Architecture diagram of the GitHub repository catvox/smartzip, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/catvox/smartzip
- Repository: https://github.com/catvox/smartzip

## Overview

##### Project Type and Purpose
- This project is a desktop utility built with AutoHotkey scripts. Its main purpose is to provide “smart” compression and decompression functionality – including password handling, nested archive extraction, and integration with Windows Explorer’s right-click menu.

##### Analyzing the File Structure
- The top-level files include SmartZip.ahk (the main script), Contextmenu.ahk (dedicated to processing right-click commands), configuration documentation (ini.md and possibly an associated .ini file), along with assets (the pic folder) for various UI screenshots.
- Notice that there aren’t distinct “frontend” or “backend” directories since this isn’t a full-stack app; rather, it’s a single-process tool organized into a few script files that perform distinct roles.
- The presence of .gitattributes, .gitignore, LICENSE, and README.md confirms that while it is a simple utility, the project is maintained in a version-controlled, open-source style.

##### Main Components
- User Interaction Component:
- GUI/Drag-and-Drop Interface: Triggered when the user double-clicks or drags files onto SmartZip.exe.
- Command-Line Execution: Handling arguments such as “x” for decompression, “a” for compression, etc.
- Context Menu Integration: Represented by Contextmenu.ahk, which accepts commands from Explorer’s right-click and passes parameters to SmartZip.

- Core Processing Logic:
- Decompression Engine: Implements “智能解压” (smart decompression) behaviors, including dealing with password-protected archives (supporting built-in fallback passwords, last-used passwords, and clipboard-ed text), decompressing single versus multiple archives, and handling nested archives.
- Compression Engine: Manages compression operations with rules that decide when to generate separate archives per folder or a single archive when mixing file types.

- Configuration and Customization Module:
- INI & Settings Parser: Reads user preferences and script configuration (as referenced in ini.md), including custom password lists, rename/delete rules after decompression, etc.
- Dynamic Updating and Persistence: Capturing the “recently used” passwords and dynamically reordering them.

- External Integration:
- 7-Zip Dependency: Although the project is built in AutoHotkey, it leverages external tools like 7-Zip (as mentioned in the README’s links and supported version) for actual compression/decompression.

- Utility & Helper Components:
- Logging and Error Feedback: Likely built-in (possibly within the script) to provide messages when decompression fails or requires manual password input.
- UI Components: The various screenshots (set.gif, xc.jpg, menu.jpg, addZip.jpg, unZip.jpg) provided in the pic folder hint at multiple dialogs or windows for settings, manual code specification, and batch processing tasks.

##### Relationships and Interactions
- Start at the User Entry Points:
- GUI/drag-drop, command-line invocation, or context menu activation.
- They all converge into the main SmartZip.ahk script which then:
- Parses the command-line arguments or input parameters.
- Consults the INI/settings configuration.
- Decides which engine (compression vs. decompression) to invoke.
- When performing decompression, the engine may call submodules for password checking, nested archive handling, and post-processing (renaming or deletion).
- The Contextmenu.ahk script acts as a proxy—it collects user-selected files from the Explorer right-click and then relays commands to the main script.

##### Architectural Patterns and Design Principles
- Modular Design: Even though it’s a single or a couple of scripts, think of the design as separated modules for UI handling, processing, configuration management, and integration.
- Separation of Concerns: Each module is responsible for one aspect (e.g., decompression logic, password handling, external tool invocation).
- Extensibility: The presence of configuration files and import mechanisms for legacy settings shows that the codebase is designed to be extended with new features or custom user configurations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Components
    subgraph "User Interfaces"
        A("GUI/Drag-Drop/CLI"):::userinter
        B("Context Menu"):::userinter
    end

    %% Core Processing Layer
    subgraph "Core Processing"
        C("Command Parser & Engines"):::core
        D("Compression Engine"):::core
        E("Decompression Engine"):::core
    end

    %% Configuration Module
    subgraph "Configuration & Customization"
        F("INI & Settings Parser"):::config
    end

    %% External Tools and Helpers
    subgraph "External & Helper Components"
        G("7-Zip (External)"):::external
        H("UI Feedback & Logging"):::helper
    end

    %% UI Assets
    subgraph "UI Components"
        I("Visual Assets"):::assets
    end

    %% Connections
    A -->|"sendsCommand"| C
    B -->|"sendsCommand"| C

    C -->|"triggers"| D
    C -->|"triggers"| E
    C -->|"readsConfig"| F

    D -->|"callsExe"| G
    E -->|"callsExe"| G

    D -->|"returnsStatus"| H
    E -->|"returnsStatus"| H

    H -->|"displaysUsing"| I

    %% Click Events
    click A "https://github.com/catvox/smartzip/blob/main/SmartZip.ahk"
    click C "https://github.com/catvox/smartzip/blob/main/SmartZip.ahk"
    click B "https://github.com/catvox/smartzip/blob/main/Contextmenu.ahk"
    click F "https://github.com/catvox/smartzip/blob/main/ini.md"
    click I "https://github.com/catvox/smartzip/tree/main/pic"

    %% Styles
    classDef userinter fill:#FFC0CB,stroke:#FF1493,stroke-width:2px;
    classDef core fill:#FFFFCC,stroke:#FF8C00,stroke-width:2px;
    classDef config fill:#CCFFCC,stroke:#228B22,stroke-width:2px;
    classDef external fill:#CEE6F3,stroke:#1E90FF,stroke-width:2px;
    classDef helper fill:#DDA0DD,stroke:#800080,stroke-width:2px;
    classDef assets fill:#F0FFF0,stroke:#32CD32,stroke-width:2px;
```
