# floccusaddon/floccus architecture

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

- Interactive diagram: https://gitdiagram.com/floccusaddon/floccus
- Repository: https://github.com/floccusaddon/floccus

## Overview

##### Main Components

a. Client Applications
- Browser Extensions (Firefox, Chrome, Edge, etc.)
- Android App
- iOS App (in development)

b. Core Components
- Account Management System
- Synchronization Engine
- Adapter Layer
- Storage Layer

c. External Services
- Nextcloud Bookmarks
- Google Drive
- Git Servers
- WebDAV Services
- Linkwarden

##### Architecture Patterns to Highlight

- Adapter Pattern (for different sync backends)
- MVC Pattern (visible in the src/lib structure)
- Plugin Architecture (for different browsers and platforms)
- Event-driven Architecture (for sync operations)

##### Component Relationships

**[Client Apps] <-> [Core Engine] <-> [Adapter Layer] <-> [External Services]**

##### Detailed Component Breakdown

Core Engine:
- Controller (src/lib/Controller.ts)
- Account Management (src/lib/Account.ts)
- Tree Management (src/lib/Tree.ts)
- Crypto Layer (src/lib/Crypto.ts)

Adapter Layer:
- NextcloudBookmarks Adapter
- WebDAV Adapter
- Google Drive Adapter
- Git Adapter
- Linkwarden Adapter

**a. Data Flow:**
- Client -> Core Engine -> Adapter -> External Service

**b. Sync Strategies:**
- Default
- Merge
- Unidirectional

**c. Security Layer:**
- Encryption
- Authentication
- Secure Storage

##### Implementation Details

Important implementation aspects:
- Browser API Integration
- Native Platform Support
- Localization System
- Storage Mechanisms

**Top: User Interfaces (Browser Extensions, Mobile Apps)**
**Middle: Core Services (Sync Engine, Account Management)**
**Bottom: External Services (Storage Backends)**

##### Additional Notes

Annotations for:
- Supported platforms
- Security features
- Sync strategies
- Configuration options

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef core fill:#b3d1ff,stroke:#333
    classDef client fill:#90EE90,stroke:#333
    classDef external fill:#FFB366,stroke:#333
    classDef adapter fill:#DDA0DD,stroke:#333
    classDef storage fill:#A9A9A9,stroke:#333
    classDef ui fill:#98FB98,stroke:#333
    classDef strategy fill:#FFE4B5,stroke:#333

    %% Client Applications Layer
    subgraph Clients
        BExt["Browser Extensions"]:::client
        Android["Android App"]:::client
        iOS["iOS App (Beta)"]:::client
        UI["User Interfaces"]:::ui
    end

    %% Core Components Layer
    subgraph Core
        Controller["Controller"]:::core
        Account["Account Management"]:::core
        Tree["Tree Management"]:::core
        Crypto["Crypto Layer"]:::core
        I18n["Localization System"]:::core
    end

    %% Storage Layer
    subgraph Storage
        BStorage["Browser Storage"]:::storage
        NStorage["Native Storage"]:::storage
    end

    %% Sync Strategies
    subgraph Strategies
        Default["Default Strategy"]:::strategy
        Merge["Merge Strategy"]:::strategy
        Uni["Unidirectional Strategy"]:::strategy
    end

    %% Adapter Layer
    subgraph Adapters
        NextCloud["Nextcloud Adapter"]:::adapter
        WebDAV["WebDAV Adapter"]:::adapter
        GDrive["Google Drive Adapter"]:::adapter
        Git["Git Adapter"]:::adapter
        Linkwarden["Linkwarden Adapter"]:::adapter
    end

    %% External Services
    subgraph External
        NC["Nextcloud"]:::external
        WD["WebDAV Services"]:::external
        GD["Google Drive"]:::external
        GS["Git Servers"]:::external
        LW["Linkwarden"]:::external
    end

    %% Relationships
    BExt --> UI
    Android --> UI
    iOS --> UI
    UI --> Controller
    Controller --> Account
    Controller --> Tree
    Controller --> Crypto
    Controller --> I18n
    Account --> BStorage
    Account --> NStorage
    Controller --> Strategies
    Strategies --> Adapters
    NextCloud --> NC
    WebDAV --> WD
    GDrive --> GD
    Git --> GS
    Linkwarden --> LW

    %% Click events
    click BExt "https://github.com/floccusaddon/floccus/tree/develop/src/lib/browser/"
    click Android "https://github.com/floccusaddon/floccus/tree/develop//android/"
    click iOS "https://github.com/floccusaddon/floccus/tree/develop//ios/"
    click Controller "https://github.com/floccusaddon/floccus/blob/develop/src/lib/Controller.ts"
    click Account "https://github.com/floccusaddon/floccus/blob/develop/src/lib/Account.ts"
    click Tree "https://github.com/floccusaddon/floccus/blob/develop/src/lib/Tree.ts"
    click Crypto "https://github.com/floccusaddon/floccus/blob/develop/src/lib/Crypto.ts"
    click I18n "https://github.com/floccusaddon/floccus/blob/develop/src/lib/native/I18n.ts"
    click BStorage "https://github.com/floccusaddon/floccus/blob/develop/src/lib/browser/BrowserAccountStorage.js"
    click NStorage "https://github.com/floccusaddon/floccus/blob/develop/src/lib/native/NativeAccountStorage.js"
    click Default "https://github.com/floccusaddon/floccus/blob/develop/src/lib/strategies/Default.ts"
    click Merge "https://github.com/floccusaddon/floccus/blob/develop/src/lib/strategies/Merge.ts"
    click Uni "https://github.com/floccusaddon/floccus/blob/develop/src/lib/strategies/Unidirectional.ts"
    click NextCloud "https://github.com/floccusaddon/floccus/blob/develop/src/lib/adapters/NextcloudBookmarks.ts"
    click WebDAV "https://github.com/floccusaddon/floccus/blob/develop/src/lib/adapters/WebDav.ts"
    click GDrive "https://github.com/floccusaddon/floccus/blob/develop/src/lib/adapters/GoogleDrive.ts"
    click Git "https://github.com/floccusaddon/floccus/blob/develop/src/lib/adapters/Git.ts"
    click Linkwarden "https://github.com/floccusaddon/floccus/blob/develop/src/lib/adapters/Linkwarden.ts"
    click UI "https://github.com/floccusaddon/floccus/blob/develop/src/ui/App.vue"
```
