• Stars
    star
    331
  • Rank 127,323 (Top 3 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fork of our clean architecture boilerplate, this time using Koin

Android Clean Architecture Components Boilerplate

Note: This is a fork of our original Clean Architecture Boilerplate, except in this repo we have switched out the MVP approach found in the presentation layer to now use ViewModels from the Android Architecture Components Library and Koin. The caching layer now also uses Room.

Welcome πŸ‘‹ We hope this boilerplate is not only helpful to other developers, but also that it helps to educate in the area of architecture. We created this boilerplate for a few reasons:

  1. To experiment with modularisation
  2. To experiment with the Android Architecture Components
  3. To share some approaches to clean architecture, especially as we've been talking a lot about it
  4. To use as a starting point in future projects where clean architecture feels appropriate

It is written 100% in Kotlin with both UI and Unit tests - we will also be keeping this up-to-date as libraries change!

Disclaimer

Note: The use of clean architecture may seem over-complicated for this sample project. However, this allows us to keep the amount of boilerplate code to a minimum and also demonstrate the approach in a simpler form.

Clean Architecture will not be appropriate for every project, so it is down to you to decide whether or not it fits your needs πŸ™‚

Languages, libraries and tools used

Requirements

Architecture

The architecture of the project follows the principles of Clean Architecture. Here's how the sample project implements it:

architecture

The sample app when run will show you a simple list of all the Bufferoos (Buffer team members!).

Drawing

Let's look at each of the architecture layers and the role each one plays :)

Presentation

The presentation Module contains everything that is related to the user facing parts of our application. This layer should use MVVM to handle the orchestration of data from the data source to the UI - this will be made up of an Android Architecture Components View Model class implementation which will use the Use Case classes to retrieve data. The View Model class will then create an instance of an immutable UI state class which will then be passed to the View which has subscribed to the data stream.

This View will then use the model to render it's state. The UI state should be the only state of the View, this way there is only one source of truth for how the display of content is constructed. The UI state should be a sealed class and make use of a Resource State instance (LOADING, SUCCESS, ERROR) so that UI states can easily be composed.

Data

The Data Module is our access point to external data layers and is used to fetch data from multiple sources (the cache and network), it also contains the Use Case classes (domain logic) which are uses to carry out operations on the data (such as creating an update, closing a conversation). The data layer contains the Data Models which are used in this module and modules higher than it (such as the UI module). The Remote and Cache module models will map to this model, past here the model will never change so it makes no sense to perform any more mappings.

The Use Case classes will use a repository interface which defines the set of operations which can be performed within the data layer. This interface is the implemented by a Data Repository class which will use a Data Store Factory to retrieve an instance of a Data Store Interface to retrieve data from. This Data Store Interface will be implemented by an external layer and allows us to abstract the source of data from our data layer - allowing us to create a more flexible and decoupled data source

Remote

The Remote module handles all communications with remote sources, in our case it makes simple API calls using a Retrofit interface. This service will be used within a Remote Data store implementation class to retrieve instance of the Remote Model representations - this data store class implements the data store interface from the data layer. The data store class uses a model mapper that will map these Remote models to the model representation found within the Data module.

Cache

The Cache module handles all communication with the local database which is used to cache data. For this our Database should use the Room architecture component library for the data base, whos data is accessed using DAO classes from said library.

The cache layer will have it's on Cache Model representations which will be retrieved using the DAOs through the Cache Data Store implementation class, which implements the data store interface from the data layer. This data store class will use a model mapper that will map these Cache models to the model representation found within the Data module.

Conclusion

We will be happy to answer any questions that you may have on this approach, and if you want to lend a hand with the boilerplate then please feel free to submit an issue and/or pull request πŸ™‚

Again to note, use Clean Architecture where appropriate. This is example can appear as over-architectured for what it is - but it is an example only. The same can be said for individual models for each layer, this decision is down to you. In this example, the data used for every model is exactly the same, so some may argue that "hey, maybe we don't need to map between the presentation and user-interface layer". Or maybe you don't want to modularise your data layer into data/remote/cache and want to just have it in a single 'data' module. That decision is down to you and the project that you are working on πŸ™ŒπŸ»

Thanks

A special thanks to the authors involved with these two repositories, they were a great resource during our learning!

More Repositories

1

android-clean-architecture-boilerplate

An android boilerplate project using clean architecture
Kotlin
3,651
star
2

clean-architecture-components-boilerplate

A fork of our clean architecture boilerplate, this time using the Android Architecture Components
Kotlin
1,277
star
3

BufferTextInputLayout

A simple customised version of the TextInputLayout from the Android Design Support Library ⌨️
Java
983
star
4

android-clean-architecture-mvi-boilerplate

A fork of our clean architecture boilerplate using the Model-View-Intent pattern
Kotlin
978
star
5

AdaptableBottomNavigation

A simpler way for implementing the Bottom Navigation View on Android
Java
830
star
6

android-guidelines

Project Guidelines for the Android Buffer App
Shell
750
star
7

buffer-ios-image-viewer

The BFRImageViewer is a turnkey solution to present images within your iOS app πŸŽ‰!
Objective-C
399
star
8

MultiActionSwipeHelper

An Android RecyclerView Swipe Helper for handling multiple actions per direction
Java
296
star
9

CounterView

A simple Android counter view for showing edittext character counts
Kotlin
176
star
10

Thumby

An Android video thumbnail picker
Kotlin
173
star
11

buffer-components

Buffer's shared collection of React UI components πŸ€œπŸ€›
JavaScript
139
star
12

ReactivePlayBilling

An RxJava wrapper for the Google Play Billing Library
Kotlin
117
star
13

buzzer

A little buzzer app for running your own quizzes or game shows!
JavaScript
94
star
14

buffer-chrome

Buffer for Chrome lets you easily add great articles, pictures and videos to your Buffer and we automagically share them for you through the day!
JavaScript
66
star
15

SocialLinkify

An Android library for linking @ mentions & Hashtags to their corresponding social network
Kotlin
65
star
16

BFRReorderTableView

The BFRTableReorder is an out of the box solution to add long press reordering to your ASDK apps
Objective-C
57
star
17

ui

✨ Buffer's UI Components library and Style Guide✨
TypeScript
51
star
18

old-diversity-dashboard

R
49
star
19

kiner

Python AWS Kinesis Producer with error handling and thread support.
Python
45
star
20

README

Welcome, friend! Here's an overview to our engineering team's documentation
Shell
43
star
21

sqs-worker-go

Go
38
star
22

code-of-conduct

Buffer's Employee Code of Conduct
36
star
23

diggdigg

DiggDigg is the floating all-in-one share bar for your WordPress website.
PHP
33
star
24

buffer-ios-sdk

Buffer iOS SDK
Objective-C
30
star
25

javascript-style-guide

Buffer's JavaScript style guide
24
star
26

Biscotti

A collection of Custom Actions and Matchers for Espresso Testing
Kotlin
23
star
27

buffer-blog-v2

Buffer Blog design starting July 2014
PHP
21
star
28

bootstrap-datepicker

Our own fork of eternicode's bootstrap datepicker that includes time selection.
21
star
29

buffer-extension-shared

Shared code between Buffer extensions
JavaScript
21
star
30

buffer-style

The Buffer Style Guide
JavaScript
20
star
31

EKG

Kubernetes Health And Liveness Check
JavaScript
20
star
32

android-components

Shared components for Buffer Android apps
Kotlin
19
star
33

carden

Service to save MongoDB Change Streams (oplog) records into Big Query
Python
19
star
34

buffer-php-style-guide

Buffer's PHP style guide
19
star
35

pylooker

A Python interface to Looker API
Python
16
star
36

lookerpy

A Python API client for Looker
Python
15
star
37

CustomViewIndicator

An Android ViewPager indicator that allows you to provide custom views for display
Kotlin
15
star
38

sharejs

Trigger the Buffer Share popup from any DOM element
JavaScript
14
star
39

Reactive-Pusher

An RxJava wrapper for the Pusher Java Library [Work in progress]
Kotlin
13
star
40

facebook-api-wrapper

Buffer's Facebook PHP API wrapper
PHP
13
star
41

churnado

Churn forecasting tool
R
13
star
42

buffer-redux-hover

Keep React component hover state in redux
JavaScript
12
star
43

omniauth-buffer2

Omniauth strategy to allow Ruby clients to easily use the Buffer API.
Ruby
12
star
44

k8s-jenkins-pipeline

Jenkins Pipeline Library for k8s Deployment Using Helm Chart
Groovy
11
star
45

stacklogging

Python logging integration with Google Cloud Stackdriver API.
Python
11
star
46

buffer-extensions

Main repo for extension code. Note: this has nested submodules
JavaScript
11
star
47

buffer-firefox

Buffer for Firefox
JavaScript
10
star
48

github-notify-client

Get system notifications when you get PRs assigned to you!
JavaScript
10
star
49

buffer-web-components

Buffer Dashboard Specific Components
JavaScript
10
star
50

buffer-sharekit

A Buffer plugin for your ShareKit sharing menu for iOS
Objective-C
9
star
51

rsdf

Some functions to help Pandas DataFrames communicate with Redshift
Python
9
star
52

twilio-to-slack

πŸ“²πŸ’¬ A simple app to forward SMS messages from a Twilio number to a Slack channel
JavaScript
9
star
53

restream

Replay Firehose Streams in Kinesis Streams!
Python
9
star
54

buffer-ruby-deprecated

Official Ruby API wrapper for Buffer
Ruby
9
star
55

dbt-bigquery-auditlog

Get an overview of all cost and performance data for your BigQuery project
9
star
56

BFRGIFRefreshControl

Objective-C
8
star
57

BufferSwiftKit

Swift based SDK to access the Buffer API. The main goal is to provide a simple and easy interface to use Buffer in your iOS apps.
Swift
8
star
58

micro-rpc

Async RPC microservices made easy
JavaScript
8
star
59

buffer-safari

Buffer for Safari
JavaScript
7
star
60

jquery-dragme

A super lightweight jQuery plugin for dragging elements using CSS3 Transforms
JavaScript
7
star
61

extender

Cross-Browser Extension library and build tool
Ruby
6
star
62

buffer-quality-dashboard

GitHub issue dashboard
JavaScript
6
star
63

css-style-guide

How we CSS at Buffer
6
star
64

kubesecret

A tool to manage secrets in kubernetes
JavaScript
6
star
65

tracking-plan-kit

Utilities for managing Buffer's Data Tracking Plan
Python
5
star
66

segment-config-api

A Python Wrapper for Segment's Config API
Python
4
star
67

buffer-talks

Bufferoo Talks - built on Jekyll and Remark
HTML
4
star
68

docker-demos

Intro to Docker: Images + Containers
Dockerfile
4
star
69

buffer-static-upload

πŸ“β†’β˜οΈπŸ€˜ Making it easy to upload your static assets
Go
4
star
70

aws-key-auditor

Get all keys from an AWS account and send an email if a key is getting old
JavaScript
4
star
71

app-shell

Buffer's shared App Shell for front-end applications
TypeScript
3
star
72

cerone

Extensible consumer made for applications using Amazon's Kinesis Python Client Library (KCL).
Python
3
star
73

mongoct

MongoDB Change Streams tracker.
Python
3
star
74

buffer-bot

DEPRECATED
CoffeeScript
3
star
75

buffer-scripts

⌨️ A collection of useful scripts for all sorts of manual tasks!
Shell
3
star
76

buffer-code-exercise-api

A small api server which will be used in the Buffer interview code exercise.
JavaScript
3
star
77

buffer-opensource

Buffer ❀️ Open Source. Static site generator for Buffer's Open Source Site (https://bufferapp.github.io/)
HTML
2
star
78

gprc-metrics-poc

gRPC-based Metrics Collection pipeline proof-of-concept monorepo
JavaScript
2
star
79

convoyslit

Streamlit app to quickly explore convoys models from BigQuery queries
Python
2
star
80

buffer-js-shutdown-helper

Shutdown your Express.js apps gracefully
JavaScript
2
star
81

buffer-icons

Custom Buffer fonts for all!
HTML
2
star
82

micro-rpc-client

Universal JS RPC Client https://github.com/bufferapp/micro-rpc/
JavaScript
2
star
83

helpscout-api

A Python interface to Helpscout's API
Python
2
star
84

stripe-pipeline

A simple data pipeline for Stripe API events to Redshift
Python
2
star
85

cricket

Your personal Jiminy Cricket when posting online.
Python
2
star
86

pipub

Pipe data from the command line to Google Pubsub.
Python
2
star
87

go-base-worker

Golang packages needed to build a consumers
Go
2
star
88

buffer-js-dragme

module for dragging components
JavaScript
2
star
89

streamlit-causal-impact

Streamlit app to run Causal Infence in your CSVs
Python
2
star
90

android-utils

Common utilities used in our android projects
Kotlin
2
star
91

manual-payments

R
2
star
92

bufferapp.github.io

Buffer's Development Driven Values
HTML
1
star
93

buffer-branding-2018

HTML
1
star
94

buffer-js-logger

Node.js logging for Buffer applications
JavaScript
1
star
95

buffer-update-converters

Convert statuses from Twitter, Facebook and Instagram into Buffer updates
PHP
1
star
96

php-bufflog

php logger for all PHP Buffer services
PHP
1
star
97

dd-tracing-logging-examples

JavaScript
1
star
98

buffer-js-request

JS interface to send requests – thin wrapper around fetch()
JavaScript
1
star
99

slack-channels

Analysis on Buffer's slack channels
Jupyter Notebook
1
star
100

buffer-standards

Standard configuration for shared packages/tools at Buffer
TypeScript
1
star