Overview
NetPOS is built on modern Android architecture principles using MVVM (Model-View-ViewModel) pattern with clean architecture separation. The application leverages Dagger Hilt for dependency injection, RxJava2 for reactive programming, and Room for local persistence.Core Architecture Patterns
MVVM Pattern
The app follows the Model-View-ViewModel architecture:- Models: Data entities in
com.woleapp.netpos.model - Views: Activities and Fragments in
com.woleapp.netpos.ui - ViewModels: Business logic in
com.woleapp.netpos.viewmodels
Application Components
1. Application Class
TheNetPosApp class initializes core services at startup:
app/NetPosApp.kt
Key Initialization Steps
Key Initialization Steps
- Timber: Logging framework initialization
- Firebase: Push notifications and analytics
- SharedPreferences: Using Prefs library for simple key-value storage
- NetPos SDK: Card reader and terminal configuration
- RxJava Error Handler: Global error handling
2. Dependency Injection
NetPOS uses Dagger Hilt for dependency injection, configured indi/Module.kt:38:
3. Network Layer
Multiple API services configured with different base URLs:API Services (7 Services)
API Services (7 Services)
StormApiService
StormApiService
Main backend API for authentication, transactions, and merchant data
- Base URL: Configured via
BuildConfig.STRING_DEFAULT_BASE_URL - Endpoints:
/api/auth,/api/token,/api/agents/{stormId}
ZenithPayByTransferService
ZenithPayByTransferService
Zenith Bank pay-by-transfer integration
- Base URL:
BuildConfig.STRING_ZENITH_BASE_URL - Endpoints:
/api/getUserAccount/{terminalId},/api/queryTransactions
QrPaymentService
QrPaymentService
Contactless QR payment processing
- Endpoint:
/contactlessQr
CheckoutService
CheckoutService
Payment checkout operations
SubmitComplaintsService
SubmitComplaintsService
Customer complaints and feedback
ProvidusMerchantsAccountService
ProvidusMerchantsAccountService
Providus Bank merchant account integration
FcmbMerchantsAccountService
FcmbMerchantsAccountService
FCMB Bank merchant account integration
4. Reactive Programming
NetPOS extensively uses RxJava2 for asynchronous operations:viewmodels/AuthViewModel.kt:79
All RxJava subscriptions are disposed in ViewModel’s
onCleared() to prevent memory leaks.Data Flow Architecture
Example: Transaction Flow
Key Components
Activities
AuthenticationActivity
Entry point and user authentication
- Launched on app start with
LAUNCHERintent - Handles login and password reset
MainActivity
Main dashboard and transaction hub
- Fragment container for all transaction flows
- Navigation between features
Services & Receivers
Background Services
Background Services
- MyFirebaseMessagingService: Push notifications from Firebase Cloud Messaging
- BatteryReceiver: Monitors battery status and power connection
- BootReceiver: Handles device boot and shutdown events
Configuration Management
NetPOS supports multiple product flavors (white-label configurations):build.gradle:104
Threading Model
State Management
ViewModel state is managed using LiveData and MutableLiveData:viewmodels/TransactionsViewModel.kt:32
Single-use events are wrapped in
Event<T> class to prevent re-emission on configuration changes.Build Variants
The application supports two build types:- Debug: Development with verbose logging, signing config enabled
- Release: Production with minification and ProGuard
External Dependencies
Core Libraries
Core Libraries
- Kotlin: 1.8+ with coroutines support
- AndroidX: AppCompat, Core-KTX, ConstraintLayout
- Material Components: Material Design UI components
Architecture Components
Architecture Components
- Lifecycle: ViewModel, LiveData (v2.6.1)
- Room: 2.5+ for local database
- Paging: 2.1.2 for paginated transaction lists
Dependency Injection
Dependency Injection
- Dagger Hilt: 2.48.1
Network & Serialization
Network & Serialization
- Retrofit: 2.9.0 with RxJava2 adapter
- OkHttp: 5.0.0-alpha.2 with logging interceptor
- Gson: JSON serialization
Reactive
Reactive
- RxJava2: 2.2.21
- RxAndroid: 2.1.1
- RxKotlin: 2.4.0
Next Steps
Database Schema
Explore Room database entities and relationships
ViewModels
Detailed ViewModel implementations
Services
API services and network layer
Security
Security implementation and encryption