# ahmedkhaleel2004/mach architecture

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

- Interactive diagram: https://gitdiagram.com/ahmedkhaleel2004/mach
- Repository: https://github.com/ahmedkhaleel2004/mach

## Overview

Mach is a native Mac and iPhone mail client built around a local-first mailbox: users sign in, read and search locally stored mail, act or compose offline, and synchronize changes with Gmail or Outlook. The graph highlights the shared app model, local store and provider integrations, plus conversation rendering and optional push delivery. Several feature paths are documented in the README but their implementation files were not sampled; those links cite the README rather than implying source inspection.

Main entry points: [`Core/Sources/MachCore/MailService.swift`](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/MailService.swift) (Mail service), [`App/Shared/AppModel.swift`](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/AppModel.swift) (App model), [`App/iOS/PhoneApp.swift`](https://github.com/ahmedkhaleel2004/mach/blob/main/App/iOS/PhoneApp.swift) (iPhone app), [`App/Mac/MacApp.swift`](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Mac/MacApp.swift) (Mac app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Native clients"]
  node_mac["Mac app<br/>[MacApp.swift]"]
  node_iphone["iPhone app<br/>[PhoneApp.swift]"]
  node_bootstrap["App bootstrap<br/>[Bootstrap.swift]"]
  node_model["App model<br/>[AppModel.swift]"]
  node_views["Mail views<br/>[Views.swift]"]
  node_theme["Themes<br/>[Theme.swift]"]
end

subgraph group_mailcore["Mail and sync core"]
  node_service["Mail service<br/>[MailService.swift]"]
  node_auth["OAuth sign-in<br/>[Auth.swift]"]
  node_sync["Mailbox synchronization<br/>[Sync.swift]"]
  node_store[("Local mailbox store<br/>[Store.swift]")]
  node_gmail["Gmail API client<br/>[GmailAPI.swift]"]
  node_graph["Microsoft Graph client<br/>[GraphAPI.swift]"]
  node_people["Contacts and photos<br/>[People.swift]"]
end

subgraph group_experience["Mail experience"]
  node_composer["Compose view<br/>[ComposeView.swift]"]
  node_conversation["Conversation web view<br/>[ThreadWeb.swift]"]
  node_avatars["Sender avatars<br/>[AvatarStore.swift]"]
end

subgraph group_push["Push notifications"]
  node_notifications["Mail notifications<br/>[Notifier.swift]"]
  node_pushshare["Push state sharing<br/>[PushShare.swift]"]
  node_extension["Notification extension"]
  node_publicpush["iPhone push handling<br/>[PublicPush.swift]"]
  node_relay["Push relay worker<br/>[worker.js]"]
end

node_user(("Mail user"))
node_gmailservice["Gmail"]
node_microsoft["Outlook / Graph"]
node_applepush["Apple push service"]

node_user -->|"uses"| node_mac
node_user -->|"uses"| node_iphone
node_mac -->|"opens service"| node_bootstrap
node_iphone -->|"opens service"| node_bootstrap
node_bootstrap -->|"creates"| node_service
node_mac -->|"presents"| node_model
node_iphone -->|"uses"| node_model
node_model -->|"requests mail"| node_service
node_model -->|"observes drafts"| node_store
node_model -->|"drives"| node_views
node_views -->|"styles"| node_theme
node_views -->|"shows"| node_avatars
node_model -->|"loads thread"| node_conversation
node_model -.->|"opens compose"| node_composer
node_service -->|"uses"| node_store
node_service -->|"uses"| node_gmail
node_service -->|"uses"| node_graph
node_service -->|"authenticates"| node_auth
node_auth -.->|"signs in"| node_gmailservice
node_auth -.->|"signs in"| node_microsoft
node_gmail -.->|"requests mail"| node_gmailservice
node_graph -.->|"requests mail"| node_microsoft
node_service -.->|"coordinates sync"| node_sync
node_sync -.->|"updates local copy"| node_store
node_sync -.->|"fetches changes"| node_gmail
node_model -->|"announces mail"| node_notifications
node_notifications -->|"checks accounts"| node_service
node_iphone -->|"handles push"| node_publicpush
node_publicpush -->|"uses shared state"| node_pushshare
node_extension -->|"reads shared state"| node_pushshare
node_relay -.->|"sends notifications"| node_applepush
node_gmailservice -.->|"signals new mail"| node_relay
node_microsoft -.->|"signals new mail"| node_relay
node_service -->|"looks up contacts"| node_people
node_people -.->|"reads Outlook contacts"| node_microsoft
node_service -.->|"reads and changes mail"| node_gmailservice

click node_mac "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Mac/MacApp.swift"
click node_iphone "https://github.com/ahmedkhaleel2004/mach/blob/main/App/iOS/PhoneApp.swift"
click node_bootstrap "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Bootstrap.swift"
click node_model "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/AppModel.swift"
click node_views "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Views.swift"
click node_theme "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Theme.swift"
click node_composer "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/ComposeView.swift"
click node_conversation "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/ThreadWeb.swift"
click node_avatars "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/AvatarStore.swift"
click node_notifications "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Notifier.swift"
click node_pushshare "https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/PushShare.swift"
click node_extension "https://github.com/ahmedkhaleel2004/mach/blob/main/App/NotifyExtension/NotificationService.swift"
click node_publicpush "https://github.com/ahmedkhaleel2004/mach/blob/main/App/iOS/PublicPush.swift"
click node_relay "https://github.com/ahmedkhaleel2004/mach/blob/main/Relay/worker.js"
click node_service "https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/MailService.swift"
click node_auth "https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/Auth.swift"
click node_sync "https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/Sync.swift"
click node_store "https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/Store.swift"
click node_gmail "https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/GmailAPI.swift"
click node_graph "https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/GraphAPI.swift"
click node_people "https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/People.swift"

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_mac,node_iphone,node_bootstrap,node_model,node_views,node_theme,node_user toneBlue
class node_service,node_auth,node_sync,node_store,node_gmail,node_graph,node_people toneAmber
class node_composer,node_conversation,node_avatars toneMint
class node_notifications,node_pushshare,node_extension,node_publicpush,node_relay toneRose
class node_gmailservice,node_microsoft,node_applepush toneIndigo
```

## Components

### Native clients

- [Mac app](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Mac/MacApp.swift): `App/Mac/MacApp.swift`
- [iPhone app](https://github.com/ahmedkhaleel2004/mach/blob/main/App/iOS/PhoneApp.swift): `App/iOS/PhoneApp.swift`
- [App bootstrap](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Bootstrap.swift): `App/Shared/Bootstrap.swift`
- [App model](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/AppModel.swift): `App/Shared/AppModel.swift`
- [Mail views](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Views.swift): `App/Shared/Views.swift`
- [Themes](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Theme.swift): `App/Shared/Theme.swift`

### Mail and sync core

- [Mail service](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/MailService.swift): `Core/Sources/MachCore/MailService.swift`
- [OAuth sign-in](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/Auth.swift): `Core/Sources/MachCore/Auth.swift`
- [Mailbox synchronization](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/Sync.swift): `Core/Sources/MachCore/Sync.swift`
- [Local mailbox store](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/Store.swift): `Core/Sources/MachCore/Store.swift`
- [Gmail API client](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/GmailAPI.swift): `Core/Sources/MachCore/GmailAPI.swift`
- [Microsoft Graph client](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/GraphAPI.swift): `Core/Sources/MachCore/GraphAPI.swift`
- [Contacts and photos](https://github.com/ahmedkhaleel2004/mach/blob/main/Core/Sources/MachCore/People.swift): `Core/Sources/MachCore/People.swift`

### Mail experience

- [Compose view](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/ComposeView.swift): `App/Shared/ComposeView.swift`
- [Conversation web view](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/ThreadWeb.swift): `App/Shared/ThreadWeb.swift`
- [Sender avatars](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/AvatarStore.swift): `App/Shared/AvatarStore.swift`

### Push notifications

- [Mail notifications](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/Notifier.swift): `App/Shared/Notifier.swift`
- [Push state sharing](https://github.com/ahmedkhaleel2004/mach/blob/main/App/Shared/PushShare.swift): `App/Shared/PushShare.swift`
- [Notification extension](https://github.com/ahmedkhaleel2004/mach/blob/main/App/NotifyExtension/NotificationService.swift): `App/NotifyExtension/NotificationService.swift`
- [iPhone push handling](https://github.com/ahmedkhaleel2004/mach/blob/main/App/iOS/PublicPush.swift): `App/iOS/PublicPush.swift`
- [Push relay worker](https://github.com/ahmedkhaleel2004/mach/blob/main/Relay/worker.js): `Relay/worker.js`

### Other components

- **Mail user**
- **Gmail**
- **Outlook / Graph**
- **Apple push service**

## Connections

- Mail user → Mac app: uses (evidence: `README.md`)
- Mail user → iPhone app: uses (evidence: `README.md`)
- Mac app → App bootstrap: opens service (evidence: `App/Mac/MacApp.swift`)
- iPhone app → App bootstrap: opens service (evidence: `App/iOS/PhoneApp.swift`)
- App bootstrap → Mail service: creates (evidence: `App/Shared/Bootstrap.swift`)
- Mac app → App model: presents (evidence: `App/Mac/MacApp.swift`)
- iPhone app → App model: uses (evidence: `App/iOS/PhoneApp.swift`)
- App model → Mail service: requests mail (evidence: `App/Shared/AppModel.swift`)
- App model → Local mailbox store: observes drafts (evidence: `App/Shared/AppModel.swift`)
- App model → Mail views: drives (evidence: `App/Shared/Views.swift`)
- Mail views → Themes: styles (evidence: `App/Shared/Views.swift`)
- Mail views → Sender avatars: shows (evidence: `App/Shared/Views.swift`)
- App model → Conversation web view: loads thread (evidence: `App/Shared/AppModel.swift`)
- App model → Compose view: opens compose (evidence: `README.md`)
- Mail service → Local mailbox store: uses (evidence: `Core/Sources/MachCore/MailService.swift`)
- Mail service → Gmail API client: uses (evidence: `Core/Sources/MachCore/MailService.swift`)
- Mail service → Microsoft Graph client: uses (evidence: `Core/Sources/MachCore/MailService.swift`)
- Mail service → OAuth sign-in: authenticates (evidence: `README.md`)
- OAuth sign-in → Gmail: signs in (evidence: `README.md`)
- OAuth sign-in → Outlook / Graph: signs in (evidence: `README.md`)
- Gmail API client → Gmail: requests mail (evidence: `README.md`)
- Microsoft Graph client → Outlook / Graph: requests mail (evidence: `README.md`)
- Mail service → Mailbox synchronization: coordinates sync (evidence: `README.md`)
- Mailbox synchronization → Local mailbox store: updates local copy (evidence: `README.md`)
- Mailbox synchronization → Gmail API client: fetches changes (evidence: `README.md`)
- App model → Mail notifications: announces mail (evidence: `App/Shared/AppModel.swift`)
- Mail notifications → Mail service: checks accounts (evidence: `App/Shared/Notifier.swift`)
- iPhone app → iPhone push handling: handles push (evidence: `App/iOS/PhoneApp.swift`)
- iPhone push handling → Push state sharing: uses shared state (evidence: `App/iOS/PublicPush.swift`)
- Notification extension → Push state sharing: reads shared state (evidence: `App/NotifyExtension/NotificationService.swift`)
- Push relay worker → Apple push service: sends notifications (evidence: `README.md`)
- Gmail → Push relay worker: signals new mail (evidence: `README.md`)
- Outlook / Graph → Push relay worker: signals new mail (evidence: `README.md`)
- Mail service → Contacts and photos: looks up contacts (evidence: `Core/Sources/MachCore/MailService.swift`)
- Contacts and photos → Outlook / Graph: reads Outlook contacts (evidence: `README.md`)
- Mail service → Gmail: reads and changes mail (evidence: `README.md`)
