How mhmmdvg/cashier-app works
Project Type & Purpose
• This is an Android mobile application (written in Kotlin) implementing a cashier system: user authentication, product browsing, order placement, and checkout.
High-Level Architecture
• The project follows a layered “Clean Architecture” + MVVM pattern, with these layers:
• UI Layer (Jetpack Compose screens & components)
• Presentation Layer (ViewModels)
• Domain Layer (plain model classes)
• Data Layer (remote APIs, repositories, token/local storage)
• DI Layer (provides and wires dependencies)
• External Services (external REST API)
Main Components
• UI Layer
• Composable Components: AsyncImage, CardItem, Search, etc.
• Screens: LoginScreen, HomeScreen, OrderScreen, OrderSuccess, SettingScreen
• Presentation Layer
• LoginViewModel, ProductViewModel
• Domain Layer
• Models: Auth, Product, NavigationItem, Select, etc.
• Data Layer
• Remote API Interfaces: AuthApi, ProductApi (Retrofit)
• Repositories: AuthRepository, ProductRepository
• Local Helpers: TokenManager (stores JWT, e.g., in SharedPreferences)
• Networking: OkHttpClient with AuthInterceptor
• Resource Wrapper: Resource<T> (to standardize success/error/loading)
• DI Layer
• AppModule (provides Retrofit, OkHttpClient, repositories, viewmodels)
• External Services
• REST endpoints for auth and product operations
Relationships & Data Flow
1. User interacts with a Composable UI component.
2. UI dispatches events to ViewModel (e.g., LoginViewModel.login(credentials)).
3. ViewModel calls its Repository (AuthRepository.login()).
4. Repository uses Retrofit’s AuthApi to perform HTTP request.
5. OkHttpClient (injected via AppModule) invokes AuthInterceptor, attaching JWT from TokenManager.
6. Retrofit returns API response wrapped in Resource<T>.
7. Repository returns Resource<T> to ViewModel.
8. ViewModel updates its StateFlow/LiveData.
9. UI observes state changes and recomposes.
Architectural Patterns & Technologies
• MVVM: clear separation UI <-> ViewModel <-> Model
• Clean Layers: UI, Presentation, Domain, Data, External
• Dependency Injection: Dagger/Hilt (AppModule)
• Networking: Retrofit + OkHttp + AuthInterceptor
• Coroutine-based async calls
• Jetpack Compose for declarative UI