X Marks the Spot is a phone-configured “adventure compass”:
- A mobile web app (phone) configures a trip and streams GPS location.
- A laptop-hosted server (Next.js + WebSockets) plans destinations (Gemini + Google Maps) and computes navigation guidance.
- An ESP32 device streams telemetry (IMU heading, temp/humidity, button) and receives commands (calibrate, pointer angle, display fields).
- Install deps:
npm install
- Configure API keys (optional but recommended):
cp .env.example .env- Set
GOOGLE_MAPS_API_KEYandGEMINI_API_KEY - Without keys, the server falls back to “demo” destinations and waypoint guidance.
- Run locally:
npm run dev
- Open on your phone (same Wi‑Fi as laptop):
http://<your-laptop-ip>:3000
- (Optional) Run the simulated ESP32:
http://<your-laptop-ip>:3000/device-sim
Some mobile browsers (notably iOS Safari) require HTTPS for reliable geolocation.
- Generate a self-signed cert (includes
localhost+127.0.0.1by default):scripts/generate-dev-cert.sh --ip <your-laptop-ip>
- Enable HTTPS:
XMS_HTTPS=1 XMS_HTTPS_KEY_PATH=certs/xms-dev.key.pem XMS_HTTPS_CERT_PATH=certs/xms-dev.cert.pem npm run dev
- Open:
https://<your-laptop-ip>:3000
Note: self-signed certs may need to be installed/trusted on your phone; if that’s painful, consider using mkcert for a locally-trusted dev cert.
This repo supports two device connection topologies:
Have the ESP32 open a WebSocket to:
ws://<your-laptop-ip>:3000/ws/device
Run the server with:
npm run dev -- --esp32-url ws://<esp32-ip>:<port>
When --esp32-url is set, inbound connections to /ws/device are rejected (to avoid two active device sockets).
You can also set ESP32_URL in .env instead of passing --esp32-url.
- Physically point the device toward true north (as best you can).
- Tap Calibrate in the Trip screen.
npm test
docs/PRD.MDdocs/IMPLEMENTATION_PLAN.MDdocs/ESP32_OUTPUT_SCHEMA.MD