Video summary
[Backend Project 🚀] Realtime Device track | Map with node.js express and socket.io | Maps | Leaflet
Main summary
Key takeaways
What the video builds (Realtime “device tracking” map)
- A backend real-time tracker similar to food delivery live-rider tracking (Swiggy/Zomato-style).
- Two devices are tracked on a map, with rider/device positions updating in real time.
- When a device moves, the map updates the marker position.
- When a device disconnects or closes the browser, that device’s marker is removed immediately.
Key tech stack / libraries used
- Node.js + Express
- Server setup and routing.
- Socket.IO
- Real-time, bi-directional communication between browser and backend.
- EJS
- Templating engine to serve the frontend page.
- Leaflet (open-source map library) + OpenStreetMap tiles
- Leaflet CSS/JS loaded via CDN (or local files).
- Map displayed using
L.map,setView, andtileLayer.
Frontend (browser) features / tutorial logic
-
Uses the Geolocation API:
- Checks whether
navigator.geolocationexists (browser support). - Uses
watchPosition()to continuously track movement. - Requests location with:
enableHighAccuracy: truetimeout: 5000msmaximumAge: 0(avoid cached positions)
- Checks whether
-
On every location update:
- Extracts latitude and longitude from the watch callback.
- Emits a Socket.IO event:
send locationwith{ latitude, longitude }.
-
Leaflet map rendering:
- Initializes the map centered at default coordinates (initially near
0,0until real data arrives). - Sets a zoom level (example shown around 15).
- Creates/updates markers per device using an in-memory
markersobject keyed by socket ID.
- Initializes the map centered at default coordinates (initially near
Marker behavior
- If marker exists for the device (socket ID) → update position
- Else → create marker and add it to the map
- On disconnect → remove marker layer and delete marker from
markers
Backend (Socket.IO) features / tutorial logic
- Socket.IO server created from the Express HTTP server:
- Uses the
socket.io(server)pattern.
- Uses the
- Handles client connection:
- Uses the socket’s unique ID
socket.idas the device identifier.
- Uses the socket’s unique ID
- Receives location updates from clients:
- Listens for
send location - Broadcasts to all clients with event:
receive location - Payload includes:
id(socket ID)latitude/longitude(plus related data via spread/operator)
- Listens for
- Handles disconnections:
- Listens for
disconnect - Broadcasts event:
user disconnectedwith the disconnectedsocket.id - Frontend removes the corresponding marker.
- Listens for
Project setup steps mentioned (guide-like)
- Create a project folder and run
npm init -y. - Create
app.js(entry file). - Install dependencies:
express,ejs,socket.io
- Express basics:
- Set EJS view engine.
- Serve static files from a
publicfolder.
- Frontend structure:
views/index.ejspublic/js/script.js- CSS in
public/css/(e.g., full-width/full-height styling for the map container)
Key tutorial “learning focus” emphasized
- Teaching Socket.IO realtime handling, including:
- emitting events from the frontend (
send location) - listening and broadcasting on the backend
- updating map markers without page reloads
- cleaning up marker state when a client disconnects
- emitting events from the frontend (
Main speakers / sources
- Speaker: Harsh Vandana Sharma
- Technical sources / integrated technologies:
- Leaflet (OpenStreetMap-based map)
- Socket.IO
- Node.js
- Express
- EJS
- HTML5 Geolocation API
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.