# memex-lab/memex architecture

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

- Interactive diagram: https://gitdiagram.com/memex-lab/memex
- Repository: https://github.com/memex-lab/memex

## Overview

Memex is a local-first AI journal: people capture fragments, which the app organizes into cards and knowledge and uses for insights and companion chat. The supplied tree and excerpts cover only native iOS/Android integration, not the Flutter product core or its AI, storage, and knowledge implementation. The graph therefore focuses on the evidenced platform bridge and its capture, media, backup, and background-execution capabilities; README-documented product stages are described but not assigned unsupported source paths.

Main entry points: [`android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt) (Android channel registrar), [`ios/Runner/ChannelRegistrar.swift`](https://github.com/memex-lab/memex/blob/main/ios/Runner/ChannelRegistrar.swift) (iOS channel registrar), [`android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt`](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt) (Android activity), [`android/app/src/main/kotlin/com/memexlab/memex/channels/AgentBackgroundChannelHandler.kt`](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/AgentBackgroundChannelHandler.kt) (Agent background channel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Platform Bootstrap"]
  node_android_activity["Android activity<br/>[MainActivity.kt]"]
  node_android_registrar["Android channel registrar"]
  node_ios_delegate["iOS app delegate<br/>[AppDelegate.swift]"]
  node_ios_registrar["iOS channel registrar"]
end

subgraph group_capture["Capture &amp; Links"]
  node_android_clipboard["Clipboard preview"]
  node_ios_clipboard["Clipboard preview"]
  node_app_actions["App actions"]
  node_external_import["External file import"]
end

subgraph group_media["Media &amp; Rendering"]
  node_audio_converter["Audio conversion"]
  node_ios_audio["Audio conversion"]
  node_webview["WebView rendering"]
end

subgraph group_background["Background Agents"]
  node_android_agent_channel["Agent background channel"]
  node_android_agent_service["Agent status service"]
  node_ios_agent["Agent background tasks"]
end

subgraph group_storage["Storage &amp; System"]
  node_backup_storage["Backup file access"]
  node_backup_import["Backup import"]
  node_ios_storage["iCloud path access"]
  node_system_actions["System actions"]
end

node_flutter(("Memex Flutter app"))

node_flutter -.->|"invokes bridge"| node_android_activity
node_flutter -.->|"invokes bridge"| node_ios_registrar
node_android_activity -->|"registers channels"| node_android_registrar
node_android_activity -->|"handles intents"| node_android_agent_channel
node_android_activity -->|"handles intents"| node_backup_import
node_android_activity -->|"handles intents"| node_external_import
node_android_activity -->|"routes activity results"| node_backup_storage
node_android_registrar -->|"registers"| node_android_agent_channel
node_android_registrar -->|"registers"| node_android_clipboard
node_android_registrar -->|"registers"| node_audio_converter
node_android_registrar -->|"registers"| node_backup_storage
node_android_registrar -->|"registers"| node_backup_import
node_android_registrar -->|"registers"| node_external_import
node_android_registrar -->|"registers"| node_system_actions
node_ios_delegate -->|"registers channels"| node_ios_registrar
node_ios_delegate -->|"routes links"| node_app_actions
node_ios_registrar -->|"registers"| node_ios_clipboard
node_ios_registrar -->|"registers"| node_ios_audio
node_ios_registrar -->|"registers"| node_webview
node_ios_registrar -->|"registers"| node_ios_agent
node_ios_registrar -->|"registers"| node_ios_storage
node_ios_registrar -.->|"registers"| node_system_actions
node_android_agent_channel -->|"starts or updates"| node_android_agent_service
node_ios_agent -->|"dispatches tasks"| node_flutter

click node_android_activity "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt"
click node_android_registrar "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt"
click node_ios_delegate "https://github.com/memex-lab/memex/blob/main/ios/Runner/AppDelegate.swift"
click node_ios_registrar "https://github.com/memex-lab/memex/blob/main/ios/Runner/ChannelRegistrar.swift"
click node_android_clipboard "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/ClipboardPreviewChannelHandler.kt"
click node_ios_clipboard "https://github.com/memex-lab/memex/blob/main/ios/Runner/ClipboardPreviewChannelHandler.swift"
click node_app_actions "https://github.com/memex-lab/memex/blob/main/ios/Runner/AppActionChannelHandler.swift"
click node_external_import "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/ExternalFileImportChannelHandler.kt"
click node_audio_converter "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/AudioConverterChannelHandler.kt"
click node_ios_audio "https://github.com/memex-lab/memex/blob/main/ios/Runner/AudioConverterChannelHandler.swift"
click node_webview "https://github.com/memex-lab/memex/blob/main/ios/Runner/WebViewChannelHandler.swift"
click node_android_agent_channel "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/AgentBackgroundChannelHandler.kt"
click node_android_agent_service "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/AgentBackgroundService.kt"
click node_ios_agent "https://github.com/memex-lab/memex/blob/main/ios/Runner/AgentBackgroundTaskChannelHandler.swift"
click node_backup_storage "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/BackupStorageChannelHandler.kt"
click node_backup_import "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/BackupImportChannelHandler.kt"
click node_ios_storage "https://github.com/memex-lab/memex/blob/main/ios/Runner/StorageChannelHandler.swift"
click node_system_actions "https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/SystemActionsChannelHandler.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_android_activity,node_android_registrar,node_ios_delegate,node_ios_registrar toneBlue
class node_android_clipboard,node_ios_clipboard,node_app_actions,node_external_import toneAmber
class node_audio_converter,node_ios_audio,node_webview toneMint
class node_android_agent_channel,node_android_agent_service,node_ios_agent toneRose
class node_backup_storage,node_backup_import,node_ios_storage,node_system_actions,node_flutter toneIndigo
```

## Components

### Platform Bootstrap

- [Android activity](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt): `android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt`
- [Android channel registrar](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`
- [iOS app delegate](https://github.com/memex-lab/memex/blob/main/ios/Runner/AppDelegate.swift): `ios/Runner/AppDelegate.swift`
- [iOS channel registrar](https://github.com/memex-lab/memex/blob/main/ios/Runner/ChannelRegistrar.swift): `ios/Runner/ChannelRegistrar.swift`

### Capture & Links

- [Clipboard preview](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/ClipboardPreviewChannelHandler.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/ClipboardPreviewChannelHandler.kt`
- [Clipboard preview](https://github.com/memex-lab/memex/blob/main/ios/Runner/ClipboardPreviewChannelHandler.swift): `ios/Runner/ClipboardPreviewChannelHandler.swift`
- [App actions](https://github.com/memex-lab/memex/blob/main/ios/Runner/AppActionChannelHandler.swift): `ios/Runner/AppActionChannelHandler.swift`
- [External file import](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/ExternalFileImportChannelHandler.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/ExternalFileImportChannelHandler.kt`

### Media & Rendering

- [Audio conversion](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/AudioConverterChannelHandler.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/AudioConverterChannelHandler.kt`
- [Audio conversion](https://github.com/memex-lab/memex/blob/main/ios/Runner/AudioConverterChannelHandler.swift): `ios/Runner/AudioConverterChannelHandler.swift`
- [WebView rendering](https://github.com/memex-lab/memex/blob/main/ios/Runner/WebViewChannelHandler.swift): `ios/Runner/WebViewChannelHandler.swift`

### Background Agents

- [Agent background channel](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/AgentBackgroundChannelHandler.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/AgentBackgroundChannelHandler.kt`
- [Agent status service](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/AgentBackgroundService.kt): `android/app/src/main/kotlin/com/memexlab/memex/AgentBackgroundService.kt`
- [Agent background tasks](https://github.com/memex-lab/memex/blob/main/ios/Runner/AgentBackgroundTaskChannelHandler.swift): `ios/Runner/AgentBackgroundTaskChannelHandler.swift`

### Storage & System

- [Backup file access](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/BackupStorageChannelHandler.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/BackupStorageChannelHandler.kt`
- [Backup import](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/BackupImportChannelHandler.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/BackupImportChannelHandler.kt`
- [iCloud path access](https://github.com/memex-lab/memex/blob/main/ios/Runner/StorageChannelHandler.swift): `ios/Runner/StorageChannelHandler.swift`
- [System actions](https://github.com/memex-lab/memex/blob/main/android/app/src/main/kotlin/com/memexlab/memex/channels/SystemActionsChannelHandler.kt): `android/app/src/main/kotlin/com/memexlab/memex/channels/SystemActionsChannelHandler.kt`

### Other components

- **Memex Flutter app**

## Connections

- Memex Flutter app → Android activity: invokes bridge
- Memex Flutter app → iOS channel registrar: invokes bridge
- Android activity → Android channel registrar: registers channels (evidence: `android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt`)
- Android activity → Agent background channel: handles intents (evidence: `android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt`)
- Android activity → Backup import: handles intents (evidence: `android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt`)
- Android activity → External file import: handles intents (evidence: `android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt`)
- Android activity → Backup file access: routes activity results (evidence: `android/app/src/main/kotlin/com/weshop/memex/MainActivity.kt`)
- Android channel registrar → Agent background channel: registers (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`)
- Android channel registrar → Clipboard preview: registers (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`)
- Android channel registrar → Audio conversion: registers (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`)
- Android channel registrar → Backup file access: registers (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`)
- Android channel registrar → Backup import: registers (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`)
- Android channel registrar → External file import: registers (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`)
- Android channel registrar → System actions: registers (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/ChannelRegistrar.kt`)
- iOS app delegate → iOS channel registrar: registers channels (evidence: `ios/Runner/AppDelegate.swift`)
- iOS app delegate → App actions: routes links (evidence: `ios/Runner/AppDelegate.swift`)
- iOS channel registrar → Clipboard preview: registers (evidence: `ios/Runner/ChannelRegistrar.swift`)
- iOS channel registrar → Audio conversion: registers (evidence: `ios/Runner/ChannelRegistrar.swift`)
- iOS channel registrar → WebView rendering: registers (evidence: `ios/Runner/ChannelRegistrar.swift`)
- iOS channel registrar → Agent background tasks: registers (evidence: `ios/Runner/ChannelRegistrar.swift`)
- iOS channel registrar → iCloud path access: registers (evidence: `ios/Runner/ChannelRegistrar.swift`)
- iOS channel registrar → System actions: registers
- Agent background channel → Agent status service: starts or updates (evidence: `android/app/src/main/kotlin/com/memexlab/memex/channels/AgentBackgroundChannelHandler.kt`)
- Agent background tasks → Memex Flutter app: dispatches tasks (evidence: `ios/Runner/AgentBackgroundTaskChannelHandler.swift`)
