# alack/xdrive architecture

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

- Interactive diagram: https://gitdiagram.com/alack/xdrive
- Repository: https://github.com/alack/xdrive

## Overview

##### Main Components (Top Level)

a) User Interface Layer
- Using a top-level container labeled "UI Components"
- Directory Bar
- Directory View
- Menu Bar
- Status Bar
- Title Bar
- Web View

b) Core Application Layer
- Central component showing the main application logic
- UniDrive.py as the core orchestrator

c) Storage Layer
- Abstract Store base class and its implementations

d) Cloud Services Layer
- External cloud service providers section
- Google Drive and Dropbox connections

##### Component Relationships

a) Data Flow
- Core Application → Storage Layer
- Storage Layer → Cloud Services

b) Dependencies
- How store_factory creates concrete store implementations
- How cloud_storage interfaces with external services

##### Specific Implementation Details

Create subsections showing:

a) Storage Implementation
- Store Factory pattern implementation
- Connection between directory_entry and store implementations
- Token management system (tokenbox)

b) File Management
- FileManager components
- Chunking and merging capabilities
- File distribution system

##### Key Architectural Patterns to Highlight

- Factory Pattern (store_factory.py)
- Strategy Pattern (different store implementations)
- MVC Pattern (separation of UI, logic, and data)

##### Technical Details

a) Authentication Flow
- Token management system
- How client_secret.json and idpw.json are used

b) Error Handling
- How errors propagate through the system

##### External Dependencies

- Cloud API connections
- Required external libraries (from requirements.txt)

##### Testing Architecture

A separate section showing:
- Test structure and organization
- Sample data flow in tests
- Test coverage for different components

- UI Layer (uicomponents)
- Business Logic (UniDrive.py and core components)
- Storage Management (store package)
- Cloud Service Integration (cloud_storage package)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        MainUI["Main UI"]:::ui
        DirView["Directory View"]:::ui
        MenuBar["Menu Bar"]:::ui
        StatusBar["Status Bar"]:::ui
        DirBar["Directory Bar"]:::ui
        TitleBar["Title Bar"]:::ui
    end

    subgraph Core["Core Application Layer"]
        UniDrive["UniDrive Controller"]:::core
        StoreFactory["Store Factory"]:::core
        BaseStore["Base Store"]:::core
        GDriveStore["Google Drive Store"]:::core
        DropboxStore["Dropbox Store"]:::core
        DirEntry["Directory Entry"]:::core
    end

    subgraph Cloud["Cloud Storage Integration"]
        BaseCloud["Base Cloud Storage"]:::cloud
        GCloudImpl["Google Cloud Implementation"]:::cloud
        DBXImpl["Dropbox Implementation"]:::cloud
        CloudCreds["Cloud Credentials"]:::config
    end

    subgraph FileM["File Management Layer"]
        ChunkOps["Chunk Operations"]:::file
        MergeOps["Merge Operations"]:::file
        ChunkTest["Chunk Testing"]:::file
    end

    subgraph Config["Configuration & Token Management"]
        TokenHandler["Token Handler"]:::auth
        TokenStorage["Token Storage"]:::config
        MainConfig["Main Config"]:::config
        StoreList["Store List"]:::config
    end

    subgraph Exceptions["Exception Handling"]
        StoreExcept["Store Exceptions"]:::error
    end

    %% Relationships
    MainUI --> UniDrive
    DirView --> UniDrive
    MenuBar --> UniDrive
    StatusBar --> UniDrive
    DirBar --> UniDrive
    TitleBar --> UniDrive

    UniDrive --> StoreFactory
    StoreFactory --> BaseStore
    BaseStore --> GDriveStore
    BaseStore --> DropboxStore
    
    GDriveStore --> GCloudImpl
    DropboxStore --> DBXImpl
    
    GCloudImpl --> CloudCreds
    DBXImpl --> CloudCreds

    UniDrive --> TokenHandler
    TokenHandler --> TokenStorage

    ChunkOps --> GCloudImpl
    ChunkOps --> DBXImpl
    MergeOps --> ChunkOps

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef cloud fill:#f1c40f,stroke:#f39c12,color:black
    classDef file fill:#9b59b6,stroke:#8e44ad,color:white
    classDef config fill:#e74c3c,stroke:#c0392b,color:white
    classDef auth fill:#1abc9c,stroke:#16a085,color:white
    classDef error fill:#e74c3c,stroke:#c0392b,color:white

    %% Click Events
    click MainUI "https://github.com/alack/XDrive/blob/master/mainUI.py"
    click DirView "https://github.com/alack/XDrive/blob/master/uicomponents/directory_view.py"
    click MenuBar "https://github.com/alack/XDrive/blob/master/uicomponents/menu_bar.py"
    click StatusBar "https://github.com/alack/XDrive/blob/master/uicomponents/status_bar.py"
    click DirBar "https://github.com/alack/XDrive/blob/master/uicomponents/directory_bar.py"
    click TitleBar "https://github.com/alack/XDrive/blob/master/uicomponents/title_bar.py"
    click UniDrive "https://github.com/alack/XDrive/blob/master/UniDrive.py"
    click StoreFactory "https://github.com/alack/XDrive/blob/master/store/store_factory.py"
    click BaseStore "https://github.com/alack/XDrive/blob/master/store/store.py"
    click GDriveStore "https://github.com/alack/XDrive/blob/master/store/google_drive_store.py"
    click DropboxStore "https://github.com/alack/XDrive/blob/master/store/dropbox_store.py"
    click DirEntry "https://github.com/alack/XDrive/blob/master/store/directory_entry.py"
    click BaseCloud "https://github.com/alack/XDrive/blob/master/cloud_storage/cloud_storage.py"
    click GCloudImpl "https://github.com/alack/XDrive/blob/master/cloud_storage/google_cloud_storage.py"
    click DBXImpl "https://github.com/alack/XDrive/blob/master/cloud_storage/dbx_cloud_storage.py"
    click CloudCreds "https://github.com/alack/XDrive/blob/master/cloud_storage/data/client_secret.json"
    click ChunkOps "https://github.com/alack/XDrive/blob/master/FileManager/chunk.py"
    click MergeOps "https://github.com/alack/XDrive/blob/master/FileManager/merge.py"
    click ChunkTest "https://github.com/alack/XDrive/blob/master/FileManager/FileChunkTest.py"
    click TokenHandler "https://github.com/alack/XDrive/blob/master/tokenbox/tokenbox.py"
    click TokenStorage "https://github.com/alack/XDrive/blob/master/tokenbox.json"
    click StoreExcept "https://github.com/alack/XDrive/blob/master/exceptions/store_exception.py"
    click MainConfig "https://github.com/alack/XDrive/blob/master/config.json"
    click StoreList "https://github.com/alack/XDrive/blob/master/store_list.json"
```
