# nboada/shift architecture

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

- Interactive diagram: https://gitdiagram.com/nboada/shift
- Repository: https://github.com/nboada/shift

## Overview

Shift is a local-first desktop email client with a shared mail/composer core and a Rust/Tauri backend. The main workflow is opening the inbox, reading or composing mail, then applying changes that the backend caches locally and syncs with Gmail or IMAP. The graph also includes documented scheduling, AI, invites, settings, attachments, and mobile UI capabilities. Some backend modules are indexed but unsampled, so edges to them are shown only where the README or excerpts establish the relationship.

Main entry points: [`src-tauri/src/lib.rs`](https://github.com/nboada/shift/blob/main/src-tauri/src/lib.rs) (Tauri commands), [`src/core/composer.ts`](https://github.com/nboada/shift/blob/main/src/core/composer.ts) (Composer core), [`src/email-view.ts`](https://github.com/nboada/shift/blob/main/src/email-view.ts) (Message reader), [`src/core/mail.ts`](https://github.com/nboada/shift/blob/main/src/core/mail.ts) (Mail state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interfaces"]
  node_desktop["Desktop app<br/>[main.ts]"]
  node_phone["Phone app<br/>[phone.ts]"]
end

subgraph group_mail["Mail experience"]
  node_mailcore["Mail state<br/>[mail.ts]"]
  node_reader["Message reader<br/>[email-view.ts]"]
  node_composer["Composer core<br/>[composer.ts]"]
  node_composeui["Composer UI<br/>[compose.ts]"]
  node_attachments["Attachments<br/>[attachments.ts]"]
  node_invites["Invite replies<br/>[invite.ts]"]
  node_schedule["Send scheduling<br/>[schedule.ts]"]
end

subgraph group_backend["Mail backend"]
  node_backend["Tauri commands<br/>[lib.rs]"]
  node_cache[("SQLite mail cache<br/>[db.rs]")]
  node_gmail["Gmail client<br/>[gmail.rs]"]
  node_imap["IMAP and SMTP<br/>[imap.rs]"]
  node_auth["Account auth<br/>[auth.rs]"]
end

subgraph group_support["Account and extensions"]
  node_settingsui["Settings UI<br/>[settings-ui.ts]"]
  node_settings["Preferences<br/>[settings.ts]"]
  node_ai["AI features<br/>[ai.rs]"]
  node_invitebackend["Invite handling<br/>[invite.rs]"]
end

node_user(("Mail user"))
node_provider["Mail providers"]
node_keychain[("macOS Keychain")]

node_user -->|"uses"| node_desktop
node_user -->|"uses"| node_phone
node_desktop -->|"drives"| node_mailcore
node_phone -->|"uses"| node_mailcore
node_desktop -->|"renders"| node_reader
node_phone -->|"renders"| node_reader
node_desktop -->|"opens"| node_composer
node_phone -->|"renders"| node_composeui
node_composeui -->|"delegates to"| node_composer
node_composer -->|"reads state"| node_mailcore
node_composer -->|"uses"| node_attachments
node_reader -->|"renders"| node_attachments
node_reader -->|"reads messages"| node_mailcore
node_mailcore -->|"invokes commands"| node_backend
node_composer -->|"saves and sends"| node_backend
node_backend -->|"reads and writes"| node_cache
node_backend -->|"dispatches Gmail"| node_gmail
node_backend -->|"dispatches IMAP"| node_imap
node_gmail -->|"syncs mail"| node_provider
node_imap -->|"syncs and sends"| node_provider
node_backend -->|"authenticates accounts"| node_auth
node_auth -->|"stores tokens"| node_keychain
node_settingsui -->|"updates preferences"| node_settings
node_settings -->|"loads and saves"| node_backend
node_composer -->|"schedules sends"| node_schedule
node_backend -->|"handles RSVP"| node_invitebackend
node_reader -->|"submits RSVP"| node_invitebackend
node_backend -->|"provides AI"| node_ai
node_settings -->|"stores AI keys"| node_keychain

click node_desktop "https://github.com/nboada/shift/blob/main/src/main.ts"
click node_phone "https://github.com/nboada/shift/blob/main/src/mobile/phone.ts"
click node_mailcore "https://github.com/nboada/shift/blob/main/src/core/mail.ts"
click node_reader "https://github.com/nboada/shift/blob/main/src/email-view.ts"
click node_composer "https://github.com/nboada/shift/blob/main/src/core/composer.ts"
click node_composeui "https://github.com/nboada/shift/blob/main/src/compose.ts"
click node_attachments "https://github.com/nboada/shift/blob/main/src/attachments.ts"
click node_invites "https://github.com/nboada/shift/blob/main/src/invite.ts"
click node_schedule "https://github.com/nboada/shift/blob/main/src/schedule.ts"
click node_settingsui "https://github.com/nboada/shift/blob/main/src/settings-ui.ts"
click node_settings "https://github.com/nboada/shift/blob/main/src/settings.ts"
click node_backend "https://github.com/nboada/shift/blob/main/src-tauri/src/lib.rs"
click node_cache "https://github.com/nboada/shift/blob/main/src-tauri/src/db.rs"
click node_gmail "https://github.com/nboada/shift/blob/main/src-tauri/src/gmail.rs"
click node_imap "https://github.com/nboada/shift/blob/main/src-tauri/src/imap.rs"
click node_auth "https://github.com/nboada/shift/blob/main/src-tauri/src/auth.rs"
click node_ai "https://github.com/nboada/shift/blob/main/src-tauri/src/ai.rs"
click node_invitebackend "https://github.com/nboada/shift/blob/main/src-tauri/src/invite.rs"

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_desktop,node_phone,node_user toneBlue
class node_mailcore,node_reader,node_composer,node_composeui,node_attachments,node_invites,node_schedule,node_keychain toneAmber
class node_backend,node_cache,node_gmail,node_imap,node_auth toneMint
class node_settingsui,node_settings,node_ai,node_invitebackend toneRose
class node_provider toneIndigo
```

## Components

### User interfaces

- [Desktop app](https://github.com/nboada/shift/blob/main/src/main.ts): `src/main.ts`
- [Phone app](https://github.com/nboada/shift/blob/main/src/mobile/phone.ts): `src/mobile/phone.ts`

### Mail experience

- [Mail state](https://github.com/nboada/shift/blob/main/src/core/mail.ts): `src/core/mail.ts`
- [Message reader](https://github.com/nboada/shift/blob/main/src/email-view.ts): `src/email-view.ts`
- [Composer core](https://github.com/nboada/shift/blob/main/src/core/composer.ts): `src/core/composer.ts`
- [Composer UI](https://github.com/nboada/shift/blob/main/src/compose.ts): `src/compose.ts`
- [Attachments](https://github.com/nboada/shift/blob/main/src/attachments.ts): `src/attachments.ts`
- [Invite replies](https://github.com/nboada/shift/blob/main/src/invite.ts): `src/invite.ts`
- [Send scheduling](https://github.com/nboada/shift/blob/main/src/schedule.ts): `src/schedule.ts`

### Mail backend

- [Tauri commands](https://github.com/nboada/shift/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [SQLite mail cache](https://github.com/nboada/shift/blob/main/src-tauri/src/db.rs): `src-tauri/src/db.rs`
- [Gmail client](https://github.com/nboada/shift/blob/main/src-tauri/src/gmail.rs): `src-tauri/src/gmail.rs`
- [IMAP and SMTP](https://github.com/nboada/shift/blob/main/src-tauri/src/imap.rs): `src-tauri/src/imap.rs`
- [Account auth](https://github.com/nboada/shift/blob/main/src-tauri/src/auth.rs): `src-tauri/src/auth.rs`

### Account and extensions

- [Settings UI](https://github.com/nboada/shift/blob/main/src/settings-ui.ts): `src/settings-ui.ts`
- [Preferences](https://github.com/nboada/shift/blob/main/src/settings.ts): `src/settings.ts`
- [AI features](https://github.com/nboada/shift/blob/main/src-tauri/src/ai.rs): `src-tauri/src/ai.rs`
- [Invite handling](https://github.com/nboada/shift/blob/main/src-tauri/src/invite.rs): `src-tauri/src/invite.rs`

### Other components

- **Mail user**
- **Mail providers**
- **macOS Keychain**

## Connections

- Mail user → Desktop app: uses
- Mail user → Phone app: uses
- Desktop app → Mail state: drives (evidence: `src/main.ts`)
- Phone app → Mail state: uses (evidence: `src/mobile/phone.ts`)
- Desktop app → Message reader: renders (evidence: `src/main.ts`)
- Phone app → Message reader: renders (evidence: `src/mobile/phone.ts`)
- Desktop app → Composer core: opens (evidence: `src/main.ts`)
- Phone app → Composer UI: renders
- Composer UI → Composer core: delegates to (evidence: `src/mobile/compose-sheet.ts`)
- Composer core → Mail state: reads state (evidence: `src/core/composer.ts`)
- Composer core → Attachments: uses (evidence: `src/core/composer.ts`)
- Message reader → Attachments: renders (evidence: `src/email-view.ts`)
- Message reader → Mail state: reads messages (evidence: `src/email-view.ts`)
- Mail state → Tauri commands: invokes commands (evidence: `src/core/mail.ts`)
- Composer core → Tauri commands: saves and sends
- Tauri commands → SQLite mail cache: reads and writes (evidence: `src-tauri/src/lib.rs`)
- Tauri commands → Gmail client: dispatches Gmail (evidence: `src-tauri/src/lib.rs`)
- Tauri commands → IMAP and SMTP: dispatches IMAP (evidence: `src-tauri/src/lib.rs`)
- Gmail client → Mail providers: syncs mail
- IMAP and SMTP → Mail providers: syncs and sends
- Tauri commands → Account auth: authenticates accounts (evidence: `src-tauri/src/lib.rs`)
- Account auth → macOS Keychain: stores tokens
- Settings UI → Preferences: updates preferences (evidence: `src/settings-ui.ts`)
- Preferences → Tauri commands: loads and saves (evidence: `src/settings.ts`)
- Composer core → Send scheduling: schedules sends (evidence: `src/core/composer.ts`)
- Tauri commands → Invite handling: handles RSVP (evidence: `src-tauri/src/lib.rs`)
- Message reader → Invite handling: submits RSVP (evidence: `src/email-view.ts`)
- Tauri commands → AI features: provides AI (evidence: `src-tauri/src/lib.rs`)
- Preferences → macOS Keychain: stores AI keys
