# System Architecture How the Tauri shell, Rust backend modules, and Proton WebClients frontend work together. ## Module Map
graph TB
    subgraph "User's Machine"
        TAURI[Tauri v2 Shell]
        
        subgraph "Rust Backend"
            MAIN[main.rs
Entry Point & AppState] LS[live_sync.rs
Bidirectional Sync] SDB[sync_db.rs
SQLite Persistence] NAV[proton_navigation.rs
SSO/CAPTCHA Routing] WV_C[webview_cookies.rs
Cookie Management] WV_S[webview_storage.rs
Data Directory] URL[url_log.rs
Log Sanitizer] end subgraph "WebView" WC[Proton WebClients
React App] end SQLITE[(SQLite
sync state)] end PROTON[Proton Drive API] MAIN --> LS MAIN --> SDB MAIN --> NAV MAIN --> WV_C MAIN --> WV_S MAIN --> URL MAIN --> WC LS --> SDB LS --> PROTON SDB --> SQLITE WV_C --> WC
## Module Declarations in main.rs ```rust mod live_sync; mod proton_navigation; mod sync_db; mod url_log; mod webview_cookies; mod webview_storage; ``` Note: `auth.rs` (388 lines) exists in `src-tauri/src/` but is **not declared as a module** in `main.rs`. It implements SRP authentication with the `proton-srp` crate and may be intended for future integration. ## Architecture Overview **Tauri Shell** — Manages the WebView window, proxies HTTP requests through a Rust-based proxy with shared cookie jar, and provides the sync bridge for the WebClients frontend. **Live Sync** — A bidirectional sync engine. A local `notify` file watcher monitors filesystem changes, while a periodic poller fetches remote changes from the Proton API. Changes flow both ways with a suppression TTL (30s) to prevent echo loops. **Sync Database** — SQLite (WAL mode) persistence for sync metadata. Tracks file hashes, remote IDs, sync states, and retry counts via `sync_roots` and `sync_items` tables. **Navigation** — Three specific URL interception handlers for the Proton SSO/authentication flow, not a general-purpose router. **WebView Layer** — Cookie management bridges WebKit's native cookie store with the in-process `reqwest` jar (merged via `combined_cookie_header`), data directory scaffolding, and log-safe URL sanitization.