{"id":13774639,"url":"https://github.com/odaridavid/Clean-MVVM-ArchComponents","last_synced_at":"2025-05-11T06:33:25.582Z","repository":{"id":37572234,"uuid":"227998628","full_name":"odaridavid/Clean-MVVM-ArchComponents","owner":"odaridavid","description":"👽 Built with MVVM pattern, Koin , Coroutines + Flows ,Architecture Components, Data Binding , Firebase , Unit/UI Tests ,Motion Layout","archived":false,"fork":false,"pushed_at":"2021-06-15T14:20:18.000Z","size":17690,"stargazers_count":690,"open_issues_count":23,"forks_count":112,"subscribers_count":23,"default_branch":"develop","last_synced_at":"2024-10-12T13:48:29.926Z","etag":null,"topics":["android","android-architecture","architecture-components","clean","clean-architecture","coroutines","espresso","firebase","junit","koin","kotlin","kotlin-flow","motionlayout","mvvm","mvvm-architecture","retrofit2","robolectric","tdd"],"latest_commit_sha":null,"homepage":"https://play.google.com/store/apps/details?id=com.k0d4black.theforce","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odaridavid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-14T09:38:52.000Z","updated_at":"2024-10-06T21:36:59.000Z","dependencies_parsed_at":"2022-08-08T21:00:19.398Z","dependency_job_id":null,"html_url":"https://github.com/odaridavid/Clean-MVVM-ArchComponents","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FClean-MVVM-ArchComponents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FClean-MVVM-ArchComponents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FClean-MVVM-ArchComponents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FClean-MVVM-ArchComponents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odaridavid","download_url":"https://codeload.github.com/odaridavid/Clean-MVVM-ArchComponents/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253528415,"owners_count":21922623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-architecture","architecture-components","clean","clean-architecture","coroutines","espresso","firebase","junit","koin","kotlin","kotlin-flow","motionlayout","mvvm","mvvm-architecture","retrofit2","robolectric","tdd"],"created_at":"2024-08-03T17:01:28.888Z","updated_at":"2025-05-11T06:33:24.080Z","avatar_url":"https://github.com/odaridavid.png","language":"Kotlin","funding_links":[],"categories":[":art: Pattern"],"sub_categories":["MVVM"],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"art/app_icon.png\" alt=\"home\" width=\"100\"/\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg  src=\"https://travis-ci.com/odaridavid/Clean-MVVM-ArchComponents.svg?branch=develop\"\u003e\u0026nbsp;\n\u003ca href=\"https://codecov.io/gh/odaridavid/Clean-MVVM-ArchComponents\"\u003e\n  \u003cimg src=\"https://codecov.io/gh/odaridavid/Clean-MVVM-ArchComponents/branch/develop/graph/badge.svg\" /\u003e\n\u003c/a\u003e\u0026nbsp;\n\u003ca href=\"https://www.codacy.com/manual/odaridavid/Clean-MVVM-ArchComponents?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=odaridavid/Clean-MVVM-ArchComponents\u0026amp;utm_campaign=Badge_Grade\"\u003e\u003cimg src=\"https://app.codacy.com/project/badge/Grade/e9536c1df39b482b863f152654e14fa5\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# The-Force\n\nAn Android app consuming [a Star Wars API](https://swapi.dev/) to display Movie Characters\nit has been built with clean architecture principles, Repository Pattern and MVVM\npattern as well as Architecture Components.\n\nMin Api Level : 21 [Supports Over 87% Devices ](https://developer.android.com/about/dashboards)\n\nBuild System : [Gradle](https://gradle.org/)\n\n## Table of Contents\n\n- [Prerequisite](#prerequisite)\n- [Architecture](#architecture)\n- [Testing](#testing)\n- [Libraries](#libraries)\n- [Contributors](#contributors)\n- [Related Posts](#related-posts)\n- [Demo](#demo)\n\n## Prerequisite\n\nTo run the release build successfully in travis you will need to replace the default values in \n```keystore.properties.sample```file with your own in a ```keystore.properties``` file.\n\nNext archive your keystore file and the properties file with the following command\n```shell script\n tar cvf secrets.tar keystore.properties theforce.jks\n```\n\nNext encrypt the archive and add config to travis with the following command\n```shell script\ntravis encrypt-file --pro secrets.tar --add\n```\n\nVerify that in your travis.yml in the ```before_install``` it looks something like\n```yaml\nbefore_install:\n  - openssl aes-256-cbc -K $encrypted_5880cf525281_key -iv $encrypted_5880cf525281_iv -in secrets.tar.enc -out secrets.tar -d\n  - tar xvf secrets.tar\n```\n\nMake sure to add only the `*.enc` file to git,leave out the keystore.properties and `*.jks` file.\nAdd the following to the root `.gitignore` just to be sure\n```gitignore\n*.jks\n*.tar\nkeystore.properties\n```\n\nIf you encounter any error check [this site](https://docs.travis-ci.com/user/encrypting-files/) out.\n\nTo setup the Travis CLI tools see [this](https://github.com/travis-ci/travis.rb#installation) \n\n## Architecture\n\nNB: Work in Progress - [Feature Modularisation](https://github.com/odaridavid/Clean-MVVM-ArchComponents/tree/feature-modularisation) 🚧 \n\nThe Application is split into a three layer architecture:\n- Presentation\n- Domain\n- Data\n\n![Architecture Flow Diagram](art/arch_flow.png)\n\nThis provides better abstractions between framework implementations \nand the underlying business logic.It requires a number of classes to get \nthings running but the pros outweigh the cons in terms of building an app \nthat should scale.\n\nThe 3 layered architectural approach is majorly guided by clean architecture which provides\na clear separation of concerns with its Abstraction Principle.\n\n#### Presentation\n\n```app``` contains the UI files and handles binding of DI components from other modules.\nBinding of data is facilitated by jetpacks data binding by serving data from the viewmodel\nto the UI.The data being received is part of a viewstate class that has properties contained in the\nrelevant state.\n\n#### Domain\n\nThe ```domain``` module contains domain model classes which represent the\ndata we will be handling across presentation and data layer.\n\nUse cases are also provided in the domain layer and orchestrate the flow \nof data from the data layer onto the presentation layer and a split into\nmodular pieces serving one particular purpose.\n\nThe UseCases use a ```BaseUseCase``` interface that defines the parameters its taking in and \noutput this helps in creating fakes using in testing.\n\n#### Data\n\n- ```data-remote```\n\nHandles data interacting with the network and is later serverd up to the presentation layer through \ndomain object\n\n- ```data-local```\n\nHandles persistence of object with Room ORM from.This module is responsible for handling all local related\nlogic and serves up data to and from the presentation layer through domain objects.\n\nWith this separation we can easily swap in new or replace the database being used without causeing\nmajor ripples across the codebase.\n\n## Testing\n\nEach module has its own tests except for the ```domain``` module which is catered for since its\npart of the behavior under test.\n\nAll server responses in the tests are served by mock web server by appending relative urls to\nthe localhost and the connected port as the base url.\n\nIn the ``data-remote`` module the responses are mocked using the mockwebserver and verified that they\nare what we expect.\n\nIn the ```data-local``` module an in  memory database is being used to run the tests,this makes it a \nlittle faster compared to an actual db.\n\nIn the ```app``` module there are unit tests for the viewmodels and util classes \nand connected tests for the UI Screens.\n\nThe test instrumentation app uses modules that have been swaped with fakes for\nthe network module so as to run requests on localhost with mockwebserver,this removes flakiness \ncompared to relying on actual  data from the real server aspects such as internet connection or\nnetwork service might bring up issues and an in memory database for local data that also allows \nmain thread queries since tests should also be fast and we are just asserting stuff works.\n\nView models testing on live data were guided by this [article](https://proandroiddev.com/how-to-easily-test-a-viewmodel-with-livedata-and-coroutines-230c74416047)\n \n## Libraries\n\nLibraries used in the whole application are:\n\n- [Jetpack](https://developer.android.com/jetpack)🚀\n  - [Viewmodel](https://developer.android.com/topic/libraries/architecture/viewmodel) - Manage UI related data in a lifecycle conscious way \n  and act as a channel between use cases and ui\n  - [Data Binding](https://developer.android.com/topic/libraries/data-binding) - support library that allows binding of UI components in  layouts to data sources,binds character details and search results to UI\n  - [Room](https://developer.android.com/training/data-storage/room) - Provides abstraction layer over SQLite\n- [Retrofit](https://square.github.io/retrofit/) - type safe http client \nand supports coroutines out of the box.  \n- [Moshi](https://github.com/square/moshi) - JSON Parser,used to parse \nrequests on the data layer for Entities and understands Kotlin non-nullable \nand default parameters\n- [okhttp-logging-interceptor](https://github.com/square/okhttp/blob/master/okhttp-logging-interceptor/README.md) - logs HTTP request and response data.\n- [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) - Library Support for coroutines,provides `runBlocking` coroutine builder used in tests\n- [Truth](https://truth.dev/) - Assertions Library,provides readability as far as assertions are concerned\n- [MockWebServer](https://github.com/square/okhttp/tree/master/mockwebserver) - web server for testing HTTP clients ,verify requests and responses on the star wars api with the retrofit client.\n- [Leak Canary](https://square.github.io/leakcanary/) - Leak Detection Library\n- [Material Design](https://material.io/develop/android/docs/getting-started/) - build awesome beautiful UIs.🔥🔥\n- [Firebase](https://firebase.google.com/) - Backend As A Service for faster mobile development.\n  - [Crashylitics](https://firebase.google.com/docs/crashlytics) - Provide Realtime crash reports from users end.\n- [Koin](https://github.com/InsertKoinIO/koin) - A pragmatic lightweight dependency injection framework for Kotlin\n- [Robolectric](http://robolectric.org/) - Unit test on android framework.\n- [Espresso](https://developer.android.com/training/testing/espresso) - Test framework to write UI Tests\n- [recyclerview-animators](https://github.com/wasabeef/recyclerview-animators) - Recycler View Animations\n- [AboutLibraries](https://github.com/mikepenz/AboutLibraries) -provide info on used open source libraries.\n- [Stetho](https://github.com/facebook/stetho) - debug bridge\n- [Kiel](https://github.com/ibrahimyilmaz/kiel) - Kiel RecyclerView Adapter Builders\n\n## Contributors\n\n- Thanks to [Zafer Celaloglu](https://github.com/zfrc) for the Dagger to Koin Refactor and additional test cases.\n\nFeel free to contribute in any way to the project from typos in docs to code review are all welcome.\n\n## Demo\n\nThe codebase in most cases will be ahead of whats on the store.\n\n|\u003cimg src=\"art/sh1.png\" width=200/\u003e|\u003cimg src=\"art/sh2.png\" width=200/\u003e|\u003cimg src=\"art/sh3.png\" width=200/\u003e|\u003cimg src=\"art/sh4.png\" width=200/\u003e|\n|:----:|:----:|:----:|:----:|\n\n|\u003cimg src=\"art/app.gif\" width=200/\u003e|\n|:----:|\n\n\u003ca href='https://play.google.com/store/apps/details?id=com.k0d4black.theforce\u0026pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'\u003e\u003cimg alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png' width='170'/\u003e\u003c/a\u003e\n\nGoogle Play and the Google Play logo are trademarks of Google LLC.\n\n## Copyright Notice\n\nStar Wars and all associated names are copyright Lucasfilm ltd.\n\n## Related Posts\n\n[Handling Dynamic Urls](https://davidodari.hashnode.dev/retrofit-handling-dynamic-urls-ck9zygtw700x0ans1tm5spma4)\n\n## License\n\n ```\n   Copyright 2019 David Odari\n   \n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodaridavid%2FClean-MVVM-ArchComponents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodaridavid%2FClean-MVVM-ArchComponents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodaridavid%2FClean-MVVM-ArchComponents/lists"}