Mercado Search App is a sample project that presents modern, 2022 approach to Android application development using Kotlin, Jetpack Compose and latest tech-stack.
The goal of the project is to demonstrate best practices, provide a set of guidelines, and present modern Android application architecture that is modular, scalable, and maintainable. This application may look simple, but it has all of these small details that will set the rock-solid foundation of the larger app suitable for bigger teams and long application lifecycle management.
This app allows you to find and see information about products exposed on the marketplace of Mercado Libre. You can see information about prices, shipping, condition and also you can take a look at the product on the official store.
Current version: 1.0.0
Minimum OS version: Android 8 - Oreo (API level 27)
Maximum OS version: Android 13.1 (API level 33)
Percentage of support devices (based on OS version): ~83%
Support for landscape: Yes
Dark mode: No
Offline support: No
Permissions required: ACCESS_NETWORK_STATE
, INTERNET
Following concepts of clean architecture, there 3 packages that represents the data, domain and UI. There's also one package for dependency injection.
-
In the data layer, network operations resides inside a
RemoteProductsDataSource
and it is accessible through and implementation ofProductsRepository
. Data models are converted to entities usingmappers
, this way complex deserialization logic doesn't not require changes on the business logic models. -
In the domain layer, business logic operations lives in
usecases
and real life objects are represented asentities
. There's also the definition of theProductsRepository
, this, in order to follow the dependency inversion principle. -
In the UI layer,
ProductsViewModel
handles the events from the UI components and interacts with the domain layer throughusecases
, the data is presented to the interface usingLiveData
observables and composeStates
. observables All the screens are built usingcomposables
instead of the view system (XML).
This apps was built using this libraries and frameworks:
Jetpack Compose, Accompanist , Compose Material , LiveData , Splash Screen
Timber , OkHttp Logging Interceptor
MockK , Robolectric , JUnit , kotlinx.coroutines
Due to time reasons, testinng efforts were focused on the bussines logic and some part of the data layer. Mappers and networking logic are under unit tests. In the domain layer, some methods and logic of the ProductsViewModel are covered with unit tests, here's the coverage report:
-
Based on the API documentation provided, searchs are limit up to 1000 results because at the endpoint for searching products (
search?q
) requires an authentication token. -
There are two entities that wraps the information about a product,
DProductDataModel
andDProductDetailsDataModel
, the first one is used for showing the basic information of a product in the search results list. The second one provides the information of the details screen, this is done with the purpose of presenting the the most recent data. -
Filters are not available and the sorting criteria of the products is the same as the received from the API.
If you are experiencing having troubles when trying to see Previews of composables, upgrade Android Studio to the most recent version. The AS version used for building this project was 2021.1.1 Path 3 with Gradle Plugin 7.1.3 and Gradle Version 7.2.
Sometimes, unit tests that depends on the test coroutines returns failed results when they're in fact successful (false positives), if this happens, please re-run the test again and try to rebuild the project.
All contributions are welcome! Please feel free to post questions, recommendations, ideas, bugs by create new issue following the template or if you want create directly new pull request.
Juan Camilo Sandoval Devia
Copyright 2022 Juan Camilo Sandoval
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.