An Android app built with Jetpack Compose that fetches and displays comments from the JSONPlaceholder API. Users browse a list of comments and tap into a detail view for each one.
Networking powered by Retrofit and Moshi. Dependency Injection using Hilt.
| Comments List | Comment Detail |
|---|---|
![]() |
![]() |
The project follows MVVM + Repository Pattern with clear separation of concerns:
- UI Layer — Jetpack Compose screens (
ListCommentsScreen,CommentDetailScreen) - ViewModel Layer —
CommentsViewmodelmanaging UI state viaStateFlowand a sealedCommentsUiStateclass (Idle, Loading, Success, Error) - Data Layer —
CommentRepositoryas the single source of data access - Service Layer — Retrofit interface (
JsonPlaceHolderApi) calling the JSONPlaceholder API - DI — Hilt modules providing singletons across the app
Unit testing using JUnit and Mockk. At the time of writing this Readme, all of our tests pass:
A test for each of the ViewModel states: Idle, Loading, Success and Error.
I use StandardTestDispatcher and advanceUntilIdle for coroutine testing.
Includes tests for the retrieval of a list of comments and a specific comment from the repository.
Given more time, I'd make these improvements
- Improved comment loading. Currently the list is loaded all at once. Loading a few comments at a time as the user scrolls would offer a smoother user experience. I would also like to load each batch in parallel. I know how to do this in iOS but haven't figured it out for Android yet!
- Navigation in the ViewModels. This provides a cleaner separation of concerns. Instead of having navigation in the composables and MainActivity, I would keep it with the business logic and be more able to easily pass parameters from there. Not trivial to do out of the box with Android.
- I'd integrate Room into the repository to cache the comments locally instead of retrieving them every time the list screen is opened. Like a good social media app should!


