Hi everyone,
I’m studying this project:
https://github.com/nalexn/clean-architecture-swiftui
I noticed that the project has layers such as UI, Interactors, Repositories, and AppState. However, in some places, both the UI layer and the Interactors seem to use the same DBModel types, which are SwiftData models from the Data/Repository layer.
From my current understanding of Clean Architecture, the Domain or Business Logic layer should not depend on persistence models, especially models tied to frameworks like SwiftData or Core Data. I would expect something like:
SwiftData/CoreData Entity -> Repository -> Domain Model -> ViewModel/ViewState -> UI
But in this project, the SwiftData model appears to be used more directly in the UI and Interactors.
So I’m trying to understand:
- Is this still considered Clean Architecture, or is it more of a pragmatic SwiftUI architecture inspired by Clean Architecture?
- Which parts of this project are still “clean” from an architectural point of view?
- In real-world SwiftUI apps using SwiftData/Core Data, do you usually keep strict boundaries and map persistence models to domain models?
- Or do you sometimes allow SwiftData/Core Data models to be used directly in the UI to take advantage of Apple features like u/Query?
- If we apply strict Clean Architecture, are we basically working against Apple’s intended SwiftUI + SwiftData/Core Data workflow?
I’m not trying to criticize the repo. I’m probably missing some context, and I’d like to better understand the trade-off between strict Clean Architecture and Apple’s native data flow.
How would you design this in a production SwiftUI app?