Giter VIP home page Giter VIP logo

fitnessfinder's Introduction

Android Architecture Starter Templates (beta) Example.

Features: Reactive MVVM arch with Kotlin Flows RoomDB Hilt Declarative with ComposeUI Bill of Materials (BoM) All Composable(s) have a preview.

We use Accompanist as it is maintained by the Google Android Compose Team. Accompanist is a group of libraries that aim to supplement Jetpack Compose with features that are commonly required by developers but not yet available.

https://github.com/google/accompanist/tree/main/sample/src/main/java/com/google/accompanist/sample/permissions

Video Tutorial code

================== Android GraphQL Tutorial Android GraphQL Example

GraphQL

Yelp tutorial

Yelp GraphQL

Yelp Docs Yelp GraphQL Test Yelp GraphQL

Postman

Postman GraphQL

Arach

app arch Video Series

Code

Apollo GraphQL tutorial Apollo Compose Code Download Schema

Architecture Learning Journey Modularization Learning Journey

app core datastore

Thoughts: Now in Android img app free one

Google Arch Guidelines:

  1. Data Layer
  2. UI Layer
  3. Domain Layer

The Data Layer: Data with business logic made of

Repositories -connect to -> Data Sources (Remote or local) only one source of data

Repositories: 1. Expose data, 2. Centralize changes, 3. Resolve conflicts, 4 Contain business logic (domain layer) Each to only one data source. (ie. data vs payments)

Single source of truth. The repository should update/resolve local cache when connecting to the API

Data Immutability is done with Kotlin data class. Use different data classes for various layers.

Errors: use Kotlin Flow catch operator. Testing: Use Room in memory database for local data testing. Use fake data with DI. WireMock for network test.

The UI Layer: UI Elements / State Holders - App State -

  1. App data -> UI data
  2. UI data -> UI elements
  3. User events -> UI changes

UiState: use Kotlin data class ViewModel is a state holder (Unidirectional data flow)

  1. ViewModel exposes UI state
  2. UI notifies ViewModel of events
  3. ViewModel updates state and is consumed by the UI

UI is updated by state exposure using Kotlin Flows / Channels (StateFlow) Compose: Use mutableStateOf

UI state consumption is done by the terminal operator ".collect" Need to track the lifecycle. ViewModels last longer then then UI. Only collect when the UI is active.

UI Events.

  1. User Events - Actions - onClick function ()->Unit
  2. ViewModel Events - Exposes all the business logic need by the UI - State Update. Use uiState: StateFlow = ... errorMessages: List - using scaffoldState.snackbarhostState.showSnackbar
  • refresh --
  • Use LaunchedEffect - Start a coroutine from a Composable.

MainUIRoute - has all the ViewModels.

Domain Layer: only holds business logic. Has the UseCases- Naming is {verb in present tense explainig what you are doing} {noun/what} {the world UseCase} example: getLatestGymLocationUseCase

  1. Simple
  2. Lightweight
  3. Immutable Use Suspend functions, Flows and Callbacks to message the UI Layer. Usecase use other Usecases. Lifecycle - scoped to caller / create a new instance when passing as a dependency Threading - Must be main-safe / Move job to data layer if result can be cached.

Common Tasks:

  1. Encapsulate reusable business logic.
  2. Combine data from multiple repositories

Use a usecase to combine data that is needed by the ViewModel. Use the kotlin invoke function to make it callable: suspend operator fun invoke(): List

Usecases should be thread safe as they can be called noumerous times. Everything must go though Domain Layer.

  1. Reduce complexity of UI layer
  2. Avoid duplication
  3. Improve testability

Modularization Divide your project into:

  1. Feature modules
  2. Library modules
  3. App modules

Layers: App -only-> Feature -only-> Library


Enities - Remote Entities - JSon Response - data class RemoteUser(val userid :String, val token:String) / RemoteInventory Database Entities - @Entity using Room Domain Entities - business models - data call Inventory() - UiState - UI State - @Parcelize data class Inventory():Parcelable with mapper classes - Remote and Database = DataLayer UiState or Domain = UI Layer

data class RemoteInventory

Nice Alternative platform

fitnessfinder's People

Contributors

developery 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.