Skip to content

C0deWithAj/CurrencyConverterAndroid-Mvvm

Repository files navigation

Currencny Converter MVVM + Clean Architecture

✨ A Currency Converter with MVVM + Clean Architecture using Fixer API ✨ The application is offline first. On Free API. It fetches currency data for first time and then gives users ability to pull new data on demand.

Usecase:

  • Usecase-1 : Downloads Currency rates from "latest" endpoints and caches in local Database. Displays Date of last update. In case of No internet, user can continue to do currency conversions
  • Usecase-2: User can see last X days (currently 3) history of his selections, from "Time-series" endpoint of API in following forms:
  • In the Form of list (Requires Internet)
  • In the form of Graph (Requires Internet)
  • Usecase-3: User can see conversion of his current selection into 10 other popular currencies
  • Unit Test: So Far unit tests are written for the first Usecase only. I will continue adding unit tests.

Architecture

Screenshot 2023-02-04 at 7 20 31 PM

Uses concepts of the notorious Uncle Bob's architecture called Clean Architecture.

  • Better separation of concerns. Each module has a clear API., Feature related classes life in different modules and can't be referenced without explicit module dependency.
  • Every layer is using their own model and a 'LayerObjectMapper' class is used to convert an object to its relative pattern
  • Usecases represents a UI use cases, communication between Repo and UI is done through it and maps repo object back to UI objects.

Tech stack - Library:

  • Kotlin
  • Coroutines - A coroutine is a concurrency design pattern that you can use on Android to simplify code that executes asynchronously
  • Flow - Flow is used to pass (send) a stream of data that can be computed asynchronously
  • Dagger-Hilt - for dependency injection.
  • LiveData - For reactive style programming (from VM to UI).
  • ViewModel - Stores UI-related data that isn't destroyed on UI changes.
  • Room - Used to create room db and store the data.
  • Navigation - Used to navigate between fragments
  • Data Binding - Used to bind UI components in your XML layouts.
  • Retrofit - Used for REST api communication.
  • OkHttp - HTTP client that's efficient by default: HTTP/2 support allows all requests to the same host to share a socket
  • Gson - Used to convert Java Objects into their JSON representation and vice versa.
  • Ktlint - ktlint aims to capture the official Kotlin coding conventions and Android Kotlin Style Guide. Testing
  • Google-truth - Google Truth
  • Mockito - Mockito
  • JUnit JUnit

Future Improvements:

  • Finish writing test cases
  • Add work Manager to download data on specific intervals

Screenshots:

WhatsApp Image 2023-02-10 at 9 11 50 PM WhatsApp Image 2023-02-10 at 9 11 45 PM WhatsApp Image 2023-02-10 at 9 11 44 PM (1)