feat(GRO-2153): abstracted geocoding service (Nominatim + Google) #167
Reference in New Issue
Block a user
Delete Branch "feat/gro-2153-geocoding-service-dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
GRO-2153 — Route Optimization: Geocoding Service (Phase 1.2)
Builds the abstracted geocoding service layer on top of the GRO-2152 schema.
What's included
GeocodingProviderinterface +GeocodeResulttype — provider-agnostic contract.NominatimGeocodingProvider(default, free, self-hostable) — internal rate limiter enforces the 1 req/sec Nominatim usage policy; configurable base URL + User-Agent.GoogleGeocodingProvider(optional fallback) — keyed by the encryptedbusinessSettings.googleMapsApiKey(decrypted viadecryptSecret), withGOOGLE_MAPS_API_KEYenv as a dev fallback.resolveGeocodingProvider(settings)— selects onbusinessSettings.routeOptimizationProvider; safely falls back to Nominatim (with a warning) whengoogleis configured but no usable key exists or decryption fails.geocodeBatch()— throttled batch utility; honors the provider's rate limit, captures per-item errors (never aborts the batch), optional progress callback.Tests
src/__tests__/geocoding.test.ts— 20 unit tests: both providers (success / empty / blank / HTTP error / API-status error), provider selection (all branches incl. decrypt failure + env fallback), throttle spacing (deterministic virtual clock), and batch (order, error capture, progress).tsc --noEmit✓,eslint(new files) ✓, fullvitest run→ 602 passed,pnpm build✓.Scope notes
UAT_PLAYBOOK.mdupdate is required for this PR../srctree (DockerfileCOPY src/), consistent with where GRO-2152 schema landed and the apps/api deprecation direction.⚠️ Discovered (out of scope, separate infra bug)
CI's
LintandTestjobs runpnpm --filter @groombook/api <script>, which matches no project (pnpm excludes the workspace root from--filter) → both jobs no-op and always pass. The api lint/test suites are not actually executing in CI. Filing a follow-up for the CTO. This PR's correctness is verified locally and theBuild & Pushjob does compile./srcviatsc.Reference: GRO-1164 plan — Geocoding & Mapping Strategy.
cc @cpfarhood