create-nodemin-app 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/bin/cli.js +82 -0
  2. package/package.json +25 -0
  3. package/templates/HRMS_Mongodb/README.md +331 -0
  4. package/templates/HRMS_Mongodb/backend/.env.example +6 -0
  5. package/templates/HRMS_Mongodb/backend/package-lock.json +1646 -0
  6. package/templates/HRMS_Mongodb/backend/package.json +26 -0
  7. package/templates/HRMS_Mongodb/backend/src/config/db.js +9 -0
  8. package/templates/HRMS_Mongodb/backend/src/controllers/authController.js +187 -0
  9. package/templates/HRMS_Mongodb/backend/src/controllers/departmentController.js +70 -0
  10. package/templates/HRMS_Mongodb/backend/src/controllers/employeeController.js +178 -0
  11. package/templates/HRMS_Mongodb/backend/src/controllers/positionController.js +66 -0
  12. package/templates/HRMS_Mongodb/backend/src/middleware/auth.js +57 -0
  13. package/templates/HRMS_Mongodb/backend/src/middleware/errorHandler.js +32 -0
  14. package/templates/HRMS_Mongodb/backend/src/middleware/restrictToAdmin.js +5 -0
  15. package/templates/HRMS_Mongodb/backend/src/middleware/validate.js +13 -0
  16. package/templates/HRMS_Mongodb/backend/src/models/Department.js +19 -0
  17. package/templates/HRMS_Mongodb/backend/src/models/Employee.js +81 -0
  18. package/templates/HRMS_Mongodb/backend/src/models/Position.js +19 -0
  19. package/templates/HRMS_Mongodb/backend/src/models/User.js +40 -0
  20. package/templates/HRMS_Mongodb/backend/src/routes/authRoutes.js +27 -0
  21. package/templates/HRMS_Mongodb/backend/src/routes/departmentRoutes.js +33 -0
  22. package/templates/HRMS_Mongodb/backend/src/routes/employeeRoutes.js +39 -0
  23. package/templates/HRMS_Mongodb/backend/src/routes/positionRoutes.js +32 -0
  24. package/templates/HRMS_Mongodb/backend/src/server.js +74 -0
  25. package/templates/HRMS_Mongodb/backend/src/utils/roles.js +5 -0
  26. package/templates/HRMS_Mongodb/backend/src/utils/seed.js +78 -0
  27. package/templates/HRMS_Mongodb/backend/src/validators/authValidator.js +61 -0
  28. package/templates/HRMS_Mongodb/backend/src/validators/departmentValidator.js +21 -0
  29. package/templates/HRMS_Mongodb/backend/src/validators/employeeValidator.js +27 -0
  30. package/templates/HRMS_Mongodb/backend/src/validators/positionValidator.js +26 -0
  31. package/templates/HRMS_Mongodb/frontend/index.html +19 -0
  32. package/templates/HRMS_Mongodb/frontend/package-lock.json +2812 -0
  33. package/templates/HRMS_Mongodb/frontend/package.json +25 -0
  34. package/templates/HRMS_Mongodb/frontend/public/favicon.svg +4 -0
  35. package/templates/HRMS_Mongodb/frontend/src/App.jsx +50 -0
  36. package/templates/HRMS_Mongodb/frontend/src/api/axios.js +54 -0
  37. package/templates/HRMS_Mongodb/frontend/src/components/ProtectedRoute.jsx +26 -0
  38. package/templates/HRMS_Mongodb/frontend/src/components/layout/DashboardLayout.jsx +16 -0
  39. package/templates/HRMS_Mongodb/frontend/src/components/layout/Sidebar.jsx +108 -0
  40. package/templates/HRMS_Mongodb/frontend/src/components/ui/Button.jsx +33 -0
  41. package/templates/HRMS_Mongodb/frontend/src/components/ui/Input.jsx +20 -0
  42. package/templates/HRMS_Mongodb/frontend/src/components/ui/Modal.jsx +48 -0
  43. package/templates/HRMS_Mongodb/frontend/src/components/ui/Select.jsx +27 -0
  44. package/templates/HRMS_Mongodb/frontend/src/context/AuthContext.jsx +97 -0
  45. package/templates/HRMS_Mongodb/frontend/src/index.css +34 -0
  46. package/templates/HRMS_Mongodb/frontend/src/main.jsx +16 -0
  47. package/templates/HRMS_Mongodb/frontend/src/pages/Dashboard.jsx +78 -0
  48. package/templates/HRMS_Mongodb/frontend/src/pages/Departments.jsx +144 -0
  49. package/templates/HRMS_Mongodb/frontend/src/pages/Employees.jsx +297 -0
  50. package/templates/HRMS_Mongodb/frontend/src/pages/LeaveReport.jsx +113 -0
  51. package/templates/HRMS_Mongodb/frontend/src/pages/Login.jsx +92 -0
  52. package/templates/HRMS_Mongodb/frontend/src/pages/Positions.jsx +157 -0
  53. package/templates/HRMS_Mongodb/frontend/src/pages/Register.jsx +93 -0
  54. package/templates/HRMS_Mongodb/frontend/src/pages/ResetPassword.jsx +135 -0
  55. package/templates/HRMS_Mongodb/frontend/src/utils/roles.js +1 -0
  56. package/templates/HRMS_Mongodb/frontend/src/utils/session.js +5 -0
  57. package/templates/HRMS_Mongodb/frontend/src/utils/validation.js +66 -0
  58. package/templates/HRMS_Mongodb/frontend/vite.config.js +16 -0
  59. package/templates/HRMS_Mysql/backend/db.js +13 -0
  60. package/templates/HRMS_Mysql/backend/package-lock.json +1614 -0
  61. package/templates/HRMS_Mysql/backend/package.json +21 -0
  62. package/templates/HRMS_Mysql/backend/server.js +421 -0
  63. package/templates/HRMS_Mysql/frontend/dist/assets/index-CtLtQf3_.js +75 -0
  64. package/templates/HRMS_Mysql/frontend/dist/assets/index-Dq1AXlEY.css +1 -0
  65. package/templates/HRMS_Mysql/frontend/dist/index.html +14 -0
  66. package/templates/HRMS_Mysql/frontend/dist/vite.svg +1 -0
  67. package/templates/HRMS_Mysql/frontend/index.html +13 -0
  68. package/templates/HRMS_Mysql/frontend/package-lock.json +2978 -0
  69. package/templates/HRMS_Mysql/frontend/package.json +25 -0
  70. package/templates/HRMS_Mysql/frontend/postcss.config.js +6 -0
  71. package/templates/HRMS_Mysql/frontend/public/vite.svg +1 -0
  72. package/templates/HRMS_Mysql/frontend/src/App.jsx +55 -0
  73. package/templates/HRMS_Mysql/frontend/src/api.js +11 -0
  74. package/templates/HRMS_Mysql/frontend/src/components/Layout.jsx +59 -0
  75. package/templates/HRMS_Mysql/frontend/src/index.css +7 -0
  76. package/templates/HRMS_Mysql/frontend/src/main.jsx +13 -0
  77. package/templates/HRMS_Mysql/frontend/src/pages/Dashboard.jsx +45 -0
  78. package/templates/HRMS_Mysql/frontend/src/pages/Departments.jsx +108 -0
  79. package/templates/HRMS_Mysql/frontend/src/pages/EmployeeStatusReport.jsx +72 -0
  80. package/templates/HRMS_Mysql/frontend/src/pages/Employees.jsx +252 -0
  81. package/templates/HRMS_Mysql/frontend/src/pages/ForgotPassword.jsx +66 -0
  82. package/templates/HRMS_Mysql/frontend/src/pages/Login.jsx +79 -0
  83. package/templates/HRMS_Mysql/frontend/src/pages/Positions.jsx +109 -0
  84. package/templates/HRMS_Mysql/frontend/src/pages/Register.jsx +95 -0
  85. package/templates/HRMS_Mysql/frontend/src/pages/Users.jsx +133 -0
  86. package/templates/HRMS_Mysql/frontend/tailwind.config.js +26 -0
  87. package/templates/HRMS_Mysql/frontend/vite.config.js +15 -0
  88. package/templates/HRMS_Mysql/hrms_schema.sql +57 -0
package/bin/cli.js ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const readline = require("readline");
6
+ const { execSync } = require("child_process");
7
+
8
+ // Create interface
9
+ const rl = readline.createInterface({
10
+ input: process.stdin,
11
+ output: process.stdout
12
+ });
13
+
14
+ console.log("\nSelect project to create:\n");
15
+ console.log("1. HRMS_Mongdb(human resource Management System)");
16
+ console.log("1. HRMS_Mysql(human resource Management System)");
17
+
18
+
19
+ // Ask user
20
+ rl.question("Enter your choice: ", (choice) => {
21
+
22
+ let templateName = "";
23
+ let projectName = "";
24
+
25
+ switch (choice) {
26
+ case "1":
27
+ templateName = "HRMS_Mongodb";
28
+ projectName = "hrms-app";
29
+ break;
30
+ case "2":
31
+ templateName = "HRMS_Mysql";
32
+ projectName = "hrms-app";
33
+ break;
34
+
35
+
36
+
37
+ default:
38
+ console.log(" Invalid choice");
39
+ rl.close();
40
+ return;
41
+ }
42
+
43
+ const targetPath = path.join(process.cwd(), projectName);
44
+ const templatePath = path.resolve(__dirname, "../templates", templateName);
45
+
46
+ if (!fs.existsSync(templatePath)) {
47
+ console.log(" Template not found:", templatePath);
48
+ rl.close();
49
+ return;
50
+ }
51
+
52
+ if (fs.existsSync(targetPath)) {
53
+ console.log(` Folder "${projectName}" already exists`);
54
+ rl.close();
55
+ return;
56
+ }
57
+
58
+ try {
59
+ // Create folder
60
+ fs.mkdirSync(targetPath, { recursive: true });
61
+
62
+ // Copy template
63
+ fs.cpSync(templatePath, targetPath, { recursive: true });
64
+
65
+ console.log(`\n ${projectName} created successfully!`);
66
+ console.log(" Location:", targetPath);
67
+
68
+ // Install dependencies (IMPORTANT for npx usability)
69
+ console.log("\n Installing dependencies...\n");
70
+ execSync(`cd ${targetPath} && npm install`, { stdio: "inherit" });
71
+
72
+ console.log("\n Setup complete!");
73
+ console.log(`\n Run your project:`);
74
+ console.log(` cd ${projectName}`);
75
+ console.log(` npm run dev\n`);
76
+
77
+ } catch (error) {
78
+ console.log(" Error:", error.message);
79
+ }
80
+
81
+ rl.close();
82
+ });
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+
2
+ {
3
+ "name": "create-nodemin-app",
4
+ "version": "1.0.16",
5
+ "description": "",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "create-nodemin-app": "./bin/cli.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "templates"
13
+ ],
14
+ "scripts": {
15
+ "test": "echo \"Error: no test specified\" && exit 1"
16
+ },
17
+ "keywords": [
18
+ "cli",
19
+ "scaffold",
20
+ "generator"
21
+ ],
22
+ "author": "akk",
23
+ "license": "ISC",
24
+ "type": "commonjs"
25
+ }
@@ -0,0 +1,331 @@
1
+ # DAB Enterprise LTD — Human Resource Management System (HRMS)
2
+
3
+ Web-based HRMS for **DAB Enterprise LTD** (Kigali City, Rwanda) — building tools and construction materials. Built with the **MERN stack**: MongoDB, Express.js, React.js, Node.js.
4
+
5
+ **TSS National Integrated Assessment 2025-2026**
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - Employee, Department, and Position CRUD
12
+ - JWT authentication with **protected API routes**
13
+ - **Input sanitization** (XSS strip, `express-mongo-sanitize`, Helmet, rate limiting)
14
+ - **Server-side** validation (`express-validator`) and **client-side** form validation
15
+ - **Reset password** by employee email (no Nodemailer — password reset instantly with temporary password shown on screen)
16
+ - Dashboard with workforce statistics
17
+ - Modern UI with **Tailwind CSS v4** and React 18
18
+
19
+ ---
20
+
21
+ ## Folder structure
22
+
23
+ ```
24
+ dab-enterprise-hrms/
25
+ ├── README.md
26
+ ├── .gitignore
27
+
28
+ ├── backend/
29
+ │ ├── package.json
30
+ │ ├── .env.example
31
+ │ ├── .env
32
+ │ └── src/
33
+ │ ├── server.js
34
+ │ ├── config/
35
+ │ │ └── db.js
36
+ │ ├── models/
37
+ │ │ ├── Department.js
38
+ │ │ ├── Position.js
39
+ │ │ ├── Employee.js
40
+ │ │ └── User.js
41
+ │ ├── middleware/
42
+ │ │ ├── auth.js
43
+ │ │ ├── validate.js
44
+ │ │ └── errorHandler.js
45
+ │ ├── validators/
46
+ │ │ ├── authValidator.js
47
+ │ │ ├── employeeValidator.js
48
+ │ │ ├── departmentValidator.js
49
+ │ │ └── positionValidator.js
50
+ │ ├── controllers/
51
+ │ │ ├── authController.js
52
+ │ │ ├── employeeController.js
53
+ │ │ ├── departmentController.js
54
+ │ │ └── positionController.js
55
+ │ ├── routes/
56
+ │ │ ├── authRoutes.js
57
+ │ │ ├── employeeRoutes.js
58
+ │ │ ├── departmentRoutes.js
59
+ │ │ └── positionRoutes.js
60
+ │ └── utils/
61
+ │ └── seed.js
62
+
63
+ └── frontend/
64
+ ├── package.json
65
+ ├── vite.config.js
66
+ ├── index.html
67
+ ├── public/
68
+ │ └── favicon.svg
69
+ └── src/
70
+ ├── main.jsx
71
+ ├── App.jsx
72
+ ├── index.css
73
+ ├── api/
74
+ │ └── axios.js
75
+ ├── context/
76
+ │ └── AuthContext.jsx
77
+ ├── utils/
78
+ │ └── validation.js
79
+ ├── components/
80
+ │ ├── ProtectedRoute.jsx
81
+ │ ├── layout/
82
+ │ │ ├── Sidebar.jsx
83
+ │ │ └── DashboardLayout.jsx
84
+ │ └── ui/
85
+ │ ├── Button.jsx
86
+ │ ├── Input.jsx
87
+ │ ├── Select.jsx
88
+ │ └── Modal.jsx
89
+ └── pages/
90
+ ├── Login.jsx
91
+ ├── ResetPassword.jsx
92
+ ├── Dashboard.jsx
93
+ ├── Employees.jsx
94
+ ├── Departments.jsx
95
+ └── Positions.jsx
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Entity Relationship Diagram (ERD)
101
+
102
+ ### Entities and attributes
103
+
104
+ | Entity | Attributes |
105
+ |--------|------------|
106
+ | **Employee** | EmpFirstName, EmpLastName, EmpEmail, EmpTelephone, EmpGender, EmpAddress, EmpDateOfBirth, EmpHireDate, EmpStatus |
107
+ | **Department** | DepartName |
108
+ | **Position** | PosName, RequiredQualification |
109
+ | **User** | UserName, Password |
110
+
111
+ ### Relationships
112
+
113
+ 1. **Department — Employee** (1 : N)
114
+ One department has many employees; each employee belongs to exactly one department.
115
+
116
+ 2. **Position — Employee** (1 : N)
117
+ One position can be held by many employees; each employee has exactly one position.
118
+
119
+ 3. **Employee — User** (1 : 1)
120
+ A user is also an employee; each user account links to one employee record.
121
+
122
+ ### ERD diagram (Mermaid)
123
+
124
+ ```mermaid
125
+ erDiagram
126
+ DEPARTMENT ||--o{ EMPLOYEE : "has many"
127
+ POSITION ||--o{ EMPLOYEE : "has many"
128
+ EMPLOYEE ||--|| USER : "is also"
129
+
130
+ DEPARTMENT {
131
+ ObjectId _id PK
132
+ string departName
133
+ datetime createdAt
134
+ datetime updatedAt
135
+ }
136
+
137
+ POSITION {
138
+ ObjectId _id PK
139
+ string posName
140
+ string requiredQualification
141
+ datetime createdAt
142
+ datetime updatedAt
143
+ }
144
+
145
+ EMPLOYEE {
146
+ ObjectId _id PK
147
+ string empFirstName
148
+ string empLastName
149
+ string empEmail UK
150
+ string empTelephone
151
+ string empGender
152
+ string empAddress
153
+ date empDateOfBirth
154
+ date empHireDate
155
+ string empStatus
156
+ ObjectId department FK
157
+ ObjectId position FK
158
+ datetime createdAt
159
+ datetime updatedAt
160
+ }
161
+
162
+ USER {
163
+ ObjectId _id PK
164
+ string userName UK
165
+ string password
166
+ ObjectId employee FK UK
167
+ datetime createdAt
168
+ datetime updatedAt
169
+ }
170
+ ```
171
+
172
+ ### ASCII ERD
173
+
174
+ ```
175
+ ┌─────────────────┐ ┌─────────────────┐
176
+ │ DEPARTMENT │ │ POSITION │
177
+ ├─────────────────┤ ├─────────────────┤
178
+ │ PK _id │ │ PK _id │
179
+ │ departName │ │ posName │
180
+ └────────┬────────┘ │ requiredQual │
181
+ │ 1 └────────┬────────┘
182
+ │ │ 1
183
+ │ N │ N
184
+ ▼ ▼
185
+ ┌─────────────────────────────────────────────┐
186
+ │ EMPLOYEE │
187
+ ├─────────────────────────────────────────────┤
188
+ │ PK _id │
189
+ │ empFirstName, empLastName, empEmail │
190
+ │ empTelephone, empGender, empAddress │
191
+ │ empDateOfBirth, empHireDate, empStatus │
192
+ │ FK department, FK position │
193
+ └────────────────────┬────────────────────────┘
194
+ │ 1
195
+ │ 1
196
+
197
+ ┌─────────────┐
198
+ │ USER │
199
+ ├─────────────┤
200
+ │ PK _id │
201
+ │ userName │
202
+ │ password │
203
+ │ FK employee │
204
+ └─────────────┘
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Prerequisites
210
+
211
+ - [Node.js](https://nodejs.org/) 18+
212
+ - [MongoDB](https://www.mongodb.com/) running locally (or MongoDB Atlas URI in `.env`)
213
+
214
+ ---
215
+
216
+ ## Installation and run
217
+
218
+ ### 1. Backend
219
+
220
+ ```bash
221
+ cd backend
222
+ npm install
223
+ cp .env.example .env
224
+ npm run seed
225
+ npm run dev
226
+ ```
227
+
228
+ API: `http://localhost:5000`
229
+
230
+ ### 2. Frontend
231
+
232
+ ```bash
233
+ cd frontend
234
+ npm install
235
+ npm run dev
236
+ ```
237
+
238
+ App: `http://localhost:5173`
239
+
240
+ ---
241
+
242
+ ## Default login (after seed)
243
+
244
+ | Field | Value |
245
+ |-------|--------|
246
+ | Username | `admin` |
247
+ | Password | `Admin@123` |
248
+
249
+ **Reset password test email:** `jean.uwimana@dabenterprise.rw`
250
+ Default temporary password after reset: `Reset@12345` (configurable in `backend/.env`)
251
+
252
+ ---
253
+
254
+ ## API endpoints
255
+
256
+ | Method | Endpoint | Auth | Description |
257
+ |--------|----------|------|-------------|
258
+ | POST | `/api/auth/login` | No | Login |
259
+ | POST | `/api/auth/register` | No | Register user for employee |
260
+ | POST | `/api/auth/reset-password` | No | Reset by employee email |
261
+ | GET | `/api/auth/me` | Yes | Current user |
262
+ | GET/POST | `/api/employees` | Yes | List / create employees |
263
+ | GET/PUT/DELETE | `/api/employees/:id` | Yes | Employee by ID |
264
+ | GET | `/api/employees/stats` | Yes | Dashboard stats |
265
+ | GET/POST | `/api/departments` | Yes | Departments |
266
+ | GET/PUT/DELETE | `/api/departments/:id` | Yes | Department by ID |
267
+ | GET/POST | `/api/positions` | Yes | Positions |
268
+ | GET/PUT/DELETE | `/api/positions/:id` | Yes | Position by ID |
269
+
270
+ ---
271
+
272
+ ## Security
273
+
274
+ - JWT bearer tokens on protected routes
275
+ - `bcryptjs` password hashing
276
+ - `helmet`, CORS, rate limiting
277
+ - `express-mongo-sanitize` + custom HTML tag stripping
278
+ - `express-validator` on all mutating endpoints
279
+ - React protected routes via `ProtectedRoute` + axios 401 interceptor
280
+
281
+ ---
282
+
283
+ ## Tech stack
284
+
285
+ | Layer | Technology |
286
+ |-------|------------|
287
+ | Database | MongoDB + Mongoose |
288
+ | API | Node.js, Express.js |
289
+ | Frontend | React 18, Vite, React Router 7 |
290
+ | Styling | Tailwind CSS v4 (`@tailwindcss/vite`) |
291
+ | Auth | JSON Web Tokens |
292
+
293
+ ---
294
+
295
+ ## License
296
+
297
+ Educational project — DAB Enterprise LTD HRMS assessment.
298
+
299
+
300
+ This diagram treats your entire DAB Enterprise HRMS as a single central process, showing exactly how information flows between the core system and your two main external actors (Employee and HR Admin).
301
+
302
+ Level 0 Context Diagram
303
+ [ EMPLOYEE / STAFF ]
304
+ / \
305
+ Login Credentials / \ Auth Token, Profile Details,
306
+ Password Reset Data / \ Status Toast Alerts
307
+ v \
308
+ +----------------------------------+
309
+ | |
310
+ | PROCESS 0 |
311
+ | |
312
+ | DAB Enterprise HRMS |
313
+ | |
314
+ +----------------------------------+
315
+ ^ /
316
+ Employee Profiles, \ / Workforce Directory,
317
+ Dept & Position Config\ / System Audits & Logs
318
+ \ v
319
+ [ HR MANAGER / ADMIN ]
320
+ Key Data Elements in this Diagram
321
+ The Core Process (0): Represents your entire Node.js/Express backend, MERN stack logic, and MongoDB databases bundled into one single boundary line.
322
+
323
+ Employee Flows: * Inflow: Sends data into the system to verify identity (login) or request credential updates (resetPassword).
324
+
325
+ Outflow: Receives profile details back from the server (getMe) and interactive UI alerts via your frontend state.
326
+
327
+ HR Admin Flows:
328
+
329
+ Inflow: Sends structured operational data to build the organization (employeeRoutes, departmentRoutes, positionRoutes).
330
+
331
+ Outflow: Receives data streams from the server to populate administrative dashboards and data tables.
@@ -0,0 +1,6 @@
1
+ PORT=5000
2
+ MONGODB_URI=mongodb://127.0.0.1:27017/dab_hrms
3
+ JWT_SECRET=your_super_secret_jwt_key_change_in_production
4
+ JWT_EXPIRE=7d
5
+ DEFAULT_RESET_PASSWORD=Reset@12345
6
+ CLIENT_URL=http://localhost:5173