How blockstream/green_android works
Overall Structure and Major Layers
• Client Layer: Represent the mobile client applications. For Android, you have several UI components (modules like “compose”, “green”, “ui-common”) developed with Jetpack Compose and traditional Android components. The iOS client can be represented as a parallel entity (in the iosApp folder).
• Core Business Logic: This comes from the “common” module (containing commonMain, androidMain, iosMain, jvmMain, etc.) and the gdk library (in the “gdk” folder). These layers implement cross-platform wallet functionality, core Bitcoin logic, and data models.
• Platform/Integration Services: Include modules for integration with Google Mobile Services (GMS), push notifications (Firebase in “gms” and “base-gms”), and even non-GMS variants (“no-gms”). These modules manage external integrations, notifications, and platform-specific services.
• Hardware Wallet Integration: The “hardware” module handles interactions with external hardware wallets (e.g. Ledger, Trezor). It provides the communications layer to interact with hardware devices.
• Dependency Injection and Shared Utilities: Note the use of DI frameworks (via Koin in several submodules across common, androidMain, iosMain, etc.) and shared utilities such as logging, extensions, and data converters.
Depicting Relationships and Data Flow
• User Interface (UI): Elements in the UI modules (compose, ui-common, green) interact with ViewModels (found in common models, such as “MainViewModel”, “LoginViewModel”, etc.) following an MVVM pattern.
• Business/Wallet Logic: The ViewModels call into the shared business logic provided by the common module and gdk library. This layer handles transactions, network state, and Bitcoin-specific data.
• Data Persistence: Database directories in the “common” & “green” modules (with SQL migrations, adapters, and repositories) indicate local storage for wallet data and events.
• Hardware Communication: The hardware module sits in parallel, providing an interface for sending commands to physical devices. This component interfaces ‘downstream’ to actual hardware protocols and external libraries.
Important Architectural Patterns and Concepts
• MVVM – There is extensive use of ViewModels, particularly in modules like “common/models” and “compose/screens”. Indicate that UI components bind to view models which then delegate to core business logic.
• External Dependencies – Integration with external services (Google/Firebase, push notifications, possibly even external API calls within gdk) should be represented as “external services” that interface with the wallet application.
Elements
• Clear labels for each module/component.
• Optional: A “container” for external entities like "External Bitcoin Network" or "Push Notification Service" to show interactions.
• Integration points such as database layers (local wallet and events databases) and API integration points (Firebase, analytics).