A comprehensive Employee Management System prototype built with the MERN stack (MongoDB, Express, React, Node.js).
This is a full-stack application designed for managing employees, tracking attendance, and handling leave requests. It features a modern admin dashboard with a responsive design and clean user interface.
employee-management-system/
├── frontend/ # React application
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── App.jsx # Main app component
│ │ └── index.css # Global styles
│ ├── package.json # Frontend dependencies
│ ├── vite.config.js # Vite configuration
│ └── tailwind.config.js # Tailwind CSS config
│
└── backend/ # Node.js + Express API
├── models/ # MongoDB schemas
│ ├── Employee.js
│ ├── Attendance.js
│ └── Leave.js
├── routes/ # API routes
│ ├── employeeRoutes.js
│ ├── attendanceRoutes.js
│ └── leaveRoutes.js
├── server.js # Express server
├── package.json # Backend dependencies
└── .env.example # Environment variables template
- React 18 - UI library
- Vite - Build tool (fast development experience)
- Tailwind CSS - Utility-first CSS framework
- React Router - Client-side routing
- Lucide React - Icon library
- Axios - HTTP client
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - ODM (Object Data Modeling)
- CORS - Cross-Origin Resource Sharing
- dotenv - Environment variable management
- Login page with email and password
- Role-based access control (ready for implementation)
- Overview of key metrics:
- Total employees
- Number of departments
- Attendance today
- Pending leave requests
- Recent activities feed
- Quick action buttons
- Department-wise employee distribution
- View all employees in a table format
- Search employees by name, email, or department
- Add new employees with complete details
- Edit employee information
- Delete employees (soft delete)
- View employee details modal
Employee Fields:
- Name, Email, Phone
- Department (Engineering, Sales, HR, Marketing, Operations, Finance)
- Role, Salary
- Joining Date, Address
- Mark attendance for employees
- View attendance records with status
- Filter by date and employee
- Attendance status options: Present, Absent, Leave
- Daily attendance summary
- Submit leave requests with reason
- Leave types: Casual, Sick, Earned, Unpaid
- Approval workflow: Pending → Approved/Rejected
- View all leave requests
- Filter by status (Pending, Approved, Rejected)
- Add remarks when approving/rejecting
- Notification preferences
- Email alerts
- Two-factor authentication setup
- Password management
- Account settings
- Collapsible sidebar navigation
- Responsive navbar with user profile
- Mobile-friendly design
- Modern gradient styling
- Smooth animations and transitions
Ensure you have the following installed:
- Node.js (v16 or higher)
- npm or yarn
- MongoDB (local installation or MongoDB Atlas cloud)
-
Navigate to backend directory:
cd backend -
Install dependencies:
npm install
-
Create a
.envfile (copy from.env.example):cp .env.example .env
-
Update
.envwith your MongoDB URI:PORT=5000 MONGODB_URI=mongodb://localhost:27017/employee-managementFor MongoDB Atlas (Cloud):
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/employee-management -
Start the server:
npm run dev # For development with auto-reload # or npm start # For production
Server will run on
http://localhost:5000
-
Navigate to frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
Application will be available at
http://localhost:3000 -
To build for production:
npm run build
GET /api/employees # Get all employees
GET /api/employees/:id # Get single employee
POST /api/employees # Create new employee
PUT /api/employees/:id # Update employee
DELETE /api/employees/:id # Delete employee (soft delete)
GET /api/employees/stats/department # Get employees by department
GET /api/attendance # Get all attendance records
GET /api/attendance/date/:date # Get attendance for specific date
POST /api/attendance # Mark attendance
PUT /api/attendance/:id # Update attendance
GET /api/attendance/summary/date/:date # Get attendance summary
GET /api/leaves # Get all leave requests
GET /api/leaves/:id # Get single leave request
POST /api/leaves # Create leave request
PUT /api/leaves/:id # Update leave request (approve/reject)
DELETE /api/leaves/:id # Delete leave request
GET /api/leaves/status/pending # Get pending leave requests
{
name: String,
email: String (unique),
phone: String,
department: String (enum),
role: String,
salary: Number,
joiningDate: Date,
address: String,
status: String (default: 'active'),
createdAt: Date,
updatedAt: Date
}{
employeeId: ObjectId (ref: Employee),
date: Date,
status: String ('Present', 'Absent', 'Leave'),
remarks: String,
createdAt: Date,
updatedAt: Date
}{
employeeId: ObjectId (ref: Employee),
fromDate: Date,
toDate: Date,
reason: String,
leaveType: String ('Casual', 'Sick', 'Earned', 'Unpaid'),
status: String ('Pending', 'Approved', 'Rejected'),
approvedBy: ObjectId (ref: Employee),
remarks: String,
createdAt: Date,
updatedAt: Date
}Currently, the frontend uses mock data for demonstration. To integrate with the backend:
- Replace mock data with API calls using axios
- Update component state management
- Add error handling and loading states
- User authentication with JWT
- Role-based access control (Admin, Manager, Employee)
- Email notifications
- Report generation
- Salary management
- Performance reviews
- Payroll system
- Employee directory
- Document management
- Integration with HR policies
- Use environment variables for sensitive data
- Implement proper error handling and validation
- Add request rate limiting
- Set up HTTPS
- Configure CORS properly
- Add database indexing for performance
- Implement caching strategies
- Hash passwords before storing (backend ready with bcryptjs)
- Implement JWT for API authentication
- Use HTTPS in production
- Validate all inputs on both frontend and backend
- Implement CORS restrictions
- Add rate limiting to prevent abuse
- Sanitize user inputs
- Use environment variables for sensitive data
- Ensure MongoDB is running locally:
mongod - Check MongoDB Atlas connection string
- Verify network access in MongoDB Atlas
- Backend:
lsof -i :5000andkill -9 <PID> - Frontend:
lsof -i :3000andkill -9 <PID>
- Run
npm installin both frontend and backend directories - Clear node_modules and reinstall:
rm -rf node_modules && npm install
- Email: admin@example.com
- Password: password
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For issues or questions, please contact the development team.
# Start MongoDB (if running locally)
mongod
# In one terminal - Start Backend
cd backend
npm install
npm run dev
# In another terminal - Start Frontend
cd frontend
npm install
npm run devThen open http://localhost:3000 in your browser.
Project Status: Development/Prototype Phase ✅ Last Updated: March 2024