# paulgessinger/swift-paperless architecture

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

- Interactive diagram: https://gitdiagram.com/paulgessinger/swift-paperless
- Repository: https://github.com/paulgessinger/swift-paperless

## Overview

Swift Paperless is a native iOS client for a self-hosted Paperless-ngx instance. The main workflow is to connect and authenticate to a server, browse or filter documents, inspect and edit document metadata, and rely on local caching and synchronization for offline access. The repository also includes document import and sharing, task monitoring, and settings for connections and offline storage. The graph emphasizes these product stages and the shared data/network layers; some UI and integration relationships are based on README descriptions or source-index references rather than inspected implementation.

Main entry points: [`AppShared/Sources/AppShared/Document/DocumentStore.swift`](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Document/DocumentStore.swift) (Document store), [`AppShared/Sources/AppShared/Networking/ConnectionManager.swift`](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/ConnectionManager.swift) (Connection manager), [`Networking/Sources/Networking/Repository.swift`](https://github.com/paulgessinger/swift-paperless/blob/main/Networking/Sources/Networking/Repository.swift) (Repository API), [`AppShared/Sources/AppShared/Networking/ServerSession.swift`](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/ServerSession.swift) (Server sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_app["iOS app shell"]
  node_login["Login and connections<br/>[LoginView.swift]"]
  node_tasks["Task activity"]
  node_settings["Settings and offline"]
end

subgraph group_documents["Document workflows"]
  node_list["Document browsing<br/>[DocumentList.swift]"]
  node_filters["Search and filters<br/>[FilterBar.swift]"]
  node_detail["Document details"]
  node_metadata["Metadata editing"]
  node_import["Document import"]
  node_share["Share extension"]
  node_attachments["Attachment handling"]
end

subgraph group_shared["Shared app logic"]
  node_documentstore["Document store"]
  node_errors["Error presentation"]
  node_domain["Document and filter models<br/>[FilterState.swift]"]
end

subgraph group_network["Networking and sync"]
  node_connections["Connection manager"]
  node_sessions["Server sessions"]
  node_sync["Sync scheduler<br/>[SyncEngine.swift]"]
  node_repository["Repository API<br/>[Repository.swift]"]
end

subgraph group_storage["Local data"]
  node_database[("SQLite cache<br/>[Database.swift]")]
  node_content[("Document content store<br/>[ContentStore.swift]")]
end

node_user(("User"))
node_paperless{{"Paperless-ngx server"}}

node_user -->|"uses"| node_app
node_app -.->|"presents"| node_login
node_login -.->|"configures"| node_connections
node_user -.->|"browses"| node_list
node_list -.->|"filters"| node_filters
node_list -.->|"opens"| node_detail
node_detail -.->|"edits"| node_metadata
node_metadata -.->|"saves via"| node_documentstore
node_detail -.->|"reads"| node_documentstore
node_user -.->|"imports"| node_import
node_share -->|"receives"| node_attachments
node_share -.->|"shares through"| node_documentstore
node_user -.->|"configures"| node_settings
node_settings -->|"manages"| node_connections
node_settings -->|"measures usage"| node_documentstore
node_connections -->|"observes"| node_database
node_connections -->|"selects"| node_sessions
node_sync -->|"schedules from"| node_connections
node_sync -->|"runs sync"| node_sessions
node_documentstore -->|"prepares repository"| node_sessions
node_documentstore -->|"calls"| node_repository
node_documentstore -->|"uses"| node_content
node_sessions -.->|"owns"| node_repository
node_repository -.->|"requests data"| node_paperless
node_repository -.->|"caches data"| node_database
node_documentstore -->|"queries with"| node_domain
node_tasks -.->|"shows activity"| node_documentstore
node_documentstore -.->|"reports failures"| node_errors

click node_app "https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/swift_paperlessApp.swift"
click node_login "https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Login/LoginView.swift"
click node_list "https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Document/DocumentList.swift"
click node_filters "https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Filter/FilterBar.swift"
click node_detail "https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Document/Detail/DocumentDetailView.swift"
click node_metadata "https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Document/Detail/V4/DocumentDetailViewV4.swift"
click node_import "https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/Views/Import/DocumentImportModel.swift"
click node_share "https://github.com/paulgessinger/swift-paperless/blob/main/ShareExtension/ShareViewController.swift"
click node_attachments "https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/ViewModel/AttachmentManager.swift"
click node_tasks "https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/Views/TaskActivityView.swift"
click node_settings "https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/Views/Settings/OfflineSyncView.swift"
click node_documentstore "https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Document/DocumentStore.swift"
click node_errors "https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Error/ErrorController.swift"
click node_connections "https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/ConnectionManager.swift"
click node_sessions "https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/ServerSession.swift"
click node_sync "https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/SyncEngine.swift"
click node_repository "https://github.com/paulgessinger/swift-paperless/blob/main/Networking/Sources/Networking/Repository.swift"
click node_database "https://github.com/paulgessinger/swift-paperless/blob/main/Persistence/Sources/Persistence/Database.swift"
click node_content "https://github.com/paulgessinger/swift-paperless/blob/main/Common/Sources/Common/ContentStore.swift"
click node_domain "https://github.com/paulgessinger/swift-paperless/blob/main/DataModel/Sources/DataModel/FilterState.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_app,node_login,node_tasks,node_settings,node_user toneBlue
class node_list,node_filters,node_detail,node_metadata,node_import,node_share,node_attachments toneAmber
class node_documentstore,node_errors,node_domain,node_paperless toneMint
class node_connections,node_sessions,node_sync,node_repository toneRose
class node_database,node_content toneIndigo
```

## Components

### App experience

- [iOS app shell](https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/swift_paperlessApp.swift): `swift-paperless/swift_paperlessApp.swift`
- [Login and connections](https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Login/LoginView.swift): `swift-paperless/Views/Login/LoginView.swift`
- [Task activity](https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/Views/TaskActivityView.swift): `AppViews/Sources/AppViews/Views/TaskActivityView.swift`
- [Settings and offline](https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/Views/Settings/OfflineSyncView.swift): `AppViews/Sources/AppViews/Views/Settings/OfflineSyncView.swift`

### Document workflows

- [Document browsing](https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Document/DocumentList.swift): `swift-paperless/Views/Document/DocumentList.swift`
- [Search and filters](https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Filter/FilterBar.swift): `swift-paperless/Views/Filter/FilterBar.swift`
- [Document details](https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Document/Detail/DocumentDetailView.swift): `swift-paperless/Views/Document/Detail/DocumentDetailView.swift`
- [Metadata editing](https://github.com/paulgessinger/swift-paperless/blob/main/swift-paperless/Views/Document/Detail/V4/DocumentDetailViewV4.swift): `swift-paperless/Views/Document/Detail/V4/DocumentDetailViewV4.swift`
- [Document import](https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/Views/Import/DocumentImportModel.swift): `AppViews/Sources/AppViews/Views/Import/DocumentImportModel.swift`
- [Share extension](https://github.com/paulgessinger/swift-paperless/blob/main/ShareExtension/ShareViewController.swift): `ShareExtension/ShareViewController.swift`
- [Attachment handling](https://github.com/paulgessinger/swift-paperless/blob/main/AppViews/Sources/AppViews/ViewModel/AttachmentManager.swift): `AppViews/Sources/AppViews/ViewModel/AttachmentManager.swift`

### Shared app logic

- [Document store](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Document/DocumentStore.swift): `AppShared/Sources/AppShared/Document/DocumentStore.swift`
- [Error presentation](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Error/ErrorController.swift): `AppShared/Sources/AppShared/Error/ErrorController.swift`
- [Document and filter models](https://github.com/paulgessinger/swift-paperless/blob/main/DataModel/Sources/DataModel/FilterState.swift): `DataModel/Sources/DataModel/FilterState.swift`

### Networking and sync

- [Connection manager](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/ConnectionManager.swift): `AppShared/Sources/AppShared/Networking/ConnectionManager.swift`
- [Server sessions](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/ServerSession.swift): `AppShared/Sources/AppShared/Networking/ServerSession.swift`
- [Sync scheduler](https://github.com/paulgessinger/swift-paperless/blob/main/AppShared/Sources/AppShared/Networking/SyncEngine.swift): `AppShared/Sources/AppShared/Networking/SyncEngine.swift`
- [Repository API](https://github.com/paulgessinger/swift-paperless/blob/main/Networking/Sources/Networking/Repository.swift): `Networking/Sources/Networking/Repository.swift`

### Local data

- [SQLite cache](https://github.com/paulgessinger/swift-paperless/blob/main/Persistence/Sources/Persistence/Database.swift): `Persistence/Sources/Persistence/Database.swift`
- [Document content store](https://github.com/paulgessinger/swift-paperless/blob/main/Common/Sources/Common/ContentStore.swift): `Common/Sources/Common/ContentStore.swift`

### Other components

- **User**
- **Paperless-ngx server**

## Connections

- User → iOS app shell: uses (evidence: `README.md`)
- iOS app shell → Login and connections: presents
- Login and connections → Connection manager: configures
- User → Document browsing: browses
- Document browsing → Search and filters: filters
- Document browsing → Document details: opens
- Document details → Metadata editing: edits
- Metadata editing → Document store: saves via
- Document details → Document store: reads
- User → Document import: imports
- Share extension → Attachment handling: receives (evidence: `ShareExtension/ShareViewController.swift`)
- Share extension → Document store: shares through
- User → Settings and offline: configures
- Settings and offline → Connection manager: manages
- Settings and offline → Document store: measures usage
- Connection manager → SQLite cache: observes (evidence: `AppShared/Sources/AppShared/Networking/ConnectionManager.swift`)
- Connection manager → Server sessions: selects
- Sync scheduler → Connection manager: schedules from (evidence: `AppShared/Sources/AppShared/Networking/SyncEngine.swift`)
- Sync scheduler → Server sessions: runs sync (evidence: `AppShared/Sources/AppShared/Networking/SyncEngine.swift`)
- Document store → Server sessions: prepares repository (evidence: `AppShared/Sources/AppShared/Document/DocumentStore.swift`)
- Document store → Repository API: calls (evidence: `AppShared/Sources/AppShared/Document/DocumentStore.swift`)
- Document store → Document content store: uses (evidence: `AppShared/Sources/AppShared/Document/DocumentStore.swift`)
- Server sessions → Repository API: owns
- Repository API → Paperless-ngx server: requests data
- Repository API → SQLite cache: caches data
- Document store → Document and filter models: queries with (evidence: `AppShared/Sources/AppShared/Document/DocumentStore.swift`)
- Task activity → Document store: shows activity
- Document store → Error presentation: reports failures
