# mridulparth/folderfortsync architecture

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

- Interactive diagram: https://gitdiagram.com/mridulparth/folderfortsync
- Repository: https://github.com/mridulparth/folderfortsync

## Overview

##### Project Type & Purpose
- The project is a full-featured file synchronization tool aimed at providing secure, real-time cloud backup.
- It offers secure authentication, intuitive file selection, and complete sync controls with features like pause/resume and auto-retry, all wrapped in a modern dark UI.

##### Main Components
- Sync Application Entry Point (sync_app.py): Acts as the central controller that initializes the UI and orchestrates the file sync process.
- UI Components (ui_components.py): Contains the visual elements, custom dialogs, and layout definitions powered by CustomTkinter.
- File Uploader (file_uploader.py): Manages the core logic of file transfers including upload, progress tracking, error handling, and retry mechanisms.
- Folder Manager (folder_manager.py): Handles operations related to FolderFort Cloud, such as fetching and managing remote folder structures.
- External Dependencies and Libraries: Utilize CustomTkinter (UI), Requests (API communication), Humanize (displaying file sizes and times), and Keyring (secure credential storage).

##### Relationships & Interactions
- The Main Application (sync_app.py) serves as the central hub. It initializes the UI components and ties together the file uploader and folder manager.
- The UI layer interacts with users by prompting for API tokens, allowing file/folder selection, and presenting sync controls. User actions make calls to:
- The File Uploader for starting, pausing, resuming, or stopping the sync.
- The Folder Manager to refresh and select cloud folders.
- The File Uploader and Folder Manager modules communicate with external services:
- File Uploader uses HTTP requests (via the Requests library) to send files to the cloud.
- Folder Manager interacts with the FolderFort Cloud API to fetch available folders and manage remote structures.
- Secure authentication is achieved by capturing the API token (via the UI) and securely storing it using Keyring.

##### Important Architectural Patterns & Design Principles
- Separation of Concerns: The project isolates UI (ui_components.py), business logic for file transfers (file_uploader.py), and cloud interactions (folder_manager.py) into discrete modules.
- Modularization: By splitting the functionality into separate Python files, the project is easier to maintain and extend.
- Clear Data Flow: The main application acts as a mediator, directing information between the user interface and backend synchronization components.
- Error Handling & Retry: The File Uploader includes logic to auto-retry failed transfers, ensuring robustness.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Start["User Action"]:::frontend
    Start -->|"triggers"| UI

    subgraph "UI Layer"
        UI["UI Components (ui_components.py)"]:::frontend
    end

    subgraph "Business Logic"
        Sync["Sync Application (sync_app.py)"]:::backend
        Uploader["File Uploader (file_uploader.py)"]:::backend
        FolderMgr["Folder Manager (folder_manager.py)"]:::backend
    end

    subgraph "External Services"
        Cloud["FolderFort Cloud API"]:::external
        Keyring["Authentication & Credential Storage (Keyring)"]:::external
    end

    UI -->|"initializes and sends commands"| Sync
    UI <-->|"manages API_token"| Keyring
    Sync -->|"initiates upload"| Uploader
    Sync -->|"requests folder info"| FolderMgr
    Uploader -->|"uploads files (HTTP/Requests,Humanize)"| Cloud
    FolderMgr -->|"fetches folder data"| Cloud

    click Sync "https://github.com/mridulparth/folderfortsync/blob/main/sync_app.py"
    click UI "https://github.com/mridulparth/folderfortsync/blob/main/ui_components.py"
    click Uploader "https://github.com/mridulparth/folderfortsync/blob/main/file_uploader.py"
    click FolderMgr "https://github.com/mridulparth/folderfortsync/blob/main/folder_manager.py"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
