How kashirapp/kashir works
Project Type and Purpose
• Kashir is a full-stack mobile application (React Native) functioning as an ecash (Cashu) wallet.
• It combines a TypeScript/JavaScript UI layer, business logic services, native modules (Android/iOS), and Rust-based SDKs (nostr-sdk-ffi, cdk-ffi) exposed via FFI.
File-Structure Analysis
• Top-level:
• deps/nostr-sdk-ffi and deps/cdk-ffi: Rust crates compiled to native libraries for FFI.
• scripts/: build and binding-fix scripts.
• Yarn PnP config files (.yarn/, .yarnrc.yml, turbo.json).
• tsconfig*.json, babel.config.js, eslint.config.mjs for TS/JS tooling.
• example/: The React Native application:
• example/src/: TSX components (UI), hooks, services (business logic), utils, types.
• example/android/ and example/ios/: Native code wrappers, Gradle and Xcode project files, native modules (IntentLauncher).
• Metro, Jest, and React Native config files.
• Config: ubrn.nostr.config.yaml, zapstore.yaml, ubrn.cdk.config.yaml define the Cashu and Nostr environments.
README Insights
• Briefly states core technologies: React Native, rust-nostr SDK, and Cashu Development Kit.
Main Components
a. Frontend (React Native JS/TS)
– UI Components (screens, modals, navigation)
– Hooks and State Management
– Business-logic Services (NostrClient, AmberService, WalletManager, etc.)
b. Native Modules
– Android (IntentLauncherModule, etc.)
– iOS (bridged Swift modules)
c. FFI Layer
– Rust Native Libraries from deps/nostr-sdk-ffi and deps/cdk-ffi
– React Native NativeModules bridging to Rust
d. Persistence
– SecureStorageService (on-device secure key/value)
– CacheService (local cache)
e. External Services
– Nostr Relays (via NostrClient over WebSocket)
– Cashu Mint Servers (LNURL, DVMService, MintRecommendationService)
– Location APIs (via LocationService)
f. Build & Tooling
– Yarn PnP, Turbo repo orchestration
– Metro bundler, Babel transpilation
– Gradle (Android), Xcode (iOS), scripts/build-android.sh
Relationships and Data Flows
• User taps UI → React Native JS
• JS invokes Services → may call NativeModules (IntentLauncher) or FFI methods (Rust SDKs)
• Rust modules handle cryptographic operations, networking (to Nostr relays, Cashu servers)
• Responses flow back through FFI → JS Services → UI updates
• Persist transaction data via SecureStorageService/CacheService
Architectural Patterns and Principles
• Layered architecture:
1. Presentation (React Native components)
2. Application (Services, Hooks)
3. Infrastructure (FFI + NativeModules, Secure Storage)
4. External (Relays, Mint Servers)
• Single source of truth for wallet state managed via Services and Hooks.
• Clear separation of concerns: UI vs. business logic vs. cryptography/networking.
Essential Elements to Capture
• FFI bridge between JS and Rust crates.
• NativeModules for Android/iOS.
• Core Services classes and their external dependencies (Nostr relays, LNURL).
• Secure and Cache storage components.
• Build pipeline (Yarn PnP, Metro, Gradle, Xcode) as supporting infrastructure.