2 Commits

Author SHA1 Message Date
d22d451c69 Add observer location awareness to chat widget
Progressive enhancement chain: GeoIP auto-detect -> browser GPS ->
manual entry -> works without any location. When set, the observer
coordinates are injected into chat requests so the LLM can answer
"Where is Jupiter?" with actual azimuth/elevation from the user's
location instead of placeholder coordinates.

Backend:
- GeoIP service (MaxMind GeoLite2-City) with lazy init, private IP
  filtering, and IPv4-mapped IPv6 unwrapping
- GET /api/geolocate endpoint (sync to avoid blocking event loop on
  mmap I/O, rightmost X-Forwarded-For for Caddy trust chain)
- ObserverContext model on both chat endpoints with shared
  _observer_prefix() helper that sanitizes label against prompt
  injection

Frontend:
- Location bar between header and messages with pin icon, GPS button,
  edit/clear controls, and inline manual entry parser (accepts
  "40.7N 74.0W", decimal lat/lon, pg_orrery observer format)
- GeoIP auto-detect on first visit, localStorage persistence
- Observer coordinates sent with every chat request

Infrastructure:
- api-data volume for GeoIP database, Caddy handle_4 for /api/geolocate
- update_geoip.sh using MaxMind Basic auth (key stays out of ps/proc)
2026-03-01 23:34:14 -07:00
317f74b33b Add search backend: FastAPI + FastMCP + pgvector for docs Q&A and live SQL
Search stack replicates the Hamilton site pattern with pg_orrery-specific
additions:

- FastAPI REST API (chat SSE streaming, semantic search, health check)
- FastMCP server at /mcp with doc search and live SQL query tools
- pgvector + pgai vectorizer for 1024-dim document embeddings
- Hybrid search (semantic cosine + text ILIKE with pg_trgm GIN)
- Dual LLM backend: self-hosted qwen3 via GPU gateway or Anthropic Claude
- Live read-only pg_orrery SQL execution with safety guardrails
  (SELECT-only validation, read-only transaction, 5s timeout, 100-row cap)
- Convenience MCP tools: planet_position, sky_survey, satellite_pass
- MDX content ingestion from docs/src/content/docs/ (50 pages)
- Docker Compose: pg_orrery+pgvector DB, pgai, vectorizer-worker, API
- Alembic async migrations, Makefile, .env.example
2026-03-01 15:42:14 -07:00