cloudshooterhuman / BluePets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Objectives

  • Clean Architecture: presentation, domain (agostic), data layers, and dependency injection (Hilt). ref

drawing

Dependencies between Layers

drawing

Diagram of Clean Architecture

  • Unit Testing: with JUnit and MockK.

  • Data Flow Management: Coroutine, Flow, and Paging3.

  • View Management: Jetpack Compose (Dark/Night).

  • Navigation Management: Jetpack Navigation.

Implementation Breakdown

The Domain Layer

The domain is the application's core containing the business logic and rules. The domain needs to be independent of other modules and libraries related to the UI, Android, etc. All classes (except models) and public methods should be tested.

The Data Layer

The data layer allows retrieving and persisting application data through Repositories* and Data Sources, which can be local with a database or remote with an API.

*In practice, the "repository pattern" should be used to manage different data sources (DB, API, Cache), otherwise it is implemented to support "offline mode".

The Presentation Layer

The UI's role is to display the application's data on the screen and serve as the main point of user interaction. The used pattern is MVVM (Model - View - ViewModel) / UDF.

drawing

Application Rendering

      Post screen       Error screen

Areas for Improvement:

Testing

Architecture

  • Support "offline first" mode.
    • Add Room persistence library.
    • Implement RemoteMediator.
  • Have a module for each layer. ✅

UI

  • Add a "retry" button on the data loading error screen. ✅
  • Add pull-to-refresh. ✅
  • Scroll management. ✅
  • Replace error message text with a snack bar.
  • Add/handle empty screen case.
  • Add navigation in the AppBar. ✅
  • Add an "up" button to scroll to the top of the list. ✅
  • Filter the list of posts based on a tag. ✅

Refactoring / Improvement

  • Remove the "material" dependency (as it is only used for "pull-to-refresh") and use Material3. ✅
  • Improve error handling (via Retrofit CallAdapter). ✅
    • Use a sealed class to distinguish between an exception and an error. ✅
  • Add a buildSrc module for version management (Android/release). ✅
  • Add Type-Safe Navigation for compose navigation.
  • Add documentation.

CI/CD

  • Configure CI via GitHub Actions:
    • Code formatting with Spotless/Ktlint. ✅
    • Unit test. ✅
    • Generate the release.

[Bugs/Regression]

  • Threading error: (Skipped 78 frames!)
  • Scroll position is reset to the top when navigating back from "Post" screen to "Home" screen (hint: after adding the search by tag feature).
  • manager stateful and stateless.

About


Languages

Language:Kotlin 100.0%