A full-stack web application built with the MERN stack (MongoDB, Express.js, React.js, Node.js) that automates employee scheduling, simplifies shift management, and streamlines communication between managers and employees.
- Secure JWT-based authentication
- Two user roles: Admin/Manager & Employee
- Role-based access control for all operations
- Add, edit, and delete employee profiles
- Store employee details (name, department, designation, contact info)
- Employee availability settings for smarter shift assignments
- Create different shift types (Morning, Afternoon, Night, Custom)
- Intelligent conflict detection prevents:
- Overlapping shifts
- Double-shifts
- Assignments during unavailable hours
- Assignments during approved leave
- Interactive calendar with drag-and-drop functionality
- Color-coded shift visualization
- Interactive calendar UI with Day/Week/Month views
- Visual shift planning with color-coded blocks
- Clear overview of staffing levels
- Employee leave request submission
- Manager approval/rejection workflow
- Automatic conflict detection with shift assignments
- Leave calendar integration
- Employee-initiated shift swap requests
- Two-step approval process (Employee β Manager)
- Automatic availability and role compatibility validation
- Real-time shift updates upon approval
- In-app notifications for:
- New shift assignments
- Shift updates or cancellations
- Leave approval/rejection
- Swap request status updates
- Real-time notification updates
- Manager dashboard with comprehensive analytics
- Employee performance tracking
- Shift distribution charts
- Weekly/monthly trend analysis
- React.js - UI framework
- React Router - Navigation
- Context API - State management
- Axios - HTTP client
- React Big Calendar - Calendar component
- Recharts - Data visualization
- Lucide React - Icons
- Tailwind CSS - Styling
- Moment.js - Date handling
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication
- bcryptjs - Password hashing
- CORS - Cross-origin requests
shift/
βββ client/ # React frontend
β βββ public/
β βββ src/
β β βββ components/ # Reusable components
β β βββ context/ # Context providers
β β βββ pages/ # Page components
β β βββ App.jsx # Main app component
β β βββ main.jsx # Entry point
β βββ package.json
β βββ vite.config.js
βββ server/ # Node.js backend
β βββ config/ # Database configuration
β βββ controllers/ # Route controllers
β βββ middleware/ # Custom middleware
β βββ models/ # Mongoose models
β βββ routes/ # API routes
β βββ server.js # Server entry point
β βββ package.json
βββ start.bat # Startup script
- Node.js (v14 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd shift
-
Install server dependencies
cd server npm install -
Install client dependencies
cd ../client npm install -
Environment Setup
Server (.env)
PORT=5000 MONGO_URI=mongodb://127.0.0.1:27017/shiftmaster JWT_SECRET=your_jwt_secret_key
Client (.env)
VITE_API_URL=http://localhost:5000
-
Start MongoDB
- Local:
mongod - Or use MongoDB Atlas connection string
- Local:
-
Run the application
Option 1: Use the startup script (Windows)
start.bat
Option 2: Manual startup
# Terminal 1 - Backend cd server npm run dev # Terminal 2 - Frontend cd client npm run dev
-
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Register as an Admin
- Create employees in the Employee List page
- Assign shifts using the Schedule page
- Manage leave requests in the Leaves section
- Approve shift swaps in the Swaps section
- Monitor analytics on the Dashboard
- Register as an Employee
- View your schedule on the My Schedule page
- Request leave in the My Leaves section
- Request shift swaps with colleagues
- Check notifications for updates
- View your dashboard for personal analytics
POST /api/auth/register- Register userPOST /api/auth/login- Login userPOST /api/auth/create-employee- Create employee (Admin)
GET /api/users- Get employeesPUT /api/users/:id- Update employeeDELETE /api/users/:id- Delete employee
GET /api/shifts- Get shiftsGET /api/shifts/all- Get all shifts (for swaps)POST /api/shifts- Create shift
GET /api/leaves- Get leave requestsPOST /api/leaves- Create leave requestPUT /api/leaves/:id- Update leave status
GET /api/swaps- Get swap requestsPOST /api/swaps- Create swap requestPUT /api/swaps/:id/accept- Accept swap (Employee)PUT /api/swaps/:id/reject- Reject swap (Employee)PUT /api/swaps/:id/approve- Approve swap (Manager)PUT /api/swaps/:id/manager-reject- Reject swap (Manager)
GET /api/notifications- Get notificationsPUT /api/notifications/:id/read- Mark as readPOST /api/notifications- Create notification
The system automatically prevents scheduling conflicts by checking:
- Existing shift overlaps
- Employee availability windows
- Approved leave periods
- Department compatibility for swaps
- Employee Response: Target employee accepts/rejects
- Manager Approval: Admin approves/rejects accepted swaps
- Automatic Execution: Shifts are swapped in the database
- Automatic notifications for all major actions
- Role-based notification filtering
- In-app notification center
- Mobile-friendly interface
- Adaptive layouts for all screen sizes
- Touch-friendly calendar interactions
- JWT token-based authentication
- Password hashing with bcrypt
- Role-based access control
- Input validation and sanitization
- CORS protection
- Environment variable protection
- Set environment variables
- Update MONGO_URI for production database
- Deploy server code
- Update VITE_API_URL to production backend URL
- Build and deploy client code
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.
For support and questions:
- Create an issue in the repository
- Check the documentation
- Review the API endpoints
- Email/SMS notifications
- Data export (Excel/PDF)
- Advanced analytics
- Mobile app
- Integration with HR systems
- Automated shift generation
- Time tracking integration
ShiftMaster - Simplifying workforce management, one shift at a time! π