Maps proximity / POI search system design (Yelp, Google Maps "nearby restaurants"): H3-indexed POI search with k-ring scan, hot-query cache, vector tile delivery, and OSRM-style routing. Includes 5 scenarios (nearby search, expand radius, hot tourist area, route A->B, POI ingest) and 2 ADRs (geohash vs H3 vs quadtree, vector vs raster tiles).
This design covers static points of interest (POIs), versioned vector tiles, and traffic-aware road routing. It deliberately does not claim to be a moving-driver or real-time fleet index. Those systems need a different update-rate, staleness, privacy and assignment model.
H3 is used only to generate candidates. It is not an exact distance function and its cells are not equal-area. The authoritative inclusion predicate is an exact geospatial calculation in the POI store.
The H3 resolution table reports that resolution 9 has average cell area about 0.1053 km², but minimum and maximum hexagon areas differ materially. H3 has twelve pentagons at every resolution, and grid traversal APIs document distortion behavior around them. Therefore “resolution 9, k = 1 covers 2 km” is not a valid geometric guarantee.
In an undistorted hex neighborhood, gridDisk has at most 1 + 3k(k + 1) cells. That counts graph cells; it does not turn k into a universal radius in meters. The implementation instead builds a conservative cover of the query circle at the configured resolution, adds a validated boundary margin, and rejects a request that exceeds the fan-out budget. Exact geography distance then decides inclusion.
For PostGIS geography, ST_DWithin takes distance in meters and can use an index bounding-box prefilter. The final distance model (spheroid or documented sphere approximation) is consistent between filtering, ranking and the response.
A query centered elsewhere in the same H3 cell gets a new exact ordering. Candidate caching remains useful without asserting that the cell center equals the user.
[CONCEPT]partitioning-strategiesThe catalog service writes current POI state and an outbox row in one transaction. Each event includes POI id, source version, prior cell (or enough state to resolve it), new cell and tombstone flag. The projector:
This is eventually consistent discovery with source-of-truth verification. An administrative read-after-write endpoint can read the authoritative row and expose projection lag; ordinary search may lag but cannot return a deleted/moved POI after the final hydration check.
Mapbox Vector Tile is a protobuf format for tiled vector data. It does not eliminate the zoom pyramid: clients still request z/x/y, and features are clipped/quantized into each tile's coordinate system. Generalization, attributes, geometry complexity and compression determine size, so the diagram makes no universal “20× smaller” claim.
The cache key includes style version, data version and z/x/y. A deployment can precompute popular zooms and render colder tiles on demand, but it publishes immutable versions and prevents a tile from mixing a style with an incompatible schema. The CDN can keep old versions until active clients age out.
The flow follows the public OSRM distinction between Contraction Hierarchies (CH) and Multi-Level Dijkstra (MLD). OSRM documents that osrm-customize can repeatedly apply segment-speed and turn-penalty updates to a partitioned MLD graph. The design therefore publishes a complete metric snapshot tied to a graph version.
A route worker pins graph and metric versions for the whole request. If a new metric is incomplete or incompatible, it serves the last complete version with freshness metadata or fails according to product policy. It does not calculate a static path and then pretend that changing only its ETA made the path traffic-optimal.
Traffic updates must be validated for impossible speeds, direction, turn identity, source quality and age. Route alternatives and snapping radii are bounded to control worst-case work.
Longitude arithmetic cannot assume a flat interval around ±180°. GeoJSON guidance recommends cutting geometries that cross the antimeridian; an implementation can normalize/split its cover geometry or use a geospatial library whose spherical behavior is explicitly tested. Near poles and H3 pentagons, traversal errors or abnormal fan-out trigger the conservative fallback and budget, never a smaller unchecked candidate set.
All values are deployment inputs, not facts about a global map service:
Measure distributions by latitude, radius, city density, filter, zoom and route distance. Averages conceal dense-city fan-out and long-route tails.
Введите числа или выберите пресет