Skip to content

An example of data retrieving from a REST API with dabatase cache, Kotlin Flow, Jetpack Compose

Notifications You must be signed in to change notification settings

lcacheux/dummy-api

Repository files navigation

Dummy API Example

This project is an example of a modular application to retrieve data from an external API (https://dummyapi.io).

It makes use of the following libraries:

  • Jetpack Compose for the UI
  • OkHttp / Retrofit for the REST requests
  • Koin for dependency injection
  • Room for database
  • Coil for image retrieval
  • Mockito Kotlin for some parts of unit testing

To build, you must add an application id for Dummy API in your local.properties file:

api_key=1234567890abcdef12345678

See https://dummyapi.io to generate your own key.

Architecture

The DatasourceRepository interface is used to provide data to the application and have multiple implementations:

  • datasource-server to retrieve data from a remote REST service
  • datasource-room to retrieve and store data into a local Room database, by implementing MutableDatasourceRepository
  • datasource-cached is a proxy implementation that retrieve data from another DatasourceRepository implementation and use a MutableDatasourceRepository implementation as cache

Two other implementations are used for testing purposes:

  • datasource-test generate its own data and also provide some helper methods
  • datasource-memory is an implementation of MutableDatasourceRepository which just store data in memory

About

An example of data retrieving from a REST API with dabatase cache, Kotlin Flow, Jetpack Compose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages