How darsh-jogi/employee-management-system works
Project Type & Purpose
• This is a full-stack MERN (MongoDB, Express.js, React.js, Node.js) web application named “Employees Management System (EMS).”
• It supports two major user roles: HR professionals and Employees, offering dashboards, attendance/leave/salary management, recruitment tracking, notifications, and email workflows.
File Structure Analysis
• Top level separates “client” (frontend) and “server” (backend).
• Frontend (“client”) uses React with Vite, Redux (Slices & Thunks), Tailwind CSS, and ShadCN UI components.
• Backend (“server”) uses Node.js/Express, follows MVC:
• routes/ → maps HTTP endpoints
• controllers/ → request handlers
• services/ → business logic (light, here mostly models + utils)
• models/ → Mongoose schemas for MongoDB
• middlewares/ → JWT auth & role-based checks
• Config files: .env, Vite config, tailwind.config, connectDB, mailtrap settings.
Key Architectural Patterns
• Frontend: Component-based UI, global state via Redux, asynchronous data fetching via Thunks, client-side routing with React Router.
• Backend: RESTful API, layered MVC, middleware for authentication/authorization, external email service via Mailtrap.
• Security: JWT-based auth, role-based access control (RBAC).
Main Components & Interactions
a. Frontend Components
• Browser / React SPA (AppRoutes, AuthRoutes, protected routes)
• UI Components (ShadCN + Tailwind)
• Redux Store (Slices, AsyncReducers, Thunks)
• API Service module (APIService, APIEndpoints)
b. Backend Components
• Express Server (index.js)
• Route Layer (routes/*.route.js)
• Controller Layer (controllers/*.controller.js)
• Model Layer (models/*.model.js)
• Middleware (Auth.middleware, RoleAuth.middleware)
• Utility Modules (JWT token generator, verification token, mail templates)
• External Service: Mailtrap (email sending)
• Database: MongoDB via Mongoose
c. Data Flows & Relationships
1. User → Browser UI → Redux Action → Thunk → APIService → HTTP Request
2. Express Route → Auth/Role Middleware → Controller → Service/Model → MongoDB
3. Controller → Utility → Mailtrap (for emails)
4. MongoDB → Mongoose → Controller → Response → Frontend Redux → UI