Full-stack MERN project implementing employee leave requests, manager approvals, and admin user/role management.
- Frontend (Vercel): https://employee-leave-management-system-fr.vercel.app/
- Backend API (Render): https://employee-leave-management-system-backend-4s8y.onrender.com/
- Health Check: https://employee-leave-management-system-backend-4s8y.onrender.com/api/health
- Frontend: React + Tailwind CSS
- Routing: React Router
- State Management: Context API
- Backend: Node.js + Express
- Database: MongoDB + Mongoose
- Authentication: JWT
- Authorization: Role-based access control (
admin,manager,employee)
- JWT login/register
- Protected routes on frontend and backend
- Role-based dashboards
- Leave application form
- Leave approval/rejection workflow
- Leave status tracking (
pending,approved,rejected) - Admin user CRUD and role assignment
- Request validation and error handling
employee-leave-management/
backend/
src/
config/
controllers/
middleware/
models/
routes/
seeder/
utils/
validators/
frontend/
src/
api/
components/
context/
pages/
cd backend
npm install
cp .env.example .envSet values in .env:
MONGO_URIJWT_SECRET- optional
JWT_EXPIRES_IN
Run backend:
npm run devOptional seed admin:
npm run seed:admincd frontend
npm install
cp .env.example .env
npm run devDefault API URL:
VITE_API_BASE_URL=http://localhost:5000/api
- Admin:
admin@company.com/Admin@123(if seeded) - Employee/Manager: Create via register/admin panel
POST /api/auth/registerPOST /api/auth/loginGET /api/auth/mePOST /api/leavesGET /api/leaves/myGET /api/leaves/summary/myGET /api/leaves/review-queuePATCH /api/leaves/:id/statusGET /api/users(admin)POST /api/users(admin)PATCH /api/users/:id/role(admin)DELETE /api/users/:id(admin)
Deploy backend and frontend separately for best reliability.
- Create a new Web Service from
backend/. - Set build command:
npm install - Set start command:
npm start - Add environment variables:
PORTis auto-provided by Render (do not hardcode in Render env)MONGO_URI=<your mongo connection string>JWT_SECRET=<strong random secret>JWT_EXPIRES_IN=1dCORS_ORIGIN=<your frontend URL>(for multiple origins, separate by comma)ADMIN_EMAIL=<optional>ADMIN_PASSWORD=<optional>
- Deploy and verify health endpoint:
https://<your-backend-domain>/api/health
- Create a new project from
frontend/. - Build command:
npm run build - Output directory:
dist - Add environment variable:
VITE_API_BASE_URL=https://<your-backend-domain>/api
- Deploy.
Notes:
frontend/vercel.jsonis included so React routes like/adminand/employee/historywork after refresh on Vercel.- Frontend API client now supports env-based URL and defaults to
/apiifVITE_API_BASE_URLis not set.
- Open frontend URL and register/login.
- Verify role-based pages load.
- Create a leave request and review it from manager account.
- Check browser Network tab for
401/CORS errors. - If CORS errors appear, update backend
CORS_ORIGINto exactly match your deployed frontend domain.