KwadMarket Docs
Product Roadmap

Geolocation

Structured location and radius search for deals

Current state

Deals store location: String? as free text (e.g. "Paris, France"). No coordinates, no distance search. Structured location matters a lot for pickup-heavy categories like drones/LiPos (shipping batteries is restricted in many countries).

Data model changes

// Add to Deal model (and optionally User for a default location)
latitude   Float?
longitude  Float?

Geocoding strategy

When a user enters a location in the deal form:

  1. Autocomplete via OpenStreetMap Nominatim (free, no API key) or Google Places (paid, better UX).
  2. On select: store both the display string and lat/lng.
  3. Validation: coordinates within reasonable bounds.

Recommendation

Start with Nominatim; switch to Google Places only if the UX isn't good enough.

Option A — PostGIS (best): ST_DWithin + spatial indexes, extremely fast. Option B — Haversine in SQL (simpler): no extension, fine for <100k deals.

Recommendation: start with Haversine, migrate to PostGIS if performance becomes an issue.

SELECT *, (
  6371 * acos(
    cos(radians(:lat)) * cos(radians(latitude)) *
    cos(radians(longitude) - radians(:lng)) +
    sin(radians(:lat)) * sin(radians(latitude))
  )
) AS distance
FROM deals
WHERE status = 'PUBLISHED'
HAVING distance < :radiusKm
ORDER BY distance

Frontend UX

  • Deal form: autocomplete replacing the free-text input; small map preview (Leaflet + OSM tiles); "Use my current location" (browser geolocation API).
  • Deal search: "Near me" / "Near [city]" filter; range slider (10/25/50/100/200km/Nationwide); sort by distance; map view toggle (V2).
  • User profile: default location setting (auto-fills the deal form).

Tasks

  • latitude/longitude on Deal (and User); geocoding service (Nominatim)
  • Location autocomplete component; store coordinates on deal create/update
  • Distance-based search query (Haversine); nearLat/nearLng/radiusKm params on the deals search endpoint
  • Location filter UI + range slider; "Use my current location"; map preview (Leaflet)
  • Map view for search results (V2)

On this page