Trendyol Android App Architecture: — Part 1

Murat Can Bur
Trendyol Tech
Published in
2 min readOct 12, 2018

At Trendyol, we try to follow best practices and recommended architecture to build a sustainable and error prone Android app. This article defines how we implemented architecture using Architecture Components.

Architecture Components: Improve Your App’s Design

Library driven development

LiveData

LiveData is an observable data holder. We use LiveData to see our UI update with data changes. Instead of updating the UI every time when the data changes, our view state classes update UI every time when the data changes.

https://developer.android.com/topic/libraries/architecture/livedata

Room

Room is the data storage persistence solution for us as any developer that decided to use AAC. We use it to create a cache of our app’s data.

https://developer.android.com/topic/libraries/architecture/room

Dagger2

Dagger is a dependency injection framework that is light weight and generates code at compile time so suitable for android.

https://github.com/google/dagger

RxJava2

We try to adopt the reactive programming paradigm for the development of our Android application using RxJava.

https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0

Project package structure

common

The common package contains any classes that may be used for common features across the application.

data

The data package contains networking classes, preferences management, database classes, entity models, network request and response models.

remote

Remote packages contain all classes and interfaces that handle all communications with remote sources.

local

Local packages contain all classes and interfaces that handle all communication with the local database that is used to cache data.

domain

The domain package contains our business objects and contains the Use Case classes used to interact with these from other packages.

ui

The UI package contains UI components of the application. UI package has child packages that are organized as feature-by-layer.

Overview of Trendyol app architecture

reference : https://developer.android.com/jetpack/docs/guide
  • We try to follow the rules from Architecture guidelines recommended by Google.
  • We generally try to keep our Activity and Fragment classes only responsible for UI related code like click listeners, etc
  • ViewModel provides us data required by the UI classes like Activity, Fragment, Dialog etc
  • Our Repository layer provides data to ViewModel classes. (single source of truth)
  • Repository layer decides if the data is to be fetched from a REST API using Retrofit or from local database using Room

We have shared a repository about Android guidelines on Trendyol Android app and want to contribute it.

--

--

Murat Can Bur
Trendyol Tech

Blogger , Public Speaker, Mobile Engineering Team Lead @Trendyol