# oscarcpc/copyfiles architecture

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

- Interactive diagram: https://gitdiagram.com/oscarcpc/copyfiles
- Repository: https://github.com/oscarcpc/copyfiles

## Overview

##### Main Components
- GUI Layer: This is implemented in Copyfiles.py together with the PyQt5 framework. The user interface components (windows, buttons, input fields) should be clearly represented. Also, incorporate the stylesheet file (Combinear.qss) which styles the GUI.
- File Operations Engine: A core module in the application that handles batch file copying, directory cleanup, progress tracking, and calls to multi-threaded routines for file operations.
- Search Engine: This module is responsible for file content search capabilities including advanced pattern matching using various logical operators (AND, OR, NOT, XOR, NAND, NOR) and configurations like adjustable thread count.
- Multi-threading Manager: A component that handles thread configuration and parallel execution for both copy and search operations.
- Logging and Result Management: This component deals with recording operation logs (as indicated by the log directory and “copyfiles.log”) and handling search results (managed in the “found” directory under the anon/files path as specified in the README).

##### Component Relationships and Interactions
- The GUI Layer is the entry point for user interaction. It dispatches user commands to either the File Operations Engine or the Search Engine.
- Both the File Operations Engine and Search Engine interact with the Multi-threading Manager to scale operations across multiple threads, improving performance during intensive operations.
- Once operations (copying or searching) are performed, feedback such as progress updates or logs is routed back to the GUI for real-time display.
- The Logging/Result Management component receives outputs from the business logic layers (file copy or search results) and updates file/directory structures accordingly.

##### Architectural Patterns and Key Design Principles
- Separation of Concerns: Clearly delineate the presentation layer (GUI) from the operational logic (file operations and search).
- Modular Design: Each functionality (copying, searching, logging, threading) should be represented as an independent module.
- Concurrency/Parallelism: Emphasize the implementation of multi-threading across both file operations and search functionalities. This suggests careful management of thread pools and synchronization where necessary.

##### Technology & Frameworks
- PyQt5 is used for building the user interface, so indicate a “GUI Framework” component.
- Python’s built-in libraries (os, threading, etc.) and possibly third-party libraries for enhanced threading and file system manipulations should be mentioned.
- Use file system components to represent both operational output (logs, search results) and configurations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% GUI Layer
    subgraph "GUI Layer"
        GUI["GUI (PyQt5)\n(styles from Combinear.qss)"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        FOP["File Operations Engine"]:::business
        SE["Search Engine"]:::business
        MTM["Multi-threading Manager"]:::business
    end

    %% Infrastructure/Data Layer
    subgraph "Infrastructure/Data Layer"
        LRM["Logging & Result Management\n(Logs, Found Results)"]:::data
    end

    %% Component Relationships
    GUI -->|"triggers_copy"| FOP
    GUI -->|"triggers_search"| SE

    FOP -->|"uses_threads"| MTM
    SE -->|"uses_threads"| MTM

    FOP -->|"sends_logs"| LRM
    SE -->|"sends_logs"| LRM

    LRM -->|"feedback_updates"| GUI

    %% Click Events
    click GUI "https://github.com/oscarcpc/copyfiles/blob/main/Copyfiles.py"
    click GUI "https://github.com/oscarcpc/copyfiles/blob/main/Combinear.qss"
    click FOP "https://github.com/oscarcpc/copyfiles/blob/main/Copyfiles.py"
    click SE "https://github.com/oscarcpc/copyfiles/blob/main/Copyfiles.py"
    click MTM "https://github.com/oscarcpc/copyfiles/blob/main/Copyfiles.py"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef business fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
