- Domain Layer = Entities + Use Cases + Gateways Interfaces
- Data Repositories Layer = Repositories Implementations + API (Network) + Persistence DB
- Presentation Layer (MVVM) = ViewModels + Views
Note: Domain Layer should not include anything from other layers(e.g Presentation — UIKit or SwiftUI or Data Layer — Mapping Codable)
UseCase / Interactor
- contains the application / business logic for a specific use case in your application- It is referenced by the
Presenter
. ThePresenter
can reference multipleUseCases
since it's common to have multiple use cases on the same screen - It manipulates
Entities
and communicates withGateways
to retrieve / persist the entities - The
Gateway
protocols should be defined in theApplication Logic
layers and implemented by theGateways & Framework Logic
- The separation described above ensures that the
Application Logic
depends on abstractions and not on actual frameworks / implementations - It should be covered by Unit Tests
- It is referenced by the
Entity
- plainSwift
classes / structs- Models objects used by your application Main, Item, etc.
Gateway
- contains actual implementation of the protocols defined in theApplication Logic
layer- We can implement for instance a
LocalPersistenceGateway
protocol usingCoreData
orRealm
- We can implement for instance an
ApiGateway
protocol usingURLSession
orAlamofire
- We can implement for instance a
UserSettings
protocol usingUserDefaults
- It should be covered by Unit Tests
- We can implement for instance a
Persistence / API Entities
- contains framework specific representations- For instance we could have a
CoreDataOrder
that is aNSManagedObject
subclass - The
CoreDataOrder
would not be passed to theApplication Logic
layer but rather theGateways & Framework Logic
layer would have to "transform" it to anOrder
entity defined in theApplication Logic
layer
- For instance we could have a
Framework specific APIs
- contains implementations ofiOS
specific APIs such as sensors / bluetooth / camera
- Searching for forecast by city name, zipCode, lat/lon and current location.
- Ability to see forecast for searched location
- Ability to navigate to Dashboard screen
- Xcode Version 12+ Swift 5.0+