# protonmail/android-mail architecture

> Architecture diagram of the GitHub repository protonmail/android-mail, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/protonmail/android-mail
- Repository: https://github.com/protonmail/android-mail

## Overview

Proton Mail for Android is a native mail client. Its visible application flow is Android entry into the navigation graph, which routes users to mailbox, message, compose, contact, and search screens. The sampled code also shows content indexing coordinated through a repository and user-session/Rust wrappers, plus account-session and storage-quota domain models. The tree and index establish additional major screens, but their implementation details were not sampled; those relationships are omitted rather than inferred.

Main entry points: [`app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`](https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt) (Home routes), [`mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRepositoryImpl.kt`](https://github.com/protonmail/android-mail/blob/main/mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRepositoryImpl.kt) (Content search), [`mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/repository/UserSessionRepository.kt`](https://github.com/protonmail/android-mail/blob/main/mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/repository/UserSessionRepository.kt) (User sessions), [`app/src/main/kotlin/ch/protonmail/android/App.kt`](https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/App.kt) (Android app entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app_flow["App and navigation"]
  node_app_entry["Android app entry<br/>[App.kt]"]
  node_main_activity["Main activity<br/>[MainActivity.kt]"]
  node_home_routes["Home routes<br/>[HomeRoutes.kt]"]
end

subgraph group_mail_work["Mail workflows"]
  node_mailbox["Mailbox<br/>[MailboxScreen.kt]"]
  node_composer["Compose message<br/>[ComposerScreen.kt]"]
  node_conversation_detail["Conversation detail"]
  node_message_body["Message body"]
  node_paged_detail["Paged conversation"]
  node_raw_message["Raw message data"]
  node_contacts["Contact details"]
  node_contact_groups["Contact groups"]
  node_content_search["Content search"]
  node_search_recents["Search recents"]
end

subgraph group_account_session["Accounts and sessions"]
  node_user_session_repo["User sessions"]
  node_session_wrapper["Rust session wrapper"]
  node_session_impl["Session repository"]
  node_account_manager["Account manager"]
end

subgraph group_support["Supporting features"]
  node_storage_quota["Storage quota<br/>[StorageQuota.kt]"]
  node_storage_card["Storage information"]
  node_push_service["Push notifications"]
end

node_user(("Mail user"))

node_user -.->|"opens app"| node_app_entry
node_app_entry -.->|"starts activity"| node_main_activity
node_main_activity -.->|"hosts routes"| node_home_routes
node_home_routes -->|"routes to"| node_mailbox
node_home_routes -->|"routes to"| node_conversation_detail
node_home_routes -->|"routes to"| node_message_body
node_home_routes -->|"routes to"| node_raw_message
node_home_routes -->|"routes to"| node_contacts
node_home_routes -->|"routes to"| node_content_search
node_content_search -->|"uses session wrapper"| node_session_wrapper
node_content_search -->|"reads session"| node_user_session_repo
node_user_session_repo -->|"returns wrapper"| node_session_wrapper
node_account_manager -->|"starts password workflow"| node_user
node_storage_card -->|"displays quota"| node_storage_quota
node_push_service -.->|"handles push"| node_user_session_repo

click node_app_entry "https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/App.kt"
click node_main_activity "https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/MainActivity.kt"
click node_home_routes "https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt"
click node_mailbox "https://github.com/protonmail/android-mail/blob/main/mail-mailbox/presentation/src/main/kotlin/ch/protonmail/android/mailmailbox/presentation/mailbox/MailboxScreen.kt"
click node_composer "https://github.com/protonmail/android-mail/blob/main/mail-composer/presentation/src/main/kotlin/ch/protonmail/android/mailcomposer/presentation/ui/ComposerScreen.kt"
click node_conversation_detail "https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/ConversationDetailScreen.kt"
click node_message_body "https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/EntireMessageBodyScreen.kt"
click node_paged_detail "https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/PagedConversationDetailScreen.kt"
click node_raw_message "https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/RawMessageDataScreen.kt"
click node_contacts "https://github.com/protonmail/android-mail/blob/main/mail-contact/presentation/src/main/kotlin/ch/protonmail/android/mailcontact/presentation/contactdetails/ui/ContactDetailsScreen.kt"
click node_contact_groups "https://github.com/protonmail/android-mail/blob/main/mail-contact/presentation/src/main/kotlin/ch/protonmail/android/mailcontact/presentation/contactgroupdetails/ContactGroupDetailsScreen.kt"
click node_content_search "https://github.com/protonmail/android-mail/blob/main/mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRepositoryImpl.kt"
click node_search_recents "https://github.com/protonmail/android-mail/blob/main/mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRecentsRepositoryImpl.kt"
click node_user_session_repo "https://github.com/protonmail/android-mail/blob/main/mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/repository/UserSessionRepository.kt"
click node_session_wrapper "https://github.com/protonmail/android-mail/blob/main/mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/wrapper/MailUserSessionWrapper.kt"
click node_session_impl "https://github.com/protonmail/android-mail/blob/main/mail-session/data/src/main/kotlin/ch/protonmail/android/mailsession/data/repository/UserSessionRepositoryImpl.kt"
click node_account_manager "https://github.com/protonmail/android-mail/blob/main/shared/core/account-manager/presentation/src/main/kotlin/me/proton/android/core/accountmanager/presentation/AccountManagerOrchestrator.kt"
click node_storage_quota "https://github.com/protonmail/android-mail/blob/main/mail-settings/domain/src/main/kotlin/ch/protonmail/android/mailsettings/domain/model/StorageQuota.kt"
click node_storage_card "https://github.com/protonmail/android-mail/blob/main/mail-settings/presentation/src/main/kotlin/ch/protonmail/android/mailsettings/presentation/settings/AccountStorageInfoCard.kt"
click node_push_service "https://github.com/protonmail/android-mail/blob/main/mail-notifications/src/main/kotlin/ch/protonmail/android/mailnotifications/data/remote/fcm/PMFirebaseMessagingService.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_entry,node_main_activity,node_home_routes,node_user toneBlue
class node_mailbox,node_composer,node_conversation_detail,node_message_body,node_paged_detail,node_raw_message,node_contacts,node_contact_groups,node_content_search,node_search_recents toneAmber
class node_user_session_repo,node_session_wrapper,node_session_impl,node_account_manager toneMint
class node_storage_quota,node_storage_card,node_push_service toneRose
```

## Components

### App and navigation

- [Android app entry](https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/App.kt): `app/src/main/kotlin/ch/protonmail/android/App.kt`
- [Main activity](https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/MainActivity.kt): `app/src/main/kotlin/ch/protonmail/android/MainActivity.kt`
- [Home routes](https://github.com/protonmail/android-mail/blob/main/app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt): `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`

### Mail workflows

- [Mailbox](https://github.com/protonmail/android-mail/blob/main/mail-mailbox/presentation/src/main/kotlin/ch/protonmail/android/mailmailbox/presentation/mailbox/MailboxScreen.kt): `mail-mailbox/presentation/src/main/kotlin/ch/protonmail/android/mailmailbox/presentation/mailbox/MailboxScreen.kt`
- [Compose message](https://github.com/protonmail/android-mail/blob/main/mail-composer/presentation/src/main/kotlin/ch/protonmail/android/mailcomposer/presentation/ui/ComposerScreen.kt): `mail-composer/presentation/src/main/kotlin/ch/protonmail/android/mailcomposer/presentation/ui/ComposerScreen.kt`
- [Conversation detail](https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/ConversationDetailScreen.kt): `mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/ConversationDetailScreen.kt`
- [Message body](https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/EntireMessageBodyScreen.kt): `mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/EntireMessageBodyScreen.kt`
- [Paged conversation](https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/PagedConversationDetailScreen.kt): `mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/PagedConversationDetailScreen.kt`
- [Raw message data](https://github.com/protonmail/android-mail/blob/main/mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/RawMessageDataScreen.kt): `mail-detail/presentation/src/main/kotlin/ch/protonmail/android/maildetail/presentation/ui/RawMessageDataScreen.kt`
- [Contact details](https://github.com/protonmail/android-mail/blob/main/mail-contact/presentation/src/main/kotlin/ch/protonmail/android/mailcontact/presentation/contactdetails/ui/ContactDetailsScreen.kt): `mail-contact/presentation/src/main/kotlin/ch/protonmail/android/mailcontact/presentation/contactdetails/ui/ContactDetailsScreen.kt`
- [Contact groups](https://github.com/protonmail/android-mail/blob/main/mail-contact/presentation/src/main/kotlin/ch/protonmail/android/mailcontact/presentation/contactgroupdetails/ContactGroupDetailsScreen.kt): `mail-contact/presentation/src/main/kotlin/ch/protonmail/android/mailcontact/presentation/contactgroupdetails/ContactGroupDetailsScreen.kt`
- [Content search](https://github.com/protonmail/android-mail/blob/main/mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRepositoryImpl.kt): `mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRepositoryImpl.kt`
- [Search recents](https://github.com/protonmail/android-mail/blob/main/mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRecentsRepositoryImpl.kt): `mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRecentsRepositoryImpl.kt`

### Accounts and sessions

- [User sessions](https://github.com/protonmail/android-mail/blob/main/mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/repository/UserSessionRepository.kt): `mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/repository/UserSessionRepository.kt`
- [Rust session wrapper](https://github.com/protonmail/android-mail/blob/main/mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/wrapper/MailUserSessionWrapper.kt): `mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/wrapper/MailUserSessionWrapper.kt`
- [Session repository](https://github.com/protonmail/android-mail/blob/main/mail-session/data/src/main/kotlin/ch/protonmail/android/mailsession/data/repository/UserSessionRepositoryImpl.kt): `mail-session/data/src/main/kotlin/ch/protonmail/android/mailsession/data/repository/UserSessionRepositoryImpl.kt`
- [Account manager](https://github.com/protonmail/android-mail/blob/main/shared/core/account-manager/presentation/src/main/kotlin/me/proton/android/core/accountmanager/presentation/AccountManagerOrchestrator.kt): `shared/core/account-manager/presentation/src/main/kotlin/me/proton/android/core/accountmanager/presentation/AccountManagerOrchestrator.kt`

### Supporting features

- [Storage quota](https://github.com/protonmail/android-mail/blob/main/mail-settings/domain/src/main/kotlin/ch/protonmail/android/mailsettings/domain/model/StorageQuota.kt): `mail-settings/domain/src/main/kotlin/ch/protonmail/android/mailsettings/domain/model/StorageQuota.kt`
- [Storage information](https://github.com/protonmail/android-mail/blob/main/mail-settings/presentation/src/main/kotlin/ch/protonmail/android/mailsettings/presentation/settings/AccountStorageInfoCard.kt): `mail-settings/presentation/src/main/kotlin/ch/protonmail/android/mailsettings/presentation/settings/AccountStorageInfoCard.kt`
- [Push notifications](https://github.com/protonmail/android-mail/blob/main/mail-notifications/src/main/kotlin/ch/protonmail/android/mailnotifications/data/remote/fcm/PMFirebaseMessagingService.kt): `mail-notifications/src/main/kotlin/ch/protonmail/android/mailnotifications/data/remote/fcm/PMFirebaseMessagingService.kt`

### Other components

- **Mail user**

## Connections

- Mail user → Android app entry: opens app
- Android app entry → Main activity: starts activity (evidence: `app/src/main/kotlin/ch/protonmail/android/MainActivity.kt`)
- Main activity → Home routes: hosts routes (evidence: `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`)
- Home routes → Mailbox: routes to (evidence: `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`)
- Home routes → Conversation detail: routes to (evidence: `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`)
- Home routes → Message body: routes to (evidence: `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`)
- Home routes → Raw message data: routes to (evidence: `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`)
- Home routes → Contact details: routes to (evidence: `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`)
- Home routes → Content search: routes to (evidence: `app/src/main/kotlin/ch/protonmail/android/navigation/route/HomeRoutes.kt`)
- Content search → Rust session wrapper: uses session wrapper (evidence: `mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRepositoryImpl.kt`)
- Content search → User sessions: reads session (evidence: `mail-content-search/data/src/main/kotlin/ch/protonmail/android/mailcontentsearch/data/repository/ContentSearchRepositoryImpl.kt`)
- User sessions → Rust session wrapper: returns wrapper (evidence: `mail-session/domain/src/main/kotlin/ch/protonmail/android/mailsession/domain/repository/UserSessionRepository.kt`)
- Account manager → Mail user: starts password workflow (evidence: `shared/core/account-manager/presentation/src/main/kotlin/me/proton/android/core/accountmanager/presentation/AccountManagerOrchestrator.kt`)
- Storage information → Storage quota: displays quota (evidence: `mail-settings/presentation/src/main/kotlin/ch/protonmail/android/mailsettings/presentation/settings/AccountStorageInfoCard.kt`)
- Push notifications → User sessions: handles push
