Git Product home page Git Product logo

instagram-clone-clean-architecture's Introduction

Instagram Clone - Clean Architecture

Instagram-Clone-Clean-Architecture is my portfolio project that implemented with clean architecture approach. The projects that I referenced while developing can be see in Reference section.

The objective of this project is to learn how to handle large project when developing Android application. Particularly with clean-architecture approach, making it easy to expand, build and test.

While it takes longer to setup a project, after setting-up, the workflow is less-error-prone. Making the application much reliable and confident to develop.

Installation

Android Studio

Git Bash Terminal

git clone https://github.com/kyleliao321/instagram-clone-clean-architecture.git

Build

Android Studio

  • Build -> Make Project
  • Run - Run 'app'

Demo

  • Login process

login GIF

  • Remember login process

remember login GIF

  • Search user and follow/unfollow process

search GIF

  • Check post and like process

check post GID

  • Add post process

add post GIF

What I learned

While it is not the first android project I developed, I still learn a lot and strengthen some of the best-practice concept with it.

Clean Architecture

  • Modularization with Features using dynamic feature.
  • Presentation/Domain/Data dependency rule.
  • Setup Base Library Module to organize common utility class/function.
  • Separation of Concern with Model-View-ViewModel.
  • Repository Pattern with Local/Cache/Remote data source.
  • Error Handling, especially for network fail.
  • Dependency Injection with Kodein-DI.

Build System

  • Using Gradle-Kotlin-DSL.
  • Using buildSrc to organize library/plugin dependency and android configuration.
  • Configure build variant through build types and flavors.

Unit Test

Android Features

Kotlin

Networking

Issues

Reference projects/articles provides solid foundation for me to build this project, but there are some outdated dependency issues or special scenario that required other approaches. Here are some of the issues that I think is worth mentioning :

1. Gradle-6.0/buildSrc compatiblity

Since Gradle6.0, buildSrc is no longer visible from gradle's setting file anymore:

As a result, developers have to make sure plugin-version and modules are synchronized between gradle setting and buildSrc. (More on the this issue)

2. Navigation between dynamic features

When navigating between features, safe-args navigation is not possible:

One approach mention in this article is to use common-android module to store destination ids, but there are some drawbacks (See more on the article). My approach is to let navigation's action have the id that is the same as its destination. This way, I can use the following code to capture the exception and re-navigate in traditional-way:

try {
  navController.navigate(navDir)
} catch (e: Exception) {
  if (e is java.lang.IllegalArgumentException) {
      navController.navigate(navDir.actionId, navDir.arguments)
  } else {
      throw e
  }
}

3. Activity/Application being referenced

Potential memory leak when reference Activity/Application:

In some case, the class have to use activity/application context. For example, LocalDataSource have to get SharedPreference from application context. And this lead to other class has reference on Activity/Application, a classic-way to trigger memory leak.

To prevent from memory leak, I use WeakReference to get Activity/Application context. So when the Activity/Application is destroyed, GC can reclaim the memory.

TODO

  • Replace MockRemoteDataSource with actual API that get/upload data to/from server.
  • Detect memory leak.
  • Encrypt user data in SharedPreference.
  • Fix Lint error.

Reference

instagram-clone-clean-architecture's People

Contributors

kyleliao321 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.