# vrtmrz/obsidian-livesync architecture

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

- Interactive diagram: https://gitdiagram.com/vrtmrz/obsidian-livesync
- Repository: https://github.com/vrtmrz/obsidian-livesync

## Overview

- Local Vault → File Handler → Database Access Layer → Replication Engine → Storage Backend

- Event system connections between modules
- UI update notifications

- Configuration management
- Plugin initialization sequence

##### Key Architectural Elements to Highlight

a. Core Architecture:

- Obsidian API  | → | Local Vault Handler| ↔ | Database Layer   |

- ↕                      ↕                        ↕

- UI Components | ← | Event System      | ↔ | Replication Engine|

- ↕

- Storage Backend  |

##### Implementation Details

- Module dependency relationships
- File handling pipeline
- Event propagation system
- Storage access patterns
- Error handling flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Components
    ObsidianAPI[Obsidian API]
    VaultHandler[Local Vault Handler]:::core
    DBAccess[Database Access Layer]:::core
    RepEngine[Replication Engine]:::core
    PouchDB[PouchDB Interface]:::core

    %% Storage Backends
    subgraph Storage
        CouchDB{{CouchDB Connector}}:::storage
        MinIO{{MinIO/S3 Connector}}:::storage
    end

    %% Feature Modules
    subgraph Features
        ConfigSync(Config Sync):::feature
        HiddenSync(Hidden File Sync):::feature
        DocHistory(Document History):::feature
        GlobalHist(Global History):::feature
        ConflictRes(Conflict Resolution):::feature
    end

    %% UI Components
    subgraph UI
        Settings([Settings Tab]):::ui
        LogPane([Log Pane]):::ui
        ConflictDialog([Conflict Resolution Dialog]):::ui
        HistoryViews([History Views]):::ui
    end

    %% Security Layer
    subgraph Security
        E2E[E2E Encryption]:::security
        SecBoundary[Security Boundaries]:::security
    end

    %% Connections
    ObsidianAPI --> VaultHandler
    VaultHandler <--> DBAccess
    DBAccess <--> RepEngine
    RepEngine <--> PouchDB
    PouchDB --> Storage
    
    RepEngine --> Features
    Features --> UI
    
    E2E --> RepEngine
    SecBoundary --> Storage

    %% Event System
    EventSystem{Event System}:::event
    EventSystem <--> VaultHandler
    EventSystem <--> DBAccess
    EventSystem <--> RepEngine
    EventSystem <--> UI

    %% Legend
    subgraph Legend
        L1[Core Component]:::core
        L2{{Storage Backend}}:::storage
        L3(Feature Module):::feature
        L4([UI Component]):::ui
        L5{Event Handler}:::event
        L6[Security Layer]:::security
    end

    %% Styles
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef storage fill:#fcf,stroke:#333,stroke-width:2px
    classDef feature fill:#dfd,stroke:#333,stroke-width:2px
    classDef ui fill:#ddf,stroke:#333,stroke-width:2px
    classDef event fill:#ffd,stroke:#333,stroke-width:2px
    classDef security fill:#fdd,stroke:#333,stroke-width:2px

    %% Click Events
    click VaultHandler "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/core/ModuleFileHandler.ts"
    click DBAccess "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/core/ModuleDatabaseFileAccess.ts"
    click RepEngine "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/core/ModuleReplicator.ts"
    click PouchDB "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/core/ModulePouchDB.ts"
    click CouchDB "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/core/ModuleReplicatorCouchDB.ts"
    click MinIO "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/core/ModuleReplicatorMinIO.ts"
    click ConfigSync "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/features/ConfigSync/CmdConfigSync.ts"
    click HiddenSync "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/features/HiddenFileSync/CmdHiddenFileSync.ts"
    click DocHistory "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/features/DocumentHistory/DocumentHistoryModal.ts"
    click GlobalHist "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/features/GlobalHistory/GlobalHistoryView.ts"
    click ConflictRes "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/features/InteractiveConflictResolving/ConflictResolveModal.ts"
    click Settings "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/features/SettingDialogue/ObsidianLiveSyncSettingTab.ts"
    click LogPane "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/features/Log/LogPaneView.ts"
    click ConflictDialog "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/features/InteractiveConflictResolving/ConflictResolveModal.ts"
    click HistoryViews "https://github.com/vrtmrz/obsidian-livesync/blob/main/src/modules/features/DocumentHistory/DocumentHistoryModal.ts"
```
