How gemwalletcom/gem-ios works
Project Overview and Main Components
• Application Frontend (UI)
– Built using SwiftUI and organized into numerous feature modules (e.g., Onboarding, WalletTab, Swap, Staking, PriceAlerts, NFT, QRScanner, etc.).
– Each module often follows an MVVM pattern: Scenes (views), ViewModels, and supporting types.
• Navigation and App Coordination
– Look at the Gem/Core folder and Gem/Root navigation and view models. These are the central coordinators that manage the app’s navigation and scene switching.
• Service Layer
– The “Services” directory provides backend support for business logic such as asset management, balance updates, notifications, blockchain data retrieval, node status, transaction processing, and WalletConnect.
• Data and Domain Libraries
– Packages such as Blockchain, Keystore, Primitives, and WalletCore supply critical infrastructure (e.g., secure cryptographic operations, multi-chain support, and key management).
– The “Store” package handles persistence (database, migrations, models for balances, transactions, etc.).
• UI Components & Styling
– Packages/Components and Packages/Style present reusable UI elements like list views, buttons, and custom controls, which ensure consistency across the application.
• External Integrations and Third-Party Communication
– GemAPI handles network requests toward external endpoints.
– SwiftHTTPClient abstracts HTTP communication.
– Integration with a Rust-based “Core” library provides secure cryptographic operations.
Layered Architecture and Relationships
• Presentation Layer:
• Business Logic / Service Layer:
– Represent services (e.g., AssetsService, BalanceService, PriceService, ChainService, etc.) as a separate block that the view models call into.
• Data & Domain Layer:
• External and Infrastructure Layer:
– External dependencies such as GemAPI and SwiftHTTPClient should be shown, along with the communication with external blockchain networks and dApps (used with WalletConnect).
– Include the “Core” Rust library (found under the core submodule and referenced in Gem’s README) as a secure cryptographic engine.
• Persistence:
– The “Store” package is responsible for local database interactions. It should be depicted as a storage block that feeds data into the Service Layer.
Architectural Patterns and Design Principles
• MVVM Pattern is prominently used within each feature module:
• Modularization using Swift Packages:
• Dependency Inversion & Abstraction:
– Service interfaces (protocols) and use of dependency injection (seen under Gem/Core/AppResolver) to allow for testability and replaceable implementations.
• Separation of Concerns:
– Clearly show the boundary between UI (presentation), business logic (services), and low-level domain operations (data/crypto packages).