Where should put Location Provider in clean architecture code


#1

let say based on current location I want to fetch data from. How should I incorporate this into clean architecture


#2

Clean architecture defines a ports and adapters design.

This means things like, the UI, external sensors, sit outside of your core usecases. Therefore the Location Provider as a sensor should sit with the external interfaces. You should create a domain object for representing location, and pass thing into your usecases and use that in your domain. Having a “location providing” abstraction around your LocationProvider means you could replace this with other location providers, for example if running on Amazon using a different location provider, or perhaps even an external GPS, or even better for testing replace it with a mock provider where you can control your location (handing for Manual QA testing as well as unit testing).