This project is a real-time location tracking system designed to handle live GPS data from multiple users. The system includes a backend for processing location data and a frontend for displaying the information on an interactive map. The backend can scale to handle at least 500 simultaneous users.
- User Authentication: Secure login and access control using tokens
- Real-Time Tracking: Periodic updates of user locations sent to the server
- Filterable Map: View and filter location logs on an interactive map
- Scalability: Designed to support high concurrency
- Node.js
- Express.js
- PostgreSql
- MongoDB (with Mongoose)
- HTML, CSS, JavaScript
- Leaflet.js (for map rendering)
- GitHub (version control)
- Displays real-time user locations on a map
- Allows filtering by user and date range
- Processes and stores user location data
- Serves location logs to authorized clients
- Stores user details and location logs
- Redis Cache optimizes frequent read operations
Log in using your credentials.
Start location tracking using the "Start Tracking" button.
View real-time locations and logs on the map.
Filter logs by user and date range.
git clone https://github.com/pranj4/location-tracking.git
cd location-trackingnpm installCreate a .env file and add the following:
DB_HOST=localhost
DB_PORT=5432
DB_NAME=tracking
DB_USER=postgres
DB_PASSWORD=iamgame25...
MONGO_URI=mongodb://localhost:27017/tracking_db
JWT_SECRET=passwordnpm run devPostgreSQL
# Create database
CREATE DATABASE locationtracker;
# Create users table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
role VARCHAR(50) DEFAULT 'user'
);MongoDB
Ensure MongoDB is running Collections will be created automatically
Open http://localhost:3000/register.html in any browser.
A basic registration page has been set up
Register as new user or if already registered . Click on login here
-Sign Up / Log In
The user registers an account or logs into the system using their credentials.
Start Tracking
Once authenticated, the user starts tracking their live location by enabling GPS on their device.
The location is periodically sent to the backend.
Stop Tracking
The user can stop tracking their location at any time.
Admin Log In
The admin logs in using an authorized account with elevated privileges.
View All User Locations
The admin accesses a dashboard displaying all active users and their live locations.
Apply Filters
The admin filters user data by date, username, or specific regions on the map.
##API Endpoints
POST /api/auth/register - User registration
POST /api/auth/login - User loginLocation
POST /api/location/track - Send live location
GET /api/location/logs/:userId - Fetch user location logs
GET /api/location/location-logs - Admin: Fetch all location logs-JWT-based authentication -Password hashing -Role-based access control -Input validation -Secure API endpoints
-
Implement database indexing
-
Use connection pooling
-
Optimize query performance
Supported Platforms:
AWS Elastic Beanstalk
Heroku
Vercel
-
Implemented connection pooling
-
Efficient database indexing
-
Minimal payload transfer
-
Integrated logging middleware
-
Error tracking
- Leaflet.js
- Express.js
- PostgreSQL
- MongoDB
- Ensure all environment variables are correctly set
- Check network configurations
- Verify database connections
- Review authentication middleware
- Check browser console for frontend errors








