A real-time ride-hailing tracking application demonstrating advanced full-stack concepts including WebSocket bi-directional communication, geospatial data handling, and event-driven architecture.
This project simulates a ride-hailing experience where users can request rides and see drivers moving in real-time on a map. It efficiently handles high-frequency updates using Redis and WebSockets.
- Real-Time Driver Tracking: Drivers' locations update live on the map without refreshing.
- Geospatial Matching: Finds the nearest available driver to the pickup location.
- Event-Driven Updates: Uses WebSockets to push state changes (Ride Accepted, Driver at Pickup, etc.) to the client instantly.
- Simulation Scripts: Includes a script to simulate driver movement and behavior for testing.
- NestJS: Progressive Node.js framework for scalable server-side applications.
- Redis: In-memory data store used for geospatial indexing (
GEOADD,GEORADITUS) and pub/sub. - Socket.io: Enables real-time, bi-directional communication between web clients and servers.
- SQLite: Lightweight SQL database for persisting trip and transaction data (via TypeORM).
- Next.js: React framework for production-grade web applications.
- Leaflet / React-Leaflet: Open-source JavaScript library for interactive maps.
- Tailwind CSS: Utility-first CSS framework for rapid UI development.
- Client (Next.js): Connects to the WebSocket Gateway and listens for
driverMovedandtripUpdateevents. - Dispatcher Service: Handles ride requests, queries Redis for nearby drivers, and manages trip state.
- Redis: Stores ephemeral driver locations and supports fast geospatial queries.
- Driver Simulation: A script mimicking multiple drivers moving across the map and responding to job assignments.
- Node.js (v18+)
- Redis Server (Running locally or remotely)
- NPM or Yarn
-
Clone the repository
git clone https://github.com/thoraf20/realtime-tracker.git cd realtime-tracker -
Backend Setup
cd backend npm install cp .env.example .env # Update REDIS_URL in .env if needed
-
Frontend Setup
cd ../frontend npm install
-
Start the Backend
cd backend npm run start:devThe server will start on
http://localhost:3000. -
Start the Frontend
cd frontend npm run devThe application will be available at
http://localhost:3001(or usually 3000/3001 depending on port availability). -
Simulate Drivers To see the real-time tracking in action, run the driver simulation script:
cd backend npx ts-node scripts/simulate_drivers.tsYou should see drivers appearing and moving on the map!
This project is licensed under the MIT License.