# dedinsaf/offlinechat architecture

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

- Interactive diagram: https://gitdiagram.com/dedinsaf/offlinechat
- Repository: https://github.com/dedinsaf/offlinechat

## Overview

OfflineChat is a cross-platform experimental messenger: users register or log in, find a peer, exchange text and attachments, and see delivery/read state. macOS and iOS use a shared HTTPS API, while each also retains a separate Bluetooth offline mode. The server handles authentication, profiles, messaging and file operations backed by SQLite; email verification is an external delivery step. The graph preserves documented rich-message, media/recording, and map capabilities. Some connections are documented rather than visible in the sampled excerpts, so those are dashed and unverified.

Main entry points: [`macos/desktop_chat/application.py`](https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/application.py) (macOS app), [`ios/OfflineChat/Online/Views/OnlineConversationViews.swift`](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineConversationViews.swift) (iOS chat views), [`chat_server/server.py`](https://github.com/dedinsaf/offlinechat/blob/main/chat_server/server.py) (HTTP API), [`ios/OfflineChat/Online/OnlineChatStore.swift`](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineChatStore.swift) (iOS chat store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Messaging clients"]
  node_mac_app["macOS app<br/>[application.py]"]
  node_ios_views["iOS chat views"]
  node_ios_account["iOS account views"]
  node_ios_root["iOS app root"]
end

subgraph group_online["Online client services"]
  node_mac_worker["macOS sync worker<br/>[worker.py]"]
  node_mac_api["macOS API client<br/>[api.py]"]
  node_mac_content["Message encoding<br/>[message_content.py]"]
  node_mac_store[("macOS local state<br/>[storage.py]")]
  node_ios_store["iOS chat store"]
  node_ios_api["iOS API client<br/>[OnlineAPI.swift]"]
  node_ios_content["iOS message encoding"]
end

subgraph group_server["Chat service"]
  node_server_api["HTTP API<br/>[server.py]"]
  node_server_db[("SQLite data layer<br/>[database.py]")]
  node_email["Verification email<br/>[emailer.py]"]
  node_sqlite[("SQLite database")]
end

subgraph group_media["Media and offline"]
  node_ios_files["iOS file handling<br/>[OnlineFiles.swift]"]
  node_ios_recorder["iOS recording"]
  node_ios_record_composer["iOS recording composer"]
  node_ios_record_view["Recorded message view"]
  node_mac_recording["macOS recording<br/>[recording.py]"]
  node_mac_preview["Capture preview<br/>[capture_preview.py]"]
  node_mac_playback["macOS playback<br/>[playback.py]"]
  node_mac_ble["macOS Bluetooth<br/>[bluetooth.py]"]
  node_ios_ble["iOS Bluetooth"]
  node_ios_offline_views["iOS offline views<br/>[OfflineViews.swift]"]
end

node_user(("User"))
node_email_service["Email provider"]

node_user -->|"uses"| node_mac_app
node_user -->|"uses"| node_ios_views
node_mac_app -->|"queues commands"| node_mac_worker
node_mac_worker -->|"calls"| node_mac_api
node_mac_worker -->|"loads and saves"| node_mac_store
node_mac_app -->|"renders messages"| node_mac_content
node_mac_app -->|"uses"| node_mac_recording
node_mac_app -->|"uses"| node_mac_playback
node_mac_app -->|"starts"| node_mac_ble
node_mac_recording -->|"uses"| node_mac_preview
node_ios_root -.->|"hosts"| node_ios_views
node_ios_root -.->|"hosts"| node_ios_account
node_ios_views -->|"invokes"| node_ios_store
node_ios_account -.->|"authenticates via"| node_ios_store
node_ios_store -->|"calls"| node_ios_api
node_ios_store -.->|"encodes messages"| node_ios_content
node_ios_store -->|"stages files"| node_ios_files
node_ios_views -->|"encodes replies"| node_ios_content
node_ios_record_composer -->|"records with"| node_ios_recorder
node_ios_record_composer -->|"renders"| node_ios_record_view
node_ios_views -->|"presents"| node_ios_record_composer
node_ios_views -.->|"opens offline mode"| node_ios_ble
node_ios_ble -.->|"serves offline chat"| node_ios_offline_views
node_mac_api -.->|"HTTPS requests"| node_server_api
node_ios_api -.->|"HTTPS requests"| node_server_api
node_server_api -->|"routes operations"| node_server_db
node_server_api -->|"sends verification"| node_email
node_server_db -.->|"reads and writes"| node_sqlite
node_email -.->|"delivers via"| node_email_service
node_server_api -.->|"polling and updates"| node_mac_worker
node_server_api -.->|"polling and updates"| node_ios_store

click node_mac_app "https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/application.py"
click node_ios_views "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineConversationViews.swift"
click node_ios_account "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineAccountViews.swift"
click node_ios_root "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineMessengerRoot.swift"
click node_mac_worker "https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/worker.py"
click node_mac_api "https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/api.py"
click node_mac_content "https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/message_content.py"
click node_mac_store "https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/storage.py"
click node_ios_store "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineChatStore.swift"
click node_ios_api "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineAPI.swift"
click node_ios_content "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineMessageContent.swift"
click node_server_api "https://github.com/dedinsaf/offlinechat/blob/main/chat_server/server.py"
click node_server_db "https://github.com/dedinsaf/offlinechat/blob/main/chat_server/database.py"
click node_email "https://github.com/dedinsaf/offlinechat/blob/main/chat_server/emailer.py"
click node_ios_files "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineFiles.swift"
click node_ios_recorder "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineMessageRecorder.swift"
click node_ios_record_composer "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineRecordingComposer.swift"
click node_ios_record_view "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/RecordedMessageView.swift"
click node_mac_recording "https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/recording.py"
click node_mac_preview "https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/capture_preview.py"
click node_mac_playback "https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/playback.py"
click node_mac_ble "https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/bluetooth.py"
click node_ios_ble "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Offline/OfflineBluetooth.swift"
click node_ios_offline_views "https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Offline/OfflineViews.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_app,node_ios_views,node_ios_account,node_ios_root,node_user toneBlue
class node_mac_worker,node_mac_api,node_mac_content,node_mac_store,node_ios_store,node_ios_api,node_ios_content toneAmber
class node_server_api,node_server_db,node_email,node_sqlite toneMint
class node_ios_files,node_ios_recorder,node_ios_record_composer,node_ios_record_view,node_mac_recording,node_mac_preview,node_mac_playback,node_mac_ble,node_ios_ble,node_ios_offline_views toneRose
class node_email_service toneIndigo
```

## Components

### Messaging clients

- [macOS app](https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/application.py): `macos/desktop_chat/application.py`
- [iOS chat views](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineConversationViews.swift): `ios/OfflineChat/Online/Views/OnlineConversationViews.swift`
- [iOS account views](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineAccountViews.swift): `ios/OfflineChat/Online/Views/OnlineAccountViews.swift`
- [iOS app root](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineMessengerRoot.swift): `ios/OfflineChat/Online/Views/OnlineMessengerRoot.swift`

### Online client services

- [macOS sync worker](https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/worker.py): `macos/online_chat/worker.py`
- [macOS API client](https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/api.py): `macos/online_chat/api.py`
- [Message encoding](https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/message_content.py): `macos/online_chat/message_content.py`
- [macOS local state](https://github.com/dedinsaf/offlinechat/blob/main/macos/online_chat/storage.py): `macos/online_chat/storage.py`
- [iOS chat store](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineChatStore.swift): `ios/OfflineChat/Online/OnlineChatStore.swift`
- [iOS API client](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineAPI.swift): `ios/OfflineChat/Online/OnlineAPI.swift`
- [iOS message encoding](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineMessageContent.swift): `ios/OfflineChat/Online/OnlineMessageContent.swift`

### Chat service

- [HTTP API](https://github.com/dedinsaf/offlinechat/blob/main/chat_server/server.py): `chat_server/server.py`
- [SQLite data layer](https://github.com/dedinsaf/offlinechat/blob/main/chat_server/database.py): `chat_server/database.py`
- [Verification email](https://github.com/dedinsaf/offlinechat/blob/main/chat_server/emailer.py): `chat_server/emailer.py`
- **SQLite database**

### Media and offline

- [iOS file handling](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineFiles.swift): `ios/OfflineChat/Online/OnlineFiles.swift`
- [iOS recording](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/OnlineMessageRecorder.swift): `ios/OfflineChat/Online/OnlineMessageRecorder.swift`
- [iOS recording composer](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/OnlineRecordingComposer.swift): `ios/OfflineChat/Online/Views/OnlineRecordingComposer.swift`
- [Recorded message view](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Online/Views/RecordedMessageView.swift): `ios/OfflineChat/Online/Views/RecordedMessageView.swift`
- [macOS recording](https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/recording.py): `macos/desktop_chat/recording.py`
- [Capture preview](https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/capture_preview.py): `macos/desktop_chat/capture_preview.py`
- [macOS playback](https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/playback.py): `macos/desktop_chat/playback.py`
- [macOS Bluetooth](https://github.com/dedinsaf/offlinechat/blob/main/macos/desktop_chat/bluetooth.py): `macos/desktop_chat/bluetooth.py`
- [iOS Bluetooth](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Offline/OfflineBluetooth.swift): `ios/OfflineChat/Offline/OfflineBluetooth.swift`
- [iOS offline views](https://github.com/dedinsaf/offlinechat/blob/main/ios/OfflineChat/Offline/OfflineViews.swift): `ios/OfflineChat/Offline/OfflineViews.swift`

### Other components

- **User**
- **Email provider**

## Connections

- User → macOS app: uses (evidence: `README.md`)
- User → iOS chat views: uses (evidence: `README.md`)
- macOS app → macOS sync worker: queues commands (evidence: `macos/desktop_chat/application.py`)
- macOS sync worker → macOS API client: calls (evidence: `macos/online_chat/worker.py`)
- macOS sync worker → macOS local state: loads and saves (evidence: `macos/online_chat/worker.py`)
- macOS app → Message encoding: renders messages (evidence: `macos/desktop_chat/application.py`)
- macOS app → macOS recording: uses (evidence: `macos/desktop_chat/application.py`)
- macOS app → macOS playback: uses (evidence: `macos/desktop_chat/application.py`)
- macOS app → macOS Bluetooth: starts (evidence: `macos/desktop_chat/application.py`)
- macOS recording → Capture preview: uses (evidence: `macos/desktop_chat/recording.py`)
- iOS app root → iOS chat views: hosts
- iOS app root → iOS account views: hosts
- iOS chat views → iOS chat store: invokes (evidence: `ios/OfflineChat/Online/Views/OnlineConversationViews.swift`)
- iOS account views → iOS chat store: authenticates via
- iOS chat store → iOS API client: calls (evidence: `ios/OfflineChat/Online/OnlineChatStore.swift`)
- iOS chat store → iOS message encoding: encodes messages (evidence: `ios/OfflineChat/Online/OnlineChatStore.swift`)
- iOS chat store → iOS file handling: stages files (evidence: `ios/OfflineChat/Online/OnlineChatStore.swift`)
- iOS chat views → iOS message encoding: encodes replies (evidence: `ios/OfflineChat/Online/Views/OnlineConversationViews.swift`)
- iOS recording composer → iOS recording: records with (evidence: `ios/OfflineChat/Online/Views/OnlineRecordingComposer.swift`)
- iOS recording composer → Recorded message view: renders (evidence: `ios/OfflineChat/Online/Views/OnlineRecordingComposer.swift`)
- iOS chat views → iOS recording composer: presents (evidence: `ios/OfflineChat/Online/Views/OnlineConversationViews.swift`)
- iOS chat views → iOS Bluetooth: opens offline mode
- iOS Bluetooth → iOS offline views: serves offline chat
- macOS API client → HTTP API: HTTPS requests (evidence: `README.md`)
- iOS API client → HTTP API: HTTPS requests (evidence: `README.md`)
- HTTP API → SQLite data layer: routes operations (evidence: `chat_server/server.py`)
- HTTP API → Verification email: sends verification (evidence: `chat_server/server.py`)
- SQLite data layer → SQLite database: reads and writes
- Verification email → Email provider: delivers via (evidence: `README.md`)
- HTTP API → macOS sync worker: polling and updates (evidence: `README.md`)
- HTTP API → iOS chat store: polling and updates (evidence: `README.md`)
