This is a real-time location tracking application using Node.js, Socket.io, and Leaflet Maps. It uses Generated Persistent IDs to identify devices, meaning you can track your phone even if it's stolen, provided you have saved your unique Device ID.
- Real-time Tracking: Uses HTML5 Geolocation to stream location data.
- Persistent IDs: Auto-generates a unique ID (e.g.,
X9Z-23A) on first visit. - Stolen Phone Recovery: If you know your ID, you can track your device remotely.
- PostgreSQL Integration: Logs active sessions (optional).
-
Install Dependencies:
npm install
-
Run Server:
node server.js
-
Open Application:
- Go to
http://localhost:3000on your phone (or simulator). - Click Start Sharing Location.
- Note down the Device ID.
- Open
http://localhost:3000on another device. - Enter the ID and click Start Tracking.
- Go to
This app is ready for Railway.app.
Upload this code to a GitHub repository.
- Log in to Railway Dashboard.
- Click New Project -> Deploy from GitHub repo.
- Select your repository.
- Click Deploy Now.
To log device sessions persistently:
- In your Railway project view, right-click (or click "New") -> Database -> Add PostgreSQL.
- Railway will automatically set the
DATABASE_URLenvironment variable for your app. - Redeploy the app (it usually auto-deploys).
- The server will now connect to the DB and create the
sessionstable automatically.
- Go to your App service settings.
- Under Networking, click Generate Domain.
- You now have a public URL (e.g.,
phone-tracker-production.up.railway.app) to share with your devices.