Skip to content

This project tracks active users on a webpage using Socket.io and Express.js, storing their IP addresses and socket IDs. It provides real-time user count updates and an API to fetch current users. Ideal for monitoring online presence dynamically and efficiently. πŸš€

Notifications You must be signed in to change notification settings

RyomenDev/Real-time-Tracking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ Real-Time User Tracking with Socket.io

This project tracks active users on a page in real-time using Express, Socket.io, and React. Each connected user's IP address is saved along with their socket ID, and the count of online users is updated dynamically.

πŸš€ Features

  • Real-time user tracking with WebSockets
  • Stores IP address of connected users
  • Live updates on the frontend
  • API to get active users
  • Handles user disconnects properly

πŸ› οΈ Tech Stack

  • Backend: Node.js, Express, Socket.io
  • Frontend: React, WebSockets

πŸ“‚ Installation & Setup

1️⃣ Clone the repository

git clone https://github.com/your-username/repo-name.git
cd repo-name

2️⃣ Install dependencies

# Install backend dependencies
cd server
npm install

# Install frontend dependencies
cd client
npm install

3️⃣ Start the servers

# Start backend (Express & Socket.io)
cd server
node index.js

# Start frontend (React)
cd client
npm start

πŸ–₯️ Backend: Express + Socket.io

πŸ”Ή Server Code (server.js)


🎨 Frontend: React + WebSockets

πŸ”Ή React Component (PageTracker.js)


πŸ“‘ API Endpoints

Method Endpoint Description
GET /api/current-users Get list of active users

πŸ”₯ Expected Output

Console Logs (Backend)

User connected: abc123 from IP: 192.168.1.10
User connected: xyz456 from IP: 192.168.1.11
User disconnected: abc123

UI on Frontend

πŸ“Œ Users on this Page
2 users online

1. IP: 192.168.1.10
2. IP: 192.168.1.11

🎯 Future Improvements

βœ… Store user data in Redis for scalability
βœ… Use GeoIP API to display location info
βœ… Add user authentication for tracking logged-in users


πŸ“ License

This project is licensed under the MIT License.


🀝 Contributing

Feel free to submit issues or pull requests!

πŸ”— GitHub Repository: repo-link

About

This project tracks active users on a webpage using Socket.io and Express.js, storing their IP addresses and socket IDs. It provides real-time user count updates and an API to fetch current users. Ideal for monitoring online presence dynamically and efficiently. πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published