The stratergy followed for Modularizing the application is heavily inspired from nowinandroid
and ivywallet and also keeping loose coupling in mind
The app consists of the following modules.
Name | Responsibilities | Key classes and dependencies |
app
|
Top level module that combines the whole application's modules.Defines all the composable screens and sets up the navigation | App, MainActivity mainly depends on navigation module navigation
|
navigation
|
Responsible for handling navigation events through out the whole application . Also defines Destinations |
contains Navigator and NavHost navcontroller
|
Home
|
Contains Home Screen and uses core:Network to fetch images from network |
Mainly depends oncore:Network core:Persistence
|
Favourites
|
Contains Favourites Screen and is responsible for fetching images from database |
Depends on core:Persistence
|
Core:Domain
|
Contains all the top level abstract declarations used through out the application Also includes data models |
contains FlowAction SharedFlowAction FlowViewMoel
|
Core:Network
|
Handles logic for fetching data from the network using ktor for Http request and exposing that as Action for other modules to use |
ImageDto NetworkFlowAction
|
Core:Persistence
|
Handles logic related to persistence and exposes the functionality as Actions for other modules to use |
coreDb ImageDao ImageEntity
|
The architecture is primarily MVVM + Functional Reactive programming paradigm
The UI paradigm is an endless cycle of states and events: State -> Event -> State' -> Event' -> State'' -> ….
- A UIState made of primitives depicts the state of the screen at a particular instant
- A UIEvent depicting all possible events originating from the screens
- FlowViewModel producing a Flow of UI states and receiving a Flow events.
- @Composable Screens that transforms UiState to Ui and emitting UIEvents
This way we ensure our Ui is reactive and always has the latest UiState
Actions refers to Functions that have side-effects . For example, sending HTTP requests or querying a database. These are alternate to repositories in typical MVVM approach or use cases in Clean Architecture.
Actions basically are closely related to the concept of "signals" or "events" in FRP (Functional Reactive Programming). In FRP, signals are used to represent data streams that can be transformed and combined in various ways to produce new signals.
Similarly, Actions in MVVM+FRP are functions that represent a stream of data that can be transformed and combined to produce new streams of data. Actions are typically used to represent domain logic such as network requests or database queries, and can be composed together to build more complex functionality.
Few Actions defined so far in the application ImagesFlow SaveImageAction