# haierkeys/obsidian-fast-note-sync architecture

> Architecture diagram of the GitHub repository haierkeys/obsidian-fast-note-sync, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/haierkeys/obsidian-fast-note-sync
- Repository: https://github.com/haierkeys/obsidian-fast-note-sync

## Overview

#### Purpose and Runtime

Fast Note Sync is an Obsidian plugin that synchronizes a vault’s notes, attachments, and optionally configuration with a separately deployed Fast Note Sync Service. It targets Obsidian desktop/mobile and is written in TypeScript, bundled for plugin distribution.

Plugin metadata and build output contract are defined by `manifest.json`, `package.json`, and `esbuild.config.mjs`. The runtime entry point is `src/main.ts`.

#### Plugin Bootstrap and Obsidian Integration

`src/main.ts` owns the Obsidian plugin lifecycle: loading settings/runtime state, registering vault/event integrations, and wiring sync, UI, and service clients. It is the boundary between Obsidian APIs and the plugin’s internal synchronization system.

Settings are presented and persisted through `src/setting.tsx`, `src/views/settings-view.tsx`, and the local persistence layer in `src/lib/storage/local_storage_manager.ts`.

#### Sync Orchestration

The synchronization core is organized around operators that apply remote/local changes by resource type. `src/lib/sync/operator.ts` coordinates work; `src/lib/sync/operator_file.ts`, `src/lib/sync/operator_folder.ts`, and `src/lib/sync/operator_note.ts` handle file, directory, and note-specific operations.

`src/lib/sync/sync_state.ts` and `src/lib/sync/runtime_config.ts` maintain lifecycle and effective sync state. `src/lib/sync/concurrency_limiter.ts` constrains parallel operations, while `src/lib/sync/lock_manager.ts` prevents conflicting local/remote work.

#### Remote Service Protocols

The plugin communicates with the external Fast Note Sync Service over HTTP and WebSocket. REST-style requests are centralized in `src/lib/api/http_api_service.ts`. Real-time remote actions and connection lifecycle are handled by `src/lib/sync/websocket_client.ts`, `src/lib/sync/websocket_manager.ts`, and `src/lib/sync/websocket_action.ts`.

Protocol payloads use generated protobuf artifacts in `src/pb/v1/sync.js` and mapping logic in `src/pb/protobuf_mapper.ts`. This creates a clear transport boundary: sync operators consume mapped domain data rather than directly managing wire encoding.

#### Change Detection, Reconciliation, and Persistence

Local/remote reconciliation relies on durable comparison metadata: `src/lib/storage/file_hash_manager.ts` tracks file content identity, `src/lib/storage/folder_snapshot_manager.ts` captures directory state, and `src/lib/storage/config_hash_manager.ts` supports configuration synchronization.

`src/lib/sync/config_manager.ts` and `src/lib/sync/operator_config.ts` apply the separate configuration-sync path. These stores allow offline changes and deletions to be detected and reconciled after a connection returns.

#### User-Facing Sync Operations

Operational feedback is tracked by `src/lib/sync/sync_progress_tracker.ts` and persisted/displayed through `src/lib/sync/sync_log_manager.ts` and `src/views/sync-log-view.tsx`. Status and sharing affordances are integrated into Obsidian UI via `src/lib/ui/status_bar_manager.ts`, `src/lib/ui/menu_manager.ts`, and `src/lib/ui/share_indicator_manager.ts`.

Conflict and recovery workflows are explicit UI boundaries: `src/views/conflict-list-modal.tsx`, `src/views/conflict-resolve-modal.ts`, and `src/views/recycle-bin-modal.ts`. Historical version inspection/restoration is implemented under `src/views/note-history/history-modal.tsx` and `src/views/note-history/history-detail.tsx`.

#### Cloud Features and External Boundaries

Attachment cloud-preview behavior is represented by `src/lib/storage/file_cloud_preview.ts`; sharing flows are exposed through `src/views/share-modal.ts` and `src/views/share-manage-modal.ts`. The plugin depends on the separately deployed Fast Note Sync Service for authorization, synchronization, history, backup, sharing, and collaboration—not an in-repository backend.

Localization is runtime-facing and centralized in `src/i18n/lang.ts` with locale catalogs such as `src/i18n/locales/en.ts` and `src/i18n/locales/zh-CN.ts`.

Main entry points: [`src/lib/sync/operator.ts`](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/operator.ts) (Sync operator), [`src/main.ts`](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/main.ts) (Plugin bootstrap), [`src/lib/api/http_api_service.ts`](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/api/http_api_service.ts) (HTTP API client), [`src/setting.tsx`](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/setting.tsx) (Settings UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["Plugin &amp; Obsidian UI"]
  node_obsidian{{"Obsidian APIs<br/>host runtime"}}
  node_main["Plugin bootstrap<br/>plugin entry<br/>[main.ts]"]
  node_settings["Settings UI<br/>[setting.tsx]"]
  node_settings_view["Settings view<br/>[settings-view.tsx]"]
  node_ui_affordances["Status, menus &amp; sharing UI<br/>UI integration"]
  node_conflict_ui["Conflict &amp; recovery UI<br/>modal views"]
  node_history_ui["Note history UI<br/>history views<br/>[history-modal.tsx]"]
  node_sync_log_ui["Sync feedback UI<br/>log view<br/>[sync-log-view.tsx]"]
  node_i18n["Localization<br/>i18n<br/>[lang.ts]"]
end

subgraph group_sync["Sync Engine"]
  node_operator["Sync operator<br/>orchestrator<br/>[operator.ts]"]
  node_resource_operators["File, folder &amp; note operators<br/>resource handlers<br/>[operator_file.ts]"]
  node_sync_state["Sync state &amp; runtime config<br/>[sync_state.ts]"]
  node_coordination["Concurrency &amp; locking<br/>coordination"]
  node_config_sync["Configuration sync<br/>config handler<br/>[operator_config.ts]"]
  node_progress_log["Progress &amp; sync log<br/>operation feedback"]
end

subgraph group_transport["Service Transport"]
  node_websocket["WebSocket sync channel<br/>realtime client"]
  node_http_api["HTTP API client<br/>REST client"]
  node_protobuf["Protobuf mapping<br/>protocol mapper<br/>[protobuf_mapper.ts]"]
  node_service{{"Fast Note Sync Service<br/>external service"}}
end

subgraph group_storage["State &amp; Reconciliation"]
  node_local_storage[("Local settings storage<br/>persistence")]
  node_reconciliation_store[("Hash &amp; snapshot metadata<br/>reconciliation store")]
  node_cloud_preview["Attachment cloud preview<br/>storage feature"]
end

node_obsidian -->|"hosts"| node_main
node_main -->|"opens"| node_settings
node_settings -->|"renders"| node_settings_view
node_settings -->|"persists"| node_local_storage
node_main -->|"starts sync"| node_operator
node_main -->|"registers"| node_ui_affordances
node_main -->|"loads"| node_i18n
node_operator -->|"updates"| node_sync_state
node_operator -->|"dispatches"| node_resource_operators
node_operator -->|"coordinates through"| node_coordination
node_operator -->|"runs"| node_config_sync
node_operator -->|"compares against"| node_reconciliation_store
node_operator -->|"reports"| node_progress_log
node_progress_log -->|"displays in"| node_sync_log_ui
node_operator -->|"uses realtime sync"| node_websocket
node_resource_operators -->|"uses requests"| node_http_api
node_config_sync -->|"syncs via"| node_http_api
node_http_api -->|"maps payloads"| node_protobuf
node_websocket -->|"maps actions"| node_protobuf
node_http_api -->|"HTTP"| node_service
node_websocket -->|"WebSocket"| node_service
node_ui_affordances -.->|"sharing flows"| node_service
node_conflict_ui -->|"resolves through"| node_operator
node_history_ui -->|"inspects history"| node_service
node_cloud_preview -->|"retrieves previews"| node_service

click node_main "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/main.ts"
click node_settings "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/setting.tsx"
click node_settings_view "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/settings-view.tsx"
click node_ui_affordances "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/ui/status_bar_manager.ts"
click node_conflict_ui "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/conflict-list-modal.tsx"
click node_history_ui "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/note-history/history-modal.tsx"
click node_sync_log_ui "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/sync-log-view.tsx"
click node_operator "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/operator.ts"
click node_resource_operators "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/operator_file.ts"
click node_sync_state "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/sync_state.ts"
click node_coordination "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/concurrency_limiter.ts"
click node_config_sync "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/operator_config.ts"
click node_progress_log "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/sync_progress_tracker.ts"
click node_websocket "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/websocket_manager.ts"
click node_http_api "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/api/http_api_service.ts"
click node_protobuf "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/pb/protobuf_mapper.ts"
click node_local_storage "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/storage/local_storage_manager.ts"
click node_reconciliation_store "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/storage/file_hash_manager.ts"
click node_cloud_preview "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/storage/file_cloud_preview.ts"
click node_i18n "https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/i18n/lang.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_obsidian,node_main,node_settings,node_settings_view,node_ui_affordances,node_conflict_ui,node_history_ui,node_sync_log_ui,node_i18n toneBlue
class node_operator,node_resource_operators,node_sync_state,node_coordination,node_config_sync,node_progress_log toneAmber
class node_websocket,node_http_api,node_protobuf,node_service toneMint
class node_local_storage,node_reconciliation_store,node_cloud_preview toneRose
```

## Components

### Plugin & Obsidian UI

- **Obsidian APIs**: host runtime · Desktop/mobile vault and UI integration boundary.
- [Plugin bootstrap](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/main.ts): plugin entry · Owns lifecycle and wires plugin subsystems. · `src/main.ts`
- [Settings UI](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/setting.tsx): settings · Edits and persists plugin settings. · `src/setting.tsx`
- [Settings view](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/settings-view.tsx): view · `src/views/settings-view.tsx`
- [Status, menus & sharing UI](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/ui/status_bar_manager.ts): UI integration · `src/lib/ui/status_bar_manager.ts`
- [Conflict & recovery UI](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/conflict-list-modal.tsx): modal views · `src/views/conflict-list-modal.tsx`
- [Note history UI](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/note-history/history-modal.tsx): history views · `src/views/note-history/history-modal.tsx`
- [Sync feedback UI](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/views/sync-log-view.tsx): log view · `src/views/sync-log-view.tsx`
- [Localization](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/i18n/lang.ts): i18n · `src/i18n/lang.ts`

### Sync Engine

- [Sync operator](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/operator.ts): orchestrator · Coordinates reconciliation and resource operations. · `src/lib/sync/operator.ts`
- [File, folder & note operators](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/operator_file.ts): resource handlers · `src/lib/sync/operator_file.ts`
- [Sync state & runtime config](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/sync_state.ts): sync state · `src/lib/sync/sync_state.ts`
- [Concurrency & locking](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/concurrency_limiter.ts): coordination · Limits parallel work and prevents conflicting operations. · `src/lib/sync/concurrency_limiter.ts`
- [Configuration sync](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/operator_config.ts): config handler · `src/lib/sync/operator_config.ts`
- [Progress & sync log](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/sync_progress_tracker.ts): operation feedback · `src/lib/sync/sync_progress_tracker.ts`

### Service Transport

- [WebSocket sync channel](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/sync/websocket_manager.ts): realtime client · Manages remote actions and connection lifecycle. · `src/lib/sync/websocket_manager.ts`
- [HTTP API client](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/api/http_api_service.ts): REST client · `src/lib/api/http_api_service.ts`
- [Protobuf mapping](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/pb/protobuf_mapper.ts): protocol mapper · Maps generated wire payloads to domain data. · `src/pb/protobuf_mapper.ts`
- **Fast Note Sync Service**: external service · Provides authorization, sync, history, backup, sharing, and collaboration.

### State & Reconciliation

- [Local settings storage](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/storage/local_storage_manager.ts): persistence · `src/lib/storage/local_storage_manager.ts`
- [Hash & snapshot metadata](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/storage/file_hash_manager.ts): reconciliation store · Durable file, folder, and config comparison state. · `src/lib/storage/file_hash_manager.ts`
- [Attachment cloud preview](https://github.com/haierkeys/obsidian-fast-note-sync/blob/master/src/lib/storage/file_cloud_preview.ts): storage feature · `src/lib/storage/file_cloud_preview.ts`

## Connections

- Obsidian APIs → Plugin bootstrap: hosts
- Plugin bootstrap → Settings UI: opens
- Settings UI → Settings view: renders
- Settings UI → Local settings storage: persists
- Plugin bootstrap → Sync operator: starts sync
- Plugin bootstrap → Status, menus & sharing UI: registers
- Plugin bootstrap → Localization: loads
- Sync operator → Sync state & runtime config: updates
- Sync operator → File, folder & note operators: dispatches
- Sync operator → Concurrency & locking: coordinates through
- Sync operator → Configuration sync: runs
- Sync operator → Hash & snapshot metadata: compares against
- Sync operator → Progress & sync log: reports
- Progress & sync log → Sync feedback UI: displays in
- Sync operator → WebSocket sync channel: uses realtime sync
- File, folder & note operators → HTTP API client: uses requests
- Configuration sync → HTTP API client: syncs via
- HTTP API client → Protobuf mapping: maps payloads
- WebSocket sync channel → Protobuf mapping: maps actions
- HTTP API client → Fast Note Sync Service: HTTP
- WebSocket sync channel → Fast Note Sync Service: WebSocket
- Status, menus & sharing UI → Fast Note Sync Service: sharing flows
- Conflict & recovery UI → Sync operator: resolves through
- Note history UI → Fast Note Sync Service: inspects history
- Attachment cloud preview → Fast Note Sync Service: retrieves previews
