# mearleycf/obsyncit architecture

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

- Interactive diagram: https://gitdiagram.com/mearleycf/obsyncit
- Repository: https://github.com/mearleycf/obsyncit

## Overview

##### Main Components

a. Core Components:
- CLI Interface (main.py)
- TUI Interface (obsync_tui.py)
- Sync Engine (sync.py)
- Backup System (backup.py)
- Vault Manager (vault.py, vault_discovery.py)
- Schema Validation System (schemas/)
- Logging System (logger.py)
- Error Handling System (errors.py)

b. External Components:
- Obsidian Vaults (Source and Target)
- File System (for backups and logs)
- Configuration System (config.toml)

**┌─ User Interfaces ─────────────────────┐**
- CLI (main.py)    TUI (obsync_tui.py)│
- ┬────────────────────────┘
- ↓
**┌─ Core Services ──────────────────────────────────────┐**
- ┌─────────────┐  ┌──────────┐  ┌────────────────┐  │
- Sync Engine  │←→│  Backup  │  │Vault Discovery │  │
- (sync.py)  │  │(backup.py│  │    System      │  │
- ┘  └──────────┘  └────────────────┘  │
- ↑            ↑               ↑             │
- ┼────────────┼───────────────┼─────────────┘
- ↓            ↓               ↓
**┌─ Support Services ────────────────────────────────────┐**
- ┌─────────────┐  ┌──────────┐  ┌────────────────┐  │
- Schema    │  │  Logger  │  │Error Handling  │  │
- Validation  │  │(logger.py│  │  (errors.py)   │  │
- ┘  └──────────┘  └────────────────┘  │
- ┘
- ↑            ↑               ↑
- ↓            ↓               ↓
**┌─ External Systems ─────────────────────────────────────┐**
- ┌─────────────┐  ┌──────────┐  ┌────────────────┐   │
- Obsidian   │  │   File   │  │  Config File   │   │
- Vaults    │  │  System  │  │  (config.toml) │   │
- ┘  └──────────┘  └────────────────┘   │
- ┘

##### Important Relationships to Highlight

- How the CLI and TUI interfaces interact with the Sync Engine
- Backup system's relationship with the file system
- Demonstrate how vault discovery interacts with external Obsidian vaults
- Schema validation's role in the sync process
- Logging and error handling's pervasive nature

##### Additional Elements

- Component types (UI, Core, Support, External)
- Critical path identification

##### Key Architectural Patterns to Emphasize

- Service-based architecture
- Clear separation of concerns
- Layered design
- Error handling and logging across all layers
- Configuration-driven behavior

##### Implementation Details

- JSON schema validation flow
- Backup creation and restoration paths
- Vault discovery mechanism
- Configuration loading process
- Logging and error propagation

Remember to maintain a balance between detail and clarity, focusing on the core functionality while still showing important implementation details that affect the system's behavior.

- How components interact
- The data flow through the system
- Where to add new features
- How to troubleshoot issues
- The system's security and safety measures

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef support fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interface Layer
    subgraph UI
        CLI["CLI Interface"]:::ui
        TUI["TUI Interface"]:::ui
    end

    %% Core Services Layer
    subgraph CoreServices
        SyncEngine["Sync Engine"]:::core
        BackupSystem["Backup System"]:::core
        VaultManager["Vault Manager"]:::core
        VaultDiscovery["Vault Discovery"]:::core
    end

    %% Support Services Layer
    subgraph SupportServices
        SchemaValidation["Schema Validation"]:::support
        Logger["Logger"]:::support
        ErrorHandler["Error Handler"]:::support
    end

    %% External Systems Layer
    subgraph ExternalSystems
        ObsidianVaults["Obsidian Vaults"]:::external
        FileSystem["File System"]:::external
        ConfigFile["Configuration File"]:::external
    end

    %% Relationships
    CLI --> SyncEngine
    TUI --> SyncEngine
    SyncEngine <--> BackupSystem
    SyncEngine <--> VaultManager
    VaultManager <--> VaultDiscovery
    VaultDiscovery --> ObsidianVaults
    BackupSystem --> FileSystem
    SyncEngine --> SchemaValidation
    VaultManager --> SchemaValidation
    SchemaValidation --> ConfigFile
    ErrorHandler --> Logger
    Logger --> FileSystem

    %% Component click events
    click CLI "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/main.py"
    click TUI "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/obsync_tui.py"
    click SyncEngine "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/sync.py"
    click BackupSystem "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/backup.py"
    click VaultManager "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/vault.py"
    click VaultDiscovery "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/vault_discovery.py"
    click SchemaValidation "https://github.com/mearleycf/obsyncit/tree/main/obsyncit/schemas"
    click Logger "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/logger.py"
    click ErrorHandler "https://github.com/mearleycf/obsyncit/blob/main/obsyncit/errors.py"
    click ConfigFile "https://github.com/mearleycf/obsyncit/blob/main/config.toml"

    %% Legend
    subgraph Legend
        UI_Legend["User Interface"]:::ui
        Core_Legend["Core Service"]:::core
        Support_Legend["Support Service"]:::support
        External_Legend["External System"]:::external
    end
```
