# deltachat/deltachat-desktop architecture

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

- Interactive diagram: https://gitdiagram.com/deltachat/deltachat-desktop
- Repository: https://github.com/deltachat/deltachat-desktop

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    A("End User"):::external

    %% User Interface Layer
    subgraph "User Interface Layer"
        UI("UI Components"):::frontend
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        SH("Shared Utilities"):::logic
        RT("Runtime Support"):::logic
        SH --> RT
    end

    %% Platform Abstraction Layer
    subgraph "Platform Abstraction Layer"
        EP("Electron Wrapper (IPC,NativeIntegrations)"):::platform
        TA("Tauri Wrapper (RustBackend)"):::platform
        BR("Browser Edition (WebIntegration)"):::platform
    end

    %% External Dependencies
    subgraph "External Dependencies"
        DC("Delta Chat Core"):::external
        ES("Email Servers"):::external
    end

    %% Ancillary Tools and Scripts
    subgraph "Ancillary Tools and Scripts"
        BN("Build Scripts"):::ancillary
        DOC("Documentation"):::ancillary
    end

    %% Testing Layer
    TEST("E2E Testing (Playwright)"):::testing

    %% Connections
    A -->|"interacts"| UI
    UI -->|"triggers"| SH
    RT -->|"interfaces"| EP
    RT -->|"interfaces"| TA
    RT -->|"interfaces"| BR

    EP -->|"communicates"| DC
    EP -->|"communicates"| ES
    TA -->|"communicates"| DC
    TA -->|"communicates"| ES
    BR -->|"communicates"| DC
    BR -->|"communicates"| ES

    TEST -->|"tests"| UI

    BN -->|"builds/lints"| SH
    BN -->|"supports"| EP
    DOC -->|"documents"| SH

    %% Click Events
    click UI "https://github.com/deltachat/deltachat-desktop/tree/main/packages/frontend"
    click SH "https://github.com/deltachat/deltachat-desktop/tree/main/packages/shared"
    click RT "https://github.com/deltachat/deltachat-desktop/tree/main/packages/runtime"
    click EP "https://github.com/deltachat/deltachat-desktop/tree/main/packages/target-electron"
    click TA "https://github.com/deltachat/deltachat-desktop/tree/main/packages/target-tauri"
    click BR "https://github.com/deltachat/deltachat-desktop/tree/main/packages/target-browser"
    click TEST "https://github.com/deltachat/deltachat-desktop/tree/main/packages/e2e-tests"
    click BN "https://github.com/deltachat/deltachat-desktop/tree/main/bin"
    click DOC "https://github.com/deltachat/deltachat-desktop/tree/main/docs"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef platform fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef testing fill:#F5CBA7,stroke:#E67E22,stroke-width:2px;
    classDef ancillary fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
```
