How tutao/tutanota works
Project type and purpose
• This is a mono-repo containing the Tuta Mail client ecosystem: a secure, end-to-end encrypted email client available on Web, Desktop (Electron), Android and iOS.
• It also ships a cross-platform SDK (Rust + TypeScript/WebAssembly), shared business-logic libraries, cryptography packages, and extensive build/CI tooling.
Top-level structure and architectural zones
• Clients:
– src/… → Web client (TypeScript + Mithril, Web Workers)
– common/desktop, desktop.js, resources/… → Electron desktop app (Main & Renderer processes, IPC)
– app-android/… → Android app (Kotlin + native Rust/C++ via JNI, Room/SqlCipher, Android Keystore, Google FCM/SSE)
– app-ios/… → iOS app + extensions (Swift, shared TutaSharedFramework, SqlCipher, Keychain, APNs/SSE)
• Shared logic & SDKs:
– common/api, common/native, common/… → Business logic, platform facades, IPC-schema, generated stubs
– packages/… → Independent libraries (tutanota-crypto, tuta-utils, otest, etc.)
– tuta-sdk/… → Official client SDK in Rust + Swift + Java/Kotlin wrappers
• Persistence & Security:
– Local DB: SqlCipher on mobile/desktop, IndexedDB on web
– Crypto: Argon2id, LibOQS/Kyber, AES, HMAC modules in native and WebAssembly
– Credentials: Android Keystore, iOS Keychain, Electron key store facade
• Remote services:
– Tuta Mail REST API (HTTPS)
– SSE for push notifications & sync events
– File upload/download endpoints (blob facade)
Key interactions
• Client UI layers call common facades → facade implementations dispatch to platform-specific transports (REST, native IPC, WebWorker)
• Crypto operations often occur in Worker threads or native modules via N-API/UNIFFI bindings
• Local storage and offline migrations managed via common/…/offline and migration scripts
• Notifications delivered via SSE client → routed through façades to UI or native OS notifications
Architectural patterns & principles
• Layered architecture:
– Presentation (UI)
– Application (controllers, view-models)
– Facade/Transport (common/api, common/native)
– Persistence/Crypto engines
– External services (REST/SSE)
• Code-sharing via “common” modules and generated IPC stubs to avoid duplication
• Clean separation between platform-specific entrypoints and shared business logic
• Extensive use of Web Workers/Electron Worker processes for CPU-heavy tasks
• Monorepo with package-based modularization and independent build pipelines