How to design architecture of iOS app with switching datasources

Viewed 38

I am designing an architecture for an iOS SwiftUI app and I have no experience with it so I need to clarify few things.

My app will use these datasources:

  • Bluetooth device
  • API
  • CoreData or Realm

Bluetooth device sends data regularly (every 5 minutes) and I have to be able to get them even the app is in the background (or terminated) if possible. Data should be stored somewhere and synced to the API when connected.

Also app should be capable of determining when to use persistent storage and when to use API. One idea is that I would always use for example CoreData and data received from bluetooth device would be stored there (it should automatically rerender view). API will be requested regularly in the background, data from API will be compared with local data and synced appropriately.

I dont’ know, where should I start. I researched commonly used architectures and I really like hexagonal and clean architectures, but I can’t image how to use it correctly.

I didn’t find any resources mentioning switching datasources as the user is online/offline. If is it appropriate to use always CoreData in the app or if I should switch datasources and synchronize with CoreData in the background.

0 Answers
Related