Project Overview
HomeTracker is a real-time location-sharing web application that tracks live coordinates and calculates predictive ETAs for family members.
Families need a reliable, private way to know when members will arrive home without constant manual text updates. Standard location sharing only shows a dot on a map; it doesn't actively predict arrival times based on routing data or custom curfews.
Rather than relying on basic straight-line distance, the application calculates realistic time-to-arrival using the Open Source Routing Machine (OSRM) API. It queries bike-route geometry to account for pedestrian paths and shortcuts unavailable to cars. To make the ETA realistic, the system applies a 1.35x buffer factor plus two minutes to account for crosswalks and intersections. To ensure high availability, if the external OSRM API times out or fails, the engine gracefully degrades to a local Haversine formula calculation. This fallback computes the straight-line distance, applies a 1.4x road factor penalty, and assumes a 12 km/h average pace. This guarantees an ETA is always returned without interrupting the live dashboard feed.
Next.js (React) was chosen for its API routes, allowing the backend location logic and frontend dashboard to live in a single edge-compatible codebase. Turso (libSQL) was selected over traditional Postgres for its serverless architecture, keeping latency low when querying live location state. OSRM was chosen over the Google Maps API to avoid usage costs while getting accurate non-vehicular routing geometry. GSAP was used instead of standard CSS transitions to handle complex, chained micro-animations on the real-time map dashboard.
Deploying Next.js API routes on serverless environments caused connection timeouts because Turso defaults to persistent WebSockets, which stateless functions don't support well. I solved this by writing a connection interceptor that detects the environment and downgrades the protocol to HTTPS, forcing stateless HTTP requests and eliminating timeout errors. Additionally, constant GPS coordinate updates from multiple family members were hammering the OSRM endpoint and causing UI lag. I implemented a time-based client-side caching layer that memoizes ETA calculations for 30 seconds per user. This reduced external network requests by over 80% while keeping the map responsive.