GithubHelp home page GithubHelp logo

tchigher / clean-architecture-swiftui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nalexn/clean-architecture-swiftui

0.0 0.0 0.0 209 KB

A demo project showcasing the production setup of the SwiftUI app with Clean Architecture

Swift 90.34% HTML 9.66%

clean-architecture-swiftui's Introduction

Clean Architecture for SwiftUI + Combine

A demo project showcasing the setup of the SwiftUI app with Clean Architecture.

The app uses the restcountries.eu REST API to show the list of countries and details about them.

platforms Build Status codecov codebeat badge

Diagram

Key features

  • Designed for scalability. It can be used as a reference for building large production apps.
  • Vanilla SwiftUI + Combine implementation. No 3rd party dependencies
  • Programmatic navigation (deep links support)
  • Decoupled Presentation, Business Logic, and Data Access layers
  • Everything is a Struct (except for a couple of modules)
  • Centralized AppState as a single source of truth
  • Dependency injection of Interactors and AppState
  • Simple yet flexible networking layer built on Generics
  • Handling of system events (such as didBecomeActive, willResignActive)
  • Built with SOLID, DRY, KISS, YAGNI in mind.

Architecture overview

Diagram

Presentation Layer

SwiftUI views that contain no business logic and are a function of the state. AppState is injected into the view hierarchy as @EnvironmentObject

Side effects are triggered by the user's actions (such as a tap on a button) or view lifecycle event onAppear and are forwarded to the business logic layer.

Business Logic Layer

Business Logic layer is represented by Interactors.

Interactors receive requests to perform work, such as obtaining data from an external source or making computations, but they never return data back directly.

Instead, they forward the result to the AppState or to a Binding. The latter is used when the result of work (the data) is used locally by one View and does not belong to the AppState

Interactors are injected into the view hierarchy within a container as an @Environment variable.

Data Access Layer

Data Access layer is represented by Repositories.

Repositories provide asynchronous API (Publisher from Combine) for making CRUD operations on the backend or a local database. They don't contain business logic, neither do they mutate the AppState. Repositories are accessible and used only by the Interactors.

Articles related to this project


license Twitter blog

clean-architecture-swiftui's People

Contributors

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