Skip to content

feat(api/globe): GET /globe/data with bbox PostGIS + Redis caching + ETag#47

Merged
gracefullight merged 2 commits intomainfrom
symphony/FIR-35
Mar 21, 2026
Merged

feat(api/globe): GET /globe/data with bbox PostGIS + Redis caching + ETag#47
gracefullight merged 2 commits intomainfrom
symphony/FIR-35

Conversation

@gracefullight
Copy link
Member

Summary

  • Add GET /globe/data?bbox=west,south,east,north endpoint with PostGIS ST_Within spatial queries
  • Returns contacts[] (within bbox), relationships[] (shared-org edges), clusters[] (grid-snapped groups)
  • Redis per-user caching (5min TTL) with SCAN-based invalidation helper for mutation endpoints
  • ETag + If-None-Match support returning 304 Not Modified

Changes

  • Migration 0004: adds location geometry(Point, 4326) column + GIST index to contact table
  • geoalchemy2 dependency added for PostGIS integration
  • src/globe/ module: schemas, repository (PostGIS queries), service (cache + ETag), router

Test plan

  • Run alembic upgrade head to apply migration 0004
  • Verify GET /globe/data?bbox=-180,-90,180,90 returns contacts/relationships/clusters
  • Verify ETag header returned and 304 on matching If-None-Match
  • Verify Redis caching (second request hits cache)
  • Verify cache invalidation via GlobeService.invalidate_user_cache()

🤖 Generated with Claude Code

gracefullight and others added 2 commits March 21, 2026 21:44
…ETag

Add globe data aggregation API endpoint that returns contacts,
relationships (via shared organizations), and clusters within a
geographic bounding box using PostGIS ST_Within queries.

- Add geoalchemy2 dependency for PostGIS integration
- Migration 0004: add location geometry(Point, 4326) column to contact
  table with GIST spatial index
- New globe module with repository (PostGIS queries), service (Redis
  per-user caching with 5min TTL, ETag support), and router
- Contacts clustered via ST_SnapToGrid, relationships derived from
  shared organization experiences
- ETag-based conditional responses (304 Not Modified)
- Cache invalidation helper for mutation endpoints

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts:
#	apps/api/src/contacts/models.py
#	apps/api/src/globe/repository.py
#	apps/api/src/globe/router.py
#	apps/api/src/globe/schemas.py
#	apps/api/src/globe/service.py
#	apps/api/src/main.py
#	apps/api/uv.lock
@gracefullight gracefullight merged commit ca348a9 into main Mar 21, 2026
2 checks passed
@gracefullight gracefullight deleted the symphony/FIR-35 branch March 21, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant