Skip to content

UnreachableCode/Commentify

Repository files navigation

Commentify

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.

Screenshots

Comments List Comment Detail
List Comments Screen Comment Detail Screen

Architecture

The project follows MVVM + Repository Pattern with clear separation of concerns:

  • UI Layer — Jetpack Compose screens (ListCommentsScreen, CommentDetailScreen)
  • ViewModel LayerCommentsViewmodel managing UI state via StateFlow and a sealed CommentsUiState class (Idle, Loading, Success, Error)
  • Data LayerCommentRepository as the single source of data access
  • Service Layer — Retrofit interface (JsonPlaceHolderApi) calling the JSONPlaceholder API
  • DI — Hilt modules providing singletons across the app

Unit Tests

Unit testing using JUnit and Mockk. At the time of writing this Readme, all of our tests pass:

Test passing

CommentsViewmodel Tests

A test for each of the ViewModel states: Idle, Loading, Success and Error.

I use StandardTestDispatcher and advanceUntilIdle for coroutine testing.

CommentRepository Tests

Includes tests for the retrieval of a list of comments and a specific comment from the repository.

Future Improvements

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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages