alexandreant / SwiftCleanArchitecture

Studying about Architecture for iOS Projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift

Clean Architecture using Swift

Using Github Api para:

  • List repositories
  • List pull requests from some repository
  • Show detail from some pull request

Motivation

Study about implementation, using three layers (Domain, DataSource, Presentation), in this repository I chose follow a more flexible solutions.

  • Organization
  • Easy to debug
  • Easy to plug layers
  • Componentization
  • Tests

Structure

Domain

This layer is the main, there are all business logics and all model data struct necessary for the application.

  • All communications are executed through interfaces like InterfaceAdapter and RepositoryInterface.
  • Models are data necessary to UseCases logic
  • UseCases are the main logic

DataSource

This layer has the reponsability to handle APIs calls and access to DataBases like CoreData for example.

  • All repositories here extends RepositoryInterface and implement interfaces to DataSources like APIs or CoreData if necessary

Presentation

This layer has the reponsability to show and handle inputs from an interface, so in that example is implemented using like MVVM

  • The Coordinator has the responsibility to get all DataSources, UseCases, ViewModel and ViewController, so this will build everything and then show ViewController with your relative ViewModel
  • ViewModel, in this case, extends InterfaceAdapter to receive responses from UseCase and implement UseCase interfaces to execute that logics
  • ViewController, in that case, was created only to observe ViewModel and modify View without any intelligence there.
  • The view is a view, an only structure like Xib or StoryBoards.

How works

Image from this medium post

Libs

Roadmap

  • Do more tests
  • Discuss about necessity to translate Error from DataSource to Domain
  • Discuss about best way to connect Domain to Presentation without external solutions

License

This project is lincesed by MIT - look at file LICENSE.md for details.

About

Studying about Architecture for iOS Projects

License:MIT License


Languages

Language:Swift 90.5%Language:Ruby 7.9%Language:Objective-C 1.0%Language:Shell 0.7%