Proof concept of modularized app with SwiftPackages built over MVI + Combine + SwiftUI in a single repo

Overview

PKDex-iOS

Proof concept of modularized app with SwiftPackages built over MVI + Combine + SwiftUI in a single repo

Introduction

This project is a proof of concept to test and practice mainly the architecture and new trends in iOS development. Therefore, it will be a project in constant evolution and that can serve as a guide or model for other types of applications ready to be in production (Production Ready) for me, in which, having the architectural base already made, the speed of development should be much more quick for future features.

The main motivation to start this is precisely the paradigm shift that iOS and Android are taking on how to design an App, since they began to take a much more natural path towards a paradigm focused on "Unidirectional data flow" with the availability of Combine API on iOS and Flow on Android, in addition to a new way of designing the UI in a more declarative way with framework SwiftUI on iOS and Compose on Android, promoting the unification of a single Desing System definition for Apps.

Another main motivation is to find a balance in a modular app without having to deal with multiple repositories as much as possible, which in the case of small teams can be more of a brake on development speed than a real help, so the idea is build this app using Swift Packages (located in this same repository, but eventually if required, it is easy to move it to an independent repository).

Goals

  • Make an app with Clean Architecture and SOLID principles.
  • Use an architecture with unidirectional data flow, for this occasion I decided to do it in MVI using Combine and SwiftUI.
  • Create an MDK (Mobile Development Kit) with all the components and reusable code that can be used in this project and in other future projects.
  • Modular by features.

Architecture

The modules that will be built consist of the Base App module, which only acts as a container and which will be in charge of registering all the components for the injection of dependencies, the Main Scene of the app will mount the modules and will have a Router for the navigation of the app.

  • App: Main container of the App, contains the Navigation Router and the main Scene
  • Core: Contains contracts and common components of the App (states of the scenes, it could also contain all the logic of notifications, deeplinks, etc).
  • Listing: Module for the pokemon listing
  • Detail: Module to show the detail of a pokemon
  • Favorites: Module with the status of favorite pokemon.
  • Design: Module with the design contracts to set up a Design System that can be consumed by the Feature modules (icons, reusable views, color palette, etc.)
  • APIs: Module with the detail of third-party APIs that can be directly used by the different Feature modules.

App Modules

The modules will be built with Clean Architecture, this means that the domain layer must contain its own domain entities and their use cases, and must not depend on or know details of the data or presentation layer. In these last layers to avoid the coupling of libraries we are going to use interfaces that encapsulate all the behavior of the functionalities, which will allow us using a strategy pattern (aka Providers in the MDK) to be able to change the implementations of the libraries easily (we could easily change to run network calls with NSUrlSession to Alamofire easily).

Abstract Architecture

In practice, this project shows a structure like the following

Detail Module Structure

MVI: Model - View - Intent

MVI is a unidirectional data flow architecture that was designed to be used in reactive programming, where the model represents the source of truth for the application, the intent is an interaction that the user (or the system itself) can trigger and causes the state of the system mute to a new state, which will be rendered in the view. This allows us to make the code more readable and more scalable by adding new states or actions, making it easier to debug it knowing what is the state of the app in any time.

MVI

Each module in its presentation layer will be built under an MVI architecture, which will allow us to have a source of truth only in the scope of its domain, which could eventually be imported and read by other modules that need to know the status of that domain. . In addition, each module defines its actions, a reducer that contains the rules to mutate the current state to a new state in response to an action and the module's side effects (which will execute network tasks, database or collateral effects).

MVI Detail Structure

All this behavior will be encapsulated in a Store with which a viewmodel can be imported to connect it to a view

Store Detail

This allows the stores can be imported by other ViewModels that need to know about states or trigger specific actions handled by that Store. For example, the ViewModel of the Listing module imports the Store of its own module in addition to importing the Store of the Favorites module to be able to render a list of favorite pokemon, as well as the listing can trigger actions of favorites to store or delete favorites.

Shared Store

Roadmap

  • Implement App Base
  • Implement Listing
  • Implement Favorites
  • Implement the Detail module
  • Make complete battery of unit tests
  • Improve UI and make them more attractive, in addition to dark mode
  • Implement CI
  • Improve implementations with Futures / Promises or Async / Await

MDK: Mobile Development Kit

The project is being used with an MDK that you can find here that contains extensions and utilities in addition to providers for network and storage (more providers will come in the future and a more detailed documentation).

How to use

  • Just open the workspace PKDex.xcworkspace using and compile/run the project using the scheme PKDex (iOS).
Comments
  • Refactor: Improve MVI flux to make more easy

    Refactor: Improve MVI flux to make more easy

    Proposed Change

    • Change the way to use and build the MVI components to make more easy to implement

    Changes

    • Update the code to the version 2.0.0 of MDK and support the new MVI
    refactor ready 
    opened by MaikCL 0
  • Release: v1.0.0

    Release: v1.0.0

    What's new

    Favorites Component

    • Added: Favorite component with state for favorites pokemon

    Listing Component

    • Enhanced: Added Favorite Store to include the favorite pokemon for user in the listing

    Issues solved

    • Favorite Module (#23)
    • Documentation Readme (#12)
    • Empty Detail module to make navigation (#4)
    done 
    opened by MaikCL 0
  • Documentation: Improve Readme

    Documentation: Improve Readme

    Proposed Change

    • Improve readme to explain the project and the architecture

    Changes

    • Add some image assets
    • Improve the readme.md file

    Issue

    • Resolve #12
    documentation done 
    opened by MaikCL 0
  • Feature: Favorites Pokemon

    Feature: Favorites Pokemon

    Proposed Change

    • The ability to add favorite pokemon (stored locally in a CoreData instance) is implemented in addition to minor changes in the app

    Changes

    • Add Favorites Module - Data, Domain and Presentation layer (composed by a MVI Store to be imported in the modules that need to read the favorites State)
    • Add local datasources for favorites using the Storage Agent
    • Add Icons to Design System package
    • Implemented basic detail module
    • (Basic viewmodel, scene and factory) for future implementation

    Issue

    • Resolve #23
    enhancement done 
    opened by MaikCL 0
  • Feature: Make navigation detail

    Feature: Make navigation detail

    Proposed Change

    • Try to implement a navigation system between modules in an easy way (and if possible little coupled). In addition, a ViewModel is implemented that will act as a mapper from domain states to view states in addition to acting as an abstraction layer between the view and the stores

    Changes

    • Add an AppRouter
    • Add a ListingViewModel that map the Stores states to a ViewState
    • Add a Listing Factory to make easy the build of the module in the router

    Issue

    • Resolve #4
    enhancement done 
    opened by MaikCL 0
  • Feature: Navigation Store

    Feature: Navigation Store

    Proposed Change

    • Add a Abstraction in the way to do navigation in the App managed by a Store

    Changes

    • Add MVI components for the NavigationStore

    Issue

    • Resolve #4
    enhancement wontfix 
    opened by MaikCL 0
  • Release: v0.8.0

    Release: v0.8.0

    What's new

    APIs Component

    • Added: List of Pokemon from Kanto providing for PokeAPI.co

    Core Component

    • Added: SceneStore for Scene management

    Design Component

    • Added: Common simple exception view

    Listing Component

    • Added: ListingStore for Listing management
    • Added: ListingUI with basic Listing features

    Issues solved

    • SceneStore component (#3)
    • Domain layer for listing (#8)
    • Data layer for listing (#9)
    • Presentation layer for listing (#10)
    • Connect listing to the app (#11)
    done 
    opened by MaikCL 0
  • Feature: Integrate Listing module in the iOS Scene

    Feature: Integrate Listing module in the iOS Scene

    Proposed Change

    • Add the simple module Listing to the Main App

    Changes

    • Register all Listing dependencies in the App
    • Load the Listing View in the iOS Scene

    Issue

    • Resolve #3
    enhancement done 
    opened by MaikCL 0
  • Feature: Presentation layer listing

    Feature: Presentation layer listing

    Proposed Change

    • Add initial and basic presentation layer for the Listing module

    Changes

    • Add Design System view for the exceptions in the app
    • Add MVI components for the Listing module

    Issue

    • Resolve #8
    enhancement done 
    opened by MaikCL 0
  • Feature: Data layer Listing

    Feature: Data layer Listing

    Proposed Change

    • Add data layer for the Listing module

    Changes

    • Added Repository
    • Added Datasource cloud
    • Added respective cloud models and mapper

    Issue

    • Resolve #9
    enhancement done 
    opened by MaikCL 0
  • Feature: SceneStore

    Feature: SceneStore

    Proposed Change

    • The SceneStore is added to manage the states and actions relating to the management of the scenes in the app

    Changes

    • Add SceneStore
    • Define the scene actions
    • Define the scene states
    • Define the scene side effects

    Issue

    • Resolved #11
    enhancement done 
    opened by MaikCL 0
Releases(v1.1.0)
  • v1.1.0(Oct 20, 2021)

    What's new

    Core Component

    • Refactorized: Simplify the way of implement MVI module

    Favorites Component

    • Refactorized: Simplify the way of implement MVI module

    Listing Component

    • Refactorized: Simplify the way of implement MVI module
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Jun 22, 2021)

    What's new

    Favorites Component

    • Added: Favorite component with state for favorites pokemon

    Listing Component

    • Enhanced: Added Favorite Store to include the favorite pokemon for user in the listing
    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(May 3, 2021)

    What's new

    APIs Component

    • Added: List of Pokemon from Kanto providing for PokeAPI.co

    Core Component

    • Added: SceneStore for Scene management

    Design Component

    • Added: Common simple exception view

    Listing Component

    • Added: ListingStore for Listing management
    • Added: ListingUI with basic Listing features
    Source code(tar.gz)
    Source code(zip)
Owner
Miguel Angel Zapata
iOS & Android Dev Trying to write clean code.
Miguel Angel Zapata
An MVI, SwiftUI and Combine exploration project to shop clothe by resemblance 👗

Portfolio is an MVI, SwiftUI and Combine exploration project to keep track of your portfolio over time. Resources MVI MVI Architecture for Android Tut

Bastien Falcou 7 Oct 4, 2022
The concept took third place in the Design Concept Award contest Season 1 in 2021.

SpringAnimation Developed by Yurii Sameliuk as part of the You are launched "Design Concept Award" contest Season #1. SpringAnimation demo. Inspired b

You are launched 5 Jul 10, 2022
The concept took second place in the Design Concept Award contest Season 1 in 2021.

SmileRate Developed by Alex Kryvodub as part of the You are launched "Design Concept Award" contest Season #1. SmileRate demo. Inspired by Duy Luong c

You are launched 1 Jan 12, 2022
New version of CardinalKit based on the Swift Package Manager and a modularized architecture.

CardinalKit Open-source framework for rapid development of modern, interoperable digital health applications. Contributing Contributions to this proje

Stanford Biodesign for Digital Health 3 Dec 3, 2022
Github repo search with using mvvm-c and clean architecture and using combine swift

GitSearchWithMVVM-C-CleanArchitecture Github repo search with using mvvm-c and clean architecture and using combine swift. Content Overview How To Run

Muhammad Qasim Majeed 1 Mar 16, 2022
In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.

TodoList In this application used the concepts from the beginner level project of SwiftUI_Evolve_1 The following concepts covered in this mini app Swi

Sivaram Yadav 2 Dec 4, 2021
content for Using Combine - notes on learning Combine with UIKit and SwiftUI

SwiftUI-Notes A collection of notes, project pieces, playgrounds and ideas on learning and using SwiftUI and Combine. Changes, corrections, and feedba

Joseph Heck 1.7k Dec 27, 2022
iOS app that detects LaTeX symbols from drawings. Built using PencilKit, SwiftUI, Combine and CoreML for iOS 14 and macOS 11.

DeTeXt Finding the symbol you want to use in LaTeX can be hard since you can't memorize all the possible commands and packages for every symbol you mi

Venkat 73 Dec 8, 2022
E-commerce app built in SwiftUI. Built in the course SwiftUI Masterclass in Udemy.

Touchdown-SwiftUI E-commerce app built in SwiftUI. Built in the course SwiftUI Masterclass in Udemy. Main components and concepts used: @EnvironmentOb

Jorge Martinez 5 Aug 18, 2022
Sample iOS project built by SwiftUI + Flux and Combine framework using GitHub API

SwiftUI-Flux Flux enables us to have unidirectional data flow and make it testable. It's used to be implemented using RxSwift or ReactiveSwift in the

Yusuke Kita 87 Nov 25, 2022
Sample iOS project built by SwiftUI + MVVM and Combine framework using GitHub API

SwiftUI-MVVM One of the biggest idea for having MVVM is that most of data flow can be testable. Data binding in view layer by SwiftUI is awesome. Howe

Yusuke Kita 592 Jan 2, 2023
Recipes app written in SwiftUI using Single State Container

swiftui-recipes-app Recipes app is written in SwiftUI using Single State Container This app implemented as an example of a Single State Container conc

Majid Jabrayilov 512 Dec 31, 2022
AllAboutTheWord - A single screen iOS app developed using swiftUI

All-About-The-Word Introduction This is a single screen iOS app developed using

null 7 Dec 22, 2022
An app that composes text over an image in SwiftUI

MemeMaker MemeMaker is a little app using SwiftUI that shows a few things: Main list uses a generic type constrained to View to pass destination view

James Dempsey 99 Aug 15, 2022
Mac OSX app that displays window previews when hovering over app icon on the Dock.

Dock Window Preview Adds window preview functionality on hover for Mac Dock, an open-source alternative. This is very early in development and it will

Paul Sweeney 32 Dec 26, 2022
Informant is a macOS menu bar app that lets you inspect files with a single click. 🔍

Informant Inspect files with a single click. Introduction Welcome! If you're not sure what Informant is or what it does please check out informant-app

Ty Irvine 31 Nov 7, 2022
Moit: a single delivery platform for college students living in dormitories

Moit: a single delivery platform for college students living in dormitories

LeeProgrammer 0 Nov 9, 2021
Single Webview project for xcode in swift

Single Webview project for xcode in swift An xcode project that with single webview(UIWebView) that opens external URL, for hybrid web app debug or te

null 0 Dec 11, 2021
Best architecture for SwiftUI + CombineBest architecture for SwiftUI + Combine

Best architecture for SwiftUI + Combine The content of the presentation: First of the proposed architectures - MVP + C Second of the proposed architec

Kyrylo Triskalo 3 Sep 1, 2022