Hi Everyone,
I'm building an app using React Native and developing its APIs with Laravel. The app allows customers to post jobs for specific services, and nearby vendors are notified of the posted jobs.
I'm looking for guidance on implementing a system to find nearby vendors. Here's the workflow I've designed so far:
- Vendor Registration: During registration, I'll save the vendor's location (longitude and latitude) using Google Maps.
- Job Posting: When a customer posts a job, I'll capture the job's location (longitude and latitude) and use a function like ST_Distance_Sphere to calculate the distance and identify vendors within a specified radius.
Challenges:
- Storing Location Data:
a) Should I use the POINT data type to store location data in a single column?
b) Alternatively, should I save longitude and latitude in two separate columns with a DECIMAL data type (as suggested by ChatGPT)?
- Real-time Vendor Location:
a) How can I get the vendor's current location in real-time? Relying solely on the registered location might notify vendors who are not in the area at the time. I want functionality similar to Uber or Careem.
b) My proposed solution: When the vendor opens the app, the mobile device sends their current location to the server, which updates their location every 5 minutes.
- Resource Optimization:
a) How resource-intensive will this process be?
b) What are the best practices to optimize this workflow to ensure it’s efficient and scalable?
If anyone can provide guidance or share their experience with these challenges, it would be greatly appreciated.