/XSpends-Android

Android app for XSpends

Primary LanguageKotlin

Design Architecture

  1. MVVM Pattern:

    • ViewModel: Design your ViewModel to hold and manage UI-related data in a lifecycle-conscious way. It should be responsible for making calls to the Repository layer and handling any business logic.
    • Repository Layer: This layer will interact with your web service API. It acts as a mediator between the ViewModel and the data source (your backend).
  2. LiveData or StateFlow:

    • Decide whether to use LiveData or Kotlin's StateFlow to handle data observability and UI state management. StateFlow is a newer API that is fully integrated with Kotlin's coroutines.
  3. Dependency Injection:

    • Consider using a dependency injection framework like Hilt or Koin for better scalability and testability.
  4. Navigation:

    • Plan how navigation will be handled in your app. With Jetpack Compose, you can use the NavController for managing composable screens.
  5. Data Models:

    • Define data models corresponding to your web service's data structure for users, transactions, fund sources, etc.
  6. Handling State:

    • Determine how to handle and store the UI state effectively, especially for complex UIs or data-driven screens.

User Authentication

  1. Login UI:

    • Design a composable function for the login screen, ensuring it aligns with your app’s aesthetic.
    • Include input fields for username/email and password, and a button to submit the login request.
  2. Integration with Backend:

    • Use Retrofit or another HTTP client to make requests to your web service for authentication.
    • Handle the reception of JWT tokens and securely store them, possibly using encrypted shared preferences.
  3. Secure Storage:

    • Store the received JWT tokens securely. You can use Android’s EncryptedSharedPreferences or a secure library like Hawk.
  4. Error Handling:

    • Implement error handling for scenarios like invalid credentials or network issues.
  5. Navigation upon Login:

    • Upon successful login, navigate the user to the main screen of the app using the NavController.
  6. Signup and Password Recovery:

    • Optionally, if your API supports it, include signup and password recovery options.
  7. ViewModel for Authentication:

    • Implement a ViewModel for handling authentication logic and maintaining authentication state.