Architecture Overview of Clean Architecture for SwiftUI
masterThis project implements a decoupled architecture consisting of three distinct layers to ensure separation of concerns:
- Presentation Layer: Composed of SwiftUI views that contain no business logic. Views are a function of the state and trigger side effects via user actions or lifecycle events (like
onAppear), which are then forwarded to Interactors. - Business Logic Layer: Represented by Interactors. Interactors receive requests to perform work (e.g., fetching data or computations). They do not return data directly; instead, they update the AppState (the single source of truth) or provide data via a Binding for local view use.
- Data Access Layer: Represented by Repositories. Repositories provide asynchronous APIs (using Combine
Publisher) for CRUD operations on backends or local databases (like SwiftData). They contain no business logic and do not mutate theAppState. They are only accessible by Interactors.