How muun/apollo works
Project type and purpose
• This is a full-stack Android application: a non-custodial 2-of-2 multisig Bitcoin wallet.
• It follows “Clean Architecture”: separate layers for Data, Domain, Presentation, plus shared “common” code and a native Go-based “libwallet” library.
File structure
• Top-level Gradle modules:
• android/apollo – Data + Domain layers
• android/apolloui – Presentation (UI: Activities, Fragments, ViewModels)
• common – Pure Java shared models and API mappers
• libwallet – Native Go library for low-level wallet logic (compiled via gomobile)
• Each Android module follows:
android/apollo/src/main/java/io/muun/apollo/data → data backends (network, DB, file system, OS)
android/apollo/src/main/java/io/muun/apollo/domain → business logic, use-cases
android/apolloui/src/main/java/io/muun/apollo/presentation → UI layer
• Config files: Gradle scripts, Dockerfiles for containerized libwallet build, SQLDelight schema & migrations, ProGuard rules, CI workflows.
Extract architecture insights from README
• App enforces strict dependency direction:
Presentation → Domain → Data
• Data layer deals with network (Houston API over Retrofit/RxJava), local persistence (SQLDelight), async tasks, secure storage, OS services (Firebase, Google Drive).
• Domain layer orchestrates use-cases (Challenge keys, payments, swaps, session management).
• Presentation layer renders UI and only calls Domain use-cases (no direct Data references).
• The common module is reused by both Data and Domain layers (models, API JSON mappings).
1. Presentation Module (android/apolloui)
2. Domain Module (android/apollo/domain)
3. Data Module (android/apollo/data)
4. Common Module (common)
5. Native libwallet Module (libwallet via gomobile bridge)
6. External Services:
– Houston backend API
– Firebase Cloud Messaging
– Google Drive for Emergency Kit
7. Local Resources:
– SQLDelight database
– Android Keystore / Secure Storage
– File System (cache, disk)
– Presentation → Domain: invokes use-case actions (AsyncAction classes)
– Domain → Data: orchestrates data requests (network calls, DB reads/writes, OS services)
– Domain ↔ Common: shares models & JSON mappers
– Data → External Services: HTTP calls to Houston API, FCM registration, DriveUploader
– Data → SQLDelight: read/write wallet tables
– Data → Android OS: secure storage via KeyStoreProvider, background tasks via WorkManager/GCM
– Domain → libwallet: JNI bridge for transaction crafting & key operations
– Presentation ←→ OS: UI events, system services
c. Architectural patterns & principles:
– Clean Architecture: strict layer boundaries, Dependence Rule
– Dependency Injection (Dagger 2): wiring modules (DataComponent, DomainComponent, ApplicationComponent)
– Reactive streams (RxJava) for async flows
– SQLDelight for type-safe database
– JSII (gomobile bridge) for native Go library
d. Key technologies & libraries:
– Kotlin + Java, Android SDK
– Dagger 2 (DI)
– Retrofit + OkHttp + RxJava (network)
– SQLDelight (database)
– WorkManager / Firebase Manager (background jobs)
– Google Drive API (Emergency Kit export)
– Firebase Cloud Messaging / GCM
– Go Mobile (libwallet, JNI bridging)