Layer: Backend API / Redis
Effort: Medium (3–5h)
Artisan locations are currently static. To provide a true "Uber-like" proximity matching experience, we need a high-frequency ingestion endpoint that allows artisan mobile devices to update their coordinates in real-time.
Because this endpoint will be hit frequently (e.g., every 10–30 seconds while the artisan app is open), it must strictly avoid heavy PostgreSQL writes and instead rely entirely on our Redis in-memory datastore.
Required Changes
1. Fast Geolocation Endpoint
- Create a
PUT /api/v1/artisans/location endpoint in backend/app/api/v1/endpoints/artisan.py.
- Secure the endpoint using
Depends(require_artisan) so only authenticated artisans can update their location.
- The request payload should accept simple
latitude and longitude floats.
2. Redis Geospatial Indexing
- In
backend/app/services/geolocation.py, implement a method to handle the Redis GEOADD command.
- The Redis key should be a spatial index (e.g.,
artisans:locations) where the member is the artisan_id.
- Crucial: Implement a TTL (Time-To-Live) mechanism. If an artisan closes their app or loses signal, their location should expire from the map after ~15 minutes to prevent clients from booking "ghost" artisans who are no longer online.
Acceptance Criteria
Layer: Backend API / Redis
Effort: Medium (3–5h)
Artisan locations are currently static. To provide a true "Uber-like" proximity matching experience, we need a high-frequency ingestion endpoint that allows artisan mobile devices to update their coordinates in real-time.
Because this endpoint will be hit frequently (e.g., every 10–30 seconds while the artisan app is open), it must strictly avoid heavy PostgreSQL writes and instead rely entirely on our Redis in-memory datastore.
Required Changes
1. Fast Geolocation Endpoint
PUT /api/v1/artisans/locationendpoint inbackend/app/api/v1/endpoints/artisan.py.Depends(require_artisan)so only authenticated artisans can update their location.latitudeandlongitudefloats.2. Redis Geospatial Indexing
backend/app/services/geolocation.py, implement a method to handle the RedisGEOADDcommand.artisans:locations) where the member is theartisan_id.Acceptance Criteria
PUT /artisans/locationsuccessfully accepts coordinate payloads and strictly requires artisan authentication.GEOADDindex.