How mkdir700/uniclipboard-desktop works
Main Components
• Frontend UI: Represented by the React-based user interface components (pages, layouts, components for clipboard, device, settings, etc.) in the “src” folder. This layer handles the user interaction with pages like Dashboard, Devices, and Settings.
• Tauri Backend (Native Rust): Found in the “src-tauri” folder. This layer is subdivided using a layered, domain-driven design structure:
• API Layer: Contains API endpoints (e.g., in “src-tauri/src/api”) that provide access to functionalities such as clipboard items, events, onboarding, and settings.
• Application Layer: Implements business logic (e.g., clipboard service, device service, file service, sync service in “src-tauri/src/application”).
• Domain Layer: Contains domain models and core business entities (e.g., device and event definitions in “src-tauri/src/domain”).
• Core & Infrastructure Layers:
▪ “Core” provides utilities, context, event bus, and helper modules.
▪ “Infrastructure” includes storage (using Diesel with migrations, DAOs, and database manager), network (WebDAV, WebSocket for sync), security (authentication, encryption, security manager), connection management, and web server constructs.
• Interface Layer: Declares traits and contracts (e.g., for local clipboard access and remote sync) used for abstraction between the backend services and external integrations.
• Database: Although not a separate service, the persistence layer is managed in “src-tauri” with Diesel migrations and models representing clipboard records and device entities.
• Prototypes and Static Assets: HTML prototypes (in “prototypes”) and assets in “public” may be used for development, demonstration, or fallback views.
Relationships and Interactions
• The frontend communicates with the backend via Tauri’s bridge (invoking Rust APIs from JavaScript) for operations such as fetching or syncing clipboard data.
• Within the backend, the API layer routes requests and delegates them to application services, which in turn interact with the domain logic and infrastructure components. For instance:
• A clipboard sync request is sent from the frontend to the backend API, handled by the clipboard service (application layer), which then accesses the storage (infrastructure) and uses encryption (security) before propagating events (via the core’s event bus).
• Device management utilizes both application and domain layers to ensure proper registration and authorization using underlying security modules.
• The network sub-modules (WebDAV & WebSocket) handle external synchronization, while the local database (managed using Diesel and its migrations) stores the persistent state.
Architectural Patterns & Design Principles
• Layered Architecture / Domain-Driven Design: The clear separation into API, application, domain, core, and infrastructure ensures maintainability and separation of concerns.
• Client-Server Communication within a Desktop App: Tauri provides an abstraction that unites the React frontend and the native Rust backend.
• Security and Networking Modules: Emphasis on secure data transfer (AES-GCM encryption) and flexible network sync options (LAN, WebDAV, and WebSocket).
Technologies & Frameworks
• Frontend: React, TypeScript, Vite (as seen in configuration files such as vite.config.ts and tsconfig.json).
• Backend: Rust (cargo files, Rust source in “src-tauri”), Diesel for database management, and Tauri as the desktop framework.
• Additional Tools: TailwindCSS for styling (tailwind.config.js), various Rust libraries for encryption, authentication, and event handling.
• “Frontend (React UI)”
• “API Layer (Tauri/Rust)”
• “Application Services (Clipboard, Device, Sync)”
• “Domain Models (Device, Event, Clipboard Record)”
• “Core Utilities (Event Bus, Context, Helpers)”
• “Infrastructure (Storage/DB, Network/WebDAV, Security, Connections)”
• “Interface Layer (Traits for Clipboard, Sync, Storage)”
• Data flow from the Frontend to the API layer via the Tauri bridge.
• Subsequent internal flows from the API layer to the Application, Domain, and Infrastructure layers.
• Bidirectional communication for synchronization (UI ↔ Backend; Backend ↔ External networks).
• Annotations for modules that interact with external systems (like web servers or network services).