How deltachat/deltachat-desktop works
Main Components
• Frontend/User Interface:
– Located in packages/frontend, this contains all React components (menu screens, dialogs, chat components, contexts, hooks, and styling).
– It includes numerous UI subcomponents (dialogs, chat lists, avatars, themes, etc.) and helper modules.
• Shared/Business Logic:
– Found in packages/shared and parts of packages/runtime, these modules contain constants, state management, localization, logging, and utility functions used across the application.
• Platform-Specific Wrappers:
• Tauri (packages/target-tauri): Contains Rust-based backend code integrated with a lightweight front end. This edition is built to provide an alternative with reduced disk/ram usage.
• Browser (packages/target-browser): An experimental version that uses a webserver component and in-browser UI.
• End-to-End Testing:
– packages/e2e-tests provides the testing environment (using Playwright and custom test scripts) to simulate user interactions and run integration tests.
• Ancillary Tools and Scripts:
– Various build scripts, linting configurations, and helper scripts found in bin/ and documentation directories ensure consistent development, testing, and deployment.
Relationships and Data Flow
• End users interact with the UI components in the frontend.
• The frontend components use React contexts and hooks to send user actions to business logic which in turn interfaces with the backend runtime modules.
• Depending on the target platform, the runtime and shared modules interface with the native layer: Electron’s IPC and native system integration or Tauri’s Rust backend integration.
• The communications between the frontend and native layers should be explicitly depicted (for example, showing IPC channels in Electron or messaging protocols in Tauri).
• External dependencies such as Delta Chat Core (which, although not shown directly in the file tree, is referenced in the README) and external services (e.g., email servers) for sending/receiving messages.
Architectural Patterns and Principles
• Separation of Concerns: The clear boundaries between frontend logic (React UI components), shared business logic (state management, utilities), and platform-specific wrappers (Electron, Tauri, Browser) should be emphasized.
• Modular/Microservices-like Structure: Represent each package (target-electron, target-tauri, target-browser, frontend, shared, runtime) as independent modules that interact via well-defined APIs.
• Use of Context Providers and Hooks in the frontend indicates a component-based, reactive design.
• Build/Dependency Management: Monorepo structure managed via pnpm workspaces shows a centralized handling of dependencies and common scripts (build, lint, formatting, tests).
2. Divide it into at least three primary layers:
– User Interface Layer: Include “packages/frontend” and its sub-components.
– Business Logic/Shared Services Layer: Include “packages/shared”, “packages/runtime”, and common utilities.
– Platform Abstraction Layer: Create three components/subsystems for “target-electron”, “target-tauri”, and “target-browser”. Within these, indicate the involvement of native integrations (e.g., Electron IPC, Tauri’s Rust runtime).
3. Overlay supporting components such as configuration management, build scripts (bin/ and related directories), and testing (packages/e2e-tests).
5. Integration points with external dependencies (Delta Chat Core, email servers, etc.) if applicable.