$ show paulgessinger/swift-paperless
Swift Paperless is a native iOS client for Paperless-ngx, a self-hosted document management system. The app provides a rich SwiftUI interface for browsing, filtering, viewing, editing, and sharing documents stored on a remote Paperless-ngx server. It supports offline-first caching via GRDB (SQLite), multi-server connections, OIDC login with PKCE and TOTP, mTLS client certificates, deep links, and a share extension for importing documents from other apps. The architecture is modular, with separate Swift packages for networking (ApiRepository, wire types), data models (FilterState, SyncPlan), persistence (GRDB migrations, records, observation), and shared UI components. The app uses a repository pattern with a caching decorator (CachingRepository) that provides offline reads, delta sync with watermarks, and write-through cache consistency. A sync engine orchestrates per-server synchronization phases (elements, reconcile, fill) with progress reporting and throttle support. Key features include a customizable filter bar with saved views, custom field filtering with logical operators, a PDF viewer with text search, document scanning via VisionKit, barcode ASN extraction, and a tip jar for donations. The codebase is well-tested with unit tests for networking, persistence, data models, and concurrency patterns. CI/CD pipelines build and deploy to TestFlight, and localization is managed via Crowdin across 8 languages.
The LLM identified 3 files worth highlighting for reuse:
A keyed execution coalescing utility that deduplicates concurrent async operations for the same key. It ensures that multiple callers requesting the same resource (e.g., a network download) share a single in-flight task, and each caller receives the result via a continuation. It also supports progress forwarding via a per-caller progress handler. This is a reusable concurrency pattern applicable to any Swift project needing to coalesce async work.
A multicast event broadcaster built on Swift's AsyncStream. It allows multiple subscribers to receive events from a single source without coupling the sender to the receivers. The broadcaster supports cancellation via a Subscription token that manages the lifecycle of the underlying task. This pattern is useful for decoupling components in any SwiftUI or async Swift application.
An actor-based pagination cursor that manages fetching pages from a paginated API endpoint. It handles URL scheme fixing (http->https), rewrites certain errors (e.g., ResourceForbidden), and provides a clean async sequence of pages. The cursor is generic over the page type and can be reused with any paginated API that follows a similar pattern. It demonstrates non-obvious actor usage for thread-safe pagination state.