# collection-of-things/emc2 architecture

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

- Interactive diagram: https://gitdiagram.com/collection-of-things/emc2
- Repository: https://github.com/collection-of-things/emc2

## Overview

Emc² is a cross-platform email client that combines accounts in one inbox, with optional calendar/workspace and AI features. The main workflow is: connect an account, load and organize mail in the client, then search, read, compose, and send; the local service handles API requests and provider access. The graph includes documented capabilities whose implementation was not sampled, but omits unverified internal wiring. Dashed edges mark optional or incompletely evidenced paths.

Main entry points: [`src/App.tsx`](https://github.com/collection-of-things/emc2/blob/main/src/App.tsx) (Client interface), [`server/index.ts`](https://github.com/collection-of-things/emc2/blob/main/server/index.ts) (HTTP service), [`src/mail-ui.ts`](https://github.com/collection-of-things/emc2/blob/main/src/mail-ui.ts) (Mail navigation), [`src/api.ts`](https://github.com/collection-of-things/emc2/blob/main/src/api.ts) (Renderer API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Mail client"]
  node_app["Client interface<br/>[App.tsx]"]
  node_search["Mail navigation<br/>[mail-ui.ts]"]
  node_compose["Compose and drafts<br/>[draft-session.ts]"]
  node_clientsettings["Client preferences<br/>[SettingsPage.tsx]"]
  node_privacy["Privacy display<br/>[Privacy.tsx]"]
  node_api["Renderer API<br/>[api.ts]"]
  node_notify["Notifications<br/>[notifications.ts]"]
  node_notifyrules["Notification rules<br/>[notifications.ts]"]
  node_theme["Appearance and themes<br/>[appearance.ts]"]
  node_interaction["Keyboard and mouse<br/>[interaction.ts]"]
  node_desktop["Desktop runtime<br/>[main.ts]"]
  node_android["Android client<br/>[MainActivity.java]"]
end

subgraph group_service["Local mail service"]
  node_serviceapi["HTTP service<br/>[index.ts]"]
end

subgraph group_storage["Mail and accounts"]
  node_providers["Mail providers<br/>[providers.ts]"]
  node_store[("Encrypted mail store<br/>[store.ts]")]
  node_mailfeatures["Mail preferences<br/>[mail-features.ts]"]
  node_inboxtabs["Inbox categories<br/>[inbox-tabs.ts]"]
end

subgraph group_work["Workspace features"]
  node_workspace["Workspace data<br/>[workspace.ts]"]
  node_calendar["Calendar and events<br/>[calendar.ts]"]
  node_contacts["Contact management<br/>[contacts.ts]"]
end

subgraph group_optional["Optional integrations"]
  node_agent["AI sorting and replies<br/>[agent-provider.ts]"]
  node_mcp["Scoped MCP access<br/>[mcp.ts]"]
  node_backup["Workspace backups"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"requests data"| node_api
node_api -.->|"calls service"| node_serviceapi
node_serviceapi -->|"syncs accounts"| node_providers
node_serviceapi -->|"reads mail"| node_store
node_providers -.->|"caches mail"| node_store
node_app -->|"shows inbox"| node_search
node_app -->|"manages drafts"| node_compose
node_search -->|"uses categories"| node_inboxtabs
node_clientsettings -->|"configures compose"| node_mailfeatures
node_app -->|"applies privacy"| node_privacy
node_user -.->|"imports contacts"| node_contacts
node_user -.->|"uses calendar"| node_calendar
node_user -.->|"enables AI"| node_agent
node_user -.->|"grants permissions"| node_mcp
node_user -.->|"backs up workspace"| node_backup
node_notify -->|"uses preferences"| node_notifyrules
node_app -->|"configures appearance"| node_theme
node_app -->|"handles input"| node_interaction
node_desktop -->|"starts service"| node_serviceapi
node_user -.->|"uses client"| node_android

click node_app "https://github.com/collection-of-things/emc2/blob/main/src/App.tsx"
click node_search "https://github.com/collection-of-things/emc2/blob/main/src/mail-ui.ts"
click node_compose "https://github.com/collection-of-things/emc2/blob/main/src/compose/draft-session.ts"
click node_clientsettings "https://github.com/collection-of-things/emc2/blob/main/src/settings/SettingsPage.tsx"
click node_privacy "https://github.com/collection-of-things/emc2/blob/main/src/ui/Privacy.tsx"
click node_api "https://github.com/collection-of-things/emc2/blob/main/src/api.ts"
click node_serviceapi "https://github.com/collection-of-things/emc2/blob/main/server/index.ts"
click node_providers "https://github.com/collection-of-things/emc2/blob/main/server/providers.ts"
click node_store "https://github.com/collection-of-things/emc2/blob/main/server/store.ts"
click node_mailfeatures "https://github.com/collection-of-things/emc2/blob/main/shared/mail-features.ts"
click node_inboxtabs "https://github.com/collection-of-things/emc2/blob/main/shared/inbox-tabs.ts"
click node_workspace "https://github.com/collection-of-things/emc2/blob/main/shared/workspace.ts"
click node_calendar "https://github.com/collection-of-things/emc2/blob/main/server/calendar.ts"
click node_contacts "https://github.com/collection-of-things/emc2/blob/main/server/contacts.ts"
click node_agent "https://github.com/collection-of-things/emc2/blob/main/server/agent-provider.ts"
click node_mcp "https://github.com/collection-of-things/emc2/blob/main/server/mcp.ts"
click node_backup "https://github.com/collection-of-things/emc2/blob/main/server/workspace-backup.ts"
click node_notify "https://github.com/collection-of-things/emc2/blob/main/src/notifications.ts"
click node_notifyrules "https://github.com/collection-of-things/emc2/blob/main/shared/notifications.ts"
click node_theme "https://github.com/collection-of-things/emc2/blob/main/src/appearance.ts"
click node_interaction "https://github.com/collection-of-things/emc2/blob/main/src/interaction.ts"
click node_desktop "https://github.com/collection-of-things/emc2/blob/main/desktop/main.ts"
click node_android "https://github.com/collection-of-things/emc2/blob/main/android/app/src/main/java/dev/emc2/android/MainActivity.java"

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,node_search,node_compose,node_clientsettings,node_privacy,node_api,node_notify,node_notifyrules,node_theme,node_interaction,node_desktop,node_android,node_user toneBlue
class node_serviceapi toneAmber
class node_providers,node_store,node_mailfeatures,node_inboxtabs toneMint
class node_workspace,node_calendar,node_contacts toneRose
class node_agent,node_mcp,node_backup toneIndigo
```

## Components

### Mail client

- [Client interface](https://github.com/collection-of-things/emc2/blob/main/src/App.tsx): `src/App.tsx`
- [Mail navigation](https://github.com/collection-of-things/emc2/blob/main/src/mail-ui.ts): `src/mail-ui.ts`
- [Compose and drafts](https://github.com/collection-of-things/emc2/blob/main/src/compose/draft-session.ts): `src/compose/draft-session.ts`
- [Client preferences](https://github.com/collection-of-things/emc2/blob/main/src/settings/SettingsPage.tsx): `src/settings/SettingsPage.tsx`
- [Privacy display](https://github.com/collection-of-things/emc2/blob/main/src/ui/Privacy.tsx): `src/ui/Privacy.tsx`
- [Renderer API](https://github.com/collection-of-things/emc2/blob/main/src/api.ts): `src/api.ts`
- [Notifications](https://github.com/collection-of-things/emc2/blob/main/src/notifications.ts): `src/notifications.ts`
- [Notification rules](https://github.com/collection-of-things/emc2/blob/main/shared/notifications.ts): `shared/notifications.ts`
- [Appearance and themes](https://github.com/collection-of-things/emc2/blob/main/src/appearance.ts): `src/appearance.ts`
- [Keyboard and mouse](https://github.com/collection-of-things/emc2/blob/main/src/interaction.ts): `src/interaction.ts`
- [Desktop runtime](https://github.com/collection-of-things/emc2/blob/main/desktop/main.ts): `desktop/main.ts`
- [Android client](https://github.com/collection-of-things/emc2/blob/main/android/app/src/main/java/dev/emc2/android/MainActivity.java): `android/app/src/main/java/dev/emc2/android/MainActivity.java`

### Local mail service

- [HTTP service](https://github.com/collection-of-things/emc2/blob/main/server/index.ts): `server/index.ts`

### Mail and accounts

- [Mail providers](https://github.com/collection-of-things/emc2/blob/main/server/providers.ts): `server/providers.ts`
- [Encrypted mail store](https://github.com/collection-of-things/emc2/blob/main/server/store.ts): `server/store.ts`
- [Mail preferences](https://github.com/collection-of-things/emc2/blob/main/shared/mail-features.ts): `shared/mail-features.ts`
- [Inbox categories](https://github.com/collection-of-things/emc2/blob/main/shared/inbox-tabs.ts): `shared/inbox-tabs.ts`

### Workspace features

- [Workspace data](https://github.com/collection-of-things/emc2/blob/main/shared/workspace.ts): `shared/workspace.ts`
- [Calendar and events](https://github.com/collection-of-things/emc2/blob/main/server/calendar.ts): `server/calendar.ts`
- [Contact management](https://github.com/collection-of-things/emc2/blob/main/server/contacts.ts): `server/contacts.ts`

### Optional integrations

- [AI sorting and replies](https://github.com/collection-of-things/emc2/blob/main/server/agent-provider.ts): `server/agent-provider.ts`
- [Scoped MCP access](https://github.com/collection-of-things/emc2/blob/main/server/mcp.ts): `server/mcp.ts`
- [Workspace backups](https://github.com/collection-of-things/emc2/blob/main/server/workspace-backup.ts): `server/workspace-backup.ts`

### Other components

- **User**

## Connections

- User → Client interface: uses
- Client interface → Renderer API: requests data (evidence: `src/App.tsx`)
- Renderer API → HTTP service: calls service
- HTTP service → Mail providers: syncs accounts (evidence: `server/index.ts`)
- HTTP service → Encrypted mail store: reads mail (evidence: `server/index.ts`)
- Mail providers → Encrypted mail store: caches mail
- Client interface → Mail navigation: shows inbox (evidence: `src/App.tsx`)
- Client interface → Compose and drafts: manages drafts (evidence: `src/App.tsx`)
- Mail navigation → Inbox categories: uses categories (evidence: `src/mail-ui.ts`)
- Client preferences → Mail preferences: configures compose (evidence: `src/settings/SettingsPage.tsx`)
- Client interface → Privacy display: applies privacy (evidence: `src/App.tsx`)
- User → Contact management: imports contacts
- User → Calendar and events: uses calendar
- User → AI sorting and replies: enables AI
- User → Scoped MCP access: grants permissions
- User → Workspace backups: backs up workspace
- Notifications → Notification rules: uses preferences (evidence: `src/notifications.ts`)
- Client interface → Appearance and themes: configures appearance (evidence: `src/App.tsx`)
- Client interface → Keyboard and mouse: handles input (evidence: `src/App.tsx`)
- Desktop runtime → HTTP service: starts service (evidence: `desktop/main.ts`)
- User → Android client: uses client
