The Hindalco Tool Tracking System is a comprehensive real-time web application designed for managing tools, users, and maintenance requests in an industrial environment. The system provides role-based access control, real-time notifications, and complete audit trails.
┌─────────────────────────────────────────────────────────┐
│ Frontend (HTML/JS) │
├─────────────────────────────────────────────────────────┤
│ • User Dashboards (Employee/Manager/Admin) │
│ • Real-time UI Updates (Socket.IO Client) │
│ • Authentication & Authorization │
│ • API Communication │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Backend API (Node.js/Express) │
├─────────────────────────────────────────────────────────┤
│ • RESTful API Endpoints │
│ • JWT Authentication │
│ • Real-time Events (Socket.IO Server) │
│ • Business Logic & Validation │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Database (MongoDB) │
├─────────────────────────────────────────────────────────┤
│ • Users Collection │
│ • Tools Collection │
│ • Tool Requests Collection │
│ • Maintenance Collection │
└─────────────────────────────────────────────────────────┘
Internship_Project/
├── backend/ # Backend API server
│ ├── models/ # Database models
│ │ ├── User.js # User schema
│ │ ├── Tool.js # Tool schema
│ │ ├── ToolRequest.js # Tool request schema
│ │ └── Maintenance.js # Maintenance schema
│ ├── routes/ # API route handlers
│ │ ├── auth.js # Authentication routes
│ │ ├── users.js # User management routes
│ │ ├── tools.js # Tool management routes
│ │ ├── toolRequests.js # Request management routes
│ │ ├── maintenance.js # Maintenance routes
│ │ └── reports.js # Export/backup routes
│ ├── middleware/ # Express middleware
│ │ └── auth.js # JWT authentication middleware
│ ├── server.js # Main server file
│ ├── package.json # Backend dependencies
│ └── .env # Environment variables
├── frontend/ # Frontend web application
│ ├── index.html # Login page
│ ├── register.html # Registration page
│ ├── user_new.html # Employee dashboard
│ ├── manager_new.html # Manager dashboard
│ ├── admin.html # Admin dashboard
│ ├── profile.html # User profile page
│ ├── api.js # API service layer
│ ├── login.js # Authentication logic
│ ├── auth-utils.js # Authentication utilities
│ ├── dashboard-utils.js # Dashboard utilities
│ └── login.css # Styling
├── start-system.bat # Windows startup script
├── SETUP_GUIDE.md # Setup instructions
├── START_SERVERS.md # Server startup guide
└── SYSTEM_DOCUMENTATION.md # This file
Permissions:
Dashboard Features:
Permissions:
Dashboard Features:
Permissions:
Dashboard Features:
1. Employee submits tool request
↓
2. Backend saves request to database
↓
3. Socket.IO broadcasts to Manager/Admin rooms
↓
4. Managers receive real-time notification + audio alert
↓
5. Manager reviews and approves/rejects request
↓
6. Backend updates request status
↓
7. Socket.IO broadcasts update to all users
↓
8. Employee receives real-time status notification
// Client-side events
socket.emit('join-role', userRole); // Join role-based room
socket.emit('new-request', requestData); // New request submitted
socket.emit('request-reviewed', reviewData); // Request reviewed
// Server-side broadcasts
socket.to('Manager').emit('request-created', data); // New request alert
socket.emit('request-updated', data); // Status update
socket.emit('tool-assigned', data); // Tool assignment
socket.emit('maintenance-scheduled', data); // Maintenance scheduled
{
_id: ObjectId,
firstName: String,
lastName: String,
email: String (unique),
password: String (hashed),
role: String ['Admin', 'Manager', 'Employee'],
department: String,
employeeId: String (unique),
phone: String,
isActive: Boolean,
lastLogin: Date,
profileImage: String,
createdAt: Date,
updatedAt: Date
}
{
_id: ObjectId,
name: String,
description: String,
category: String ['Hand Tools', 'Power Tools', 'Measuring Tools', 'Safety Equipment', 'Other'],
brand: String,
model: String,
serialNumber: String (unique),
location: String,
status: String ['Available', 'In Use', 'Maintenance', 'Damaged', 'Lost'],
condition: String ['Excellent', 'Good', 'Fair', 'Poor'],
purchaseDate: Date,
purchasePrice: Number,
assignedTo: ObjectId (ref: User),
assignedDate: Date,
expectedReturnDate: Date,
lastMaintenanceDate: Date,
nextMaintenanceDate: Date,
imageUrl: String,
notes: String,
createdBy: ObjectId (ref: User),
createdAt: Date,
updatedAt: Date
}
{
_id: ObjectId,
requestedBy: ObjectId (ref: User),
tool: ObjectId (ref: Tool),
requestType: String ['borrow', 'return', 'maintenance', 'replacement'],
reason: String,
urgency: String ['low', 'medium', 'high', 'critical'],
expectedDuration: Number, // days
status: String ['pending', 'approved', 'rejected', 'cancelled'],
reviewedBy: ObjectId (ref: User),
reviewedAt: Date,
reviewComments: String,
metadata: Object,
createdAt: Date,
updatedAt: Date
}
{
_id: ObjectId,
tool: ObjectId (ref: Tool),
scheduledBy: ObjectId (ref: User),
assignedTo: ObjectId (ref: User),
maintenanceType: String ['preventive', 'corrective', 'emergency', 'inspection'],
priority: String ['low', 'medium', 'high', 'critical'],
scheduledDate: Date,
estimatedDuration: Number, // hours
description: String,
status: String ['scheduled', 'in-progress', 'completed', 'cancelled', 'overdue'],
actualStartDate: Date,
actualEndDate: Date,
actualDuration: Number,
completionNotes: String,
cost: Number,
partsUsed: [{ partName: String, quantity: Number, cost: Number }],
nextMaintenanceDate: Date,
attachments: [{ filename: String, path: String, uploadedAt: Date }],
createdAt: Date,
updatedAt: Date
}
POST /api/auth/register
- Register new userPOST /api/auth/login
- User loginGET /api/auth/me
- Get current userPUT /api/auth/change-password
- Change passwordGET /api/users
- Get all users (Admin/Manager)GET /api/users/:id
- Get user by IDPUT /api/users/:id
- Update userDELETE /api/users/:id
- Deactivate user (Admin)PUT /api/users/:id/activate
- Activate user (Admin)GET /api/users/stats/dashboard
- Get user statisticsGET /api/tools
- Get all toolsGET /api/tools/:id
- Get tool by IDPOST /api/tools
- Create new tool (Manager/Admin)PUT /api/tools/:id
- Update toolDELETE /api/tools/:id
- Delete tool (Admin/Manager)PUT /api/tools/:id/assign
- Assign/unassign toolGET /api/tool-requests
- Get tool requestsGET /api/tool-requests/:id
- Get request by IDPOST /api/tool-requests
- Create new requestPUT /api/tool-requests/:id/review
- Review request (Manager/Admin)PUT /api/tool-requests/:id/cancel
- Cancel requestGET /api/tool-requests/stats/dashboard
- Get request statisticsGET /api/maintenance
- Get maintenance tasksGET /api/maintenance/:id
- Get maintenance by IDPOST /api/maintenance
- Schedule maintenancePUT /api/maintenance/:id
- Update maintenanceDELETE /api/maintenance/:id
- Delete maintenance (Admin/Manager)GET /api/maintenance/stats/dashboard
- Get maintenance statisticsGET /api/reports/export/:type
- Export data (tools/users/requests/maintenance)POST /api/reports/backup
- Create system backup (Admin)GET /api/reports/dashboard
- Get comprehensive dashboard data// Security middleware implementation
app.use(cors({
origin: process.env.CORS_ORIGIN,
credentials: true
}));
// JWT verification middleware
const authMiddleware = (req, res, next) => {
const token = req.header('Authorization')?.replace('Bearer ', '');
if (!token) return res.status(401).json({ message: 'Access denied' });
try {
const decoded = jwt.verify(token, process.env.JWT_SECRET);
req.user = decoded.user;
next();
} catch (error) {
res.status(401).json({ message: 'Invalid token' });
}
};
# Server Configuration
PORT=5000
NODE_ENV=development
# Database Configuration
MONGODB_URI=mongodb://localhost:27017/tool-tracking
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
# CORS Configuration
CORS_ORIGIN=http://localhost:3000
const mongoConfig = {
useNewUrlParser: true,
useUnifiedTopology: true,
maxPoolSize: 10,
serverSelectionTimeoutMS: 5000,
socketTimeoutMS: 45000,
};
npm install
npm run dev
or use start-system.bat
# Example Dockerfile for backend
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 5000
CMD ["node", "server.js"]
// Health check endpoint
app.get('/health', (req, res) => {
res.json({
status: 'healthy',
timestamp: new Date(),
uptime: process.uptime(),
mongodb: mongoose.connection.readyState === 1 ? 'connected' : 'disconnected'
});
});
1. MongoDB Connection Issues
# Check MongoDB status
mongod --version
mongo --eval "db.adminCommand('ping')"
# Restart MongoDB service
net start MongoDB
2. Socket.IO Connection Problems
// Debug Socket.IO connections
socket.on('connect_error', (error) => {
console.error('Socket.IO connection error:', error);
});
3. Authentication Failures
// Check JWT token validity
const decoded = jwt.decode(token);
console.log('Token expiry:', new Date(decoded.exp * 1000));
// Enable debug logging
localStorage.setItem('debug', 'true');
// Check system status
GET /api/health
The system is considered fully operational when:
This comprehensive system provides a robust, scalable, and user-friendly solution for tool tracking and management in industrial environments.