This is the backend server for the Realtime Device Tracker application. It provides real-time tracking of devices using a Node.js server with WebSockets (socket.io) for real-time communication and Express for handling HTTP requests. The server integrates with a Leaflet-based frontend for rendering maps and displaying tracked devices.
- Real-time device tracking using WebSockets (
socket.io). - Backend server with RESTful API endpoints for device data.
- Integration with Leaflet.js for map rendering and tracking devices on the frontend.
- Scalable backend architecture using Express.js and Node.js.
- Node.js: Server-side JavaScript runtime.
- Express: Web framework for building the backend.
- Socket.io: For real-time, bidirectional communication between the client and server.
- Leaflet.js: JavaScript library for interactive maps (used in frontend).
- EJS: Embedded JavaScript templating engine (for serving views).
Before running this project, make sure you have the following installed:
-
Clone the repository:
git clone https://github.com/Explore13/Realtime-Device-Tracker-Backend.git cd Realtime-Device-Tracker-Backend -
Install dependencies: Make sure you are in the project root directory and install the required dependencies using npm:
npm install
-
Set up environment variables (Optional): Create a
.envfile in the project root to configure environment variables, such as port or database credentials (if applicable).
-
Start the server: To run the server on
localhost, use the following command:npm start
-
Access the app: Open your browser and navigate to
http://localhost:3000. The backend will start on port 3000 (or whichever port you set in the environment). -
Real-time tracking: Open multiple browser windows to test real-time tracking of devices on the map.
The server communicates with clients via WebSocket (Socket.io) events.
connection: When a new user connects to the server.send-location: Clients emit this event when they send their latitude and longitude data.receive-location: The server emits this event with the user’s ID and location details to all connected clients.disconnect: When a user disconnects from the server.
Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-branch). - Create a pull request.
Thank You Everyone :)