Skip to content

Commit 545eecb

Browse files
committed
Update README.md
1 parent 62be616 commit 545eecb

File tree

1 file changed

+92
-77
lines changed

1 file changed

+92
-77
lines changed

README.md

Lines changed: 92 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🗂️ Employee Data Management App - Node.js CLI Based
1+
# 🗂️ Employee Data Management App - Node.js + MongoDB CLI
22

33
A feature-rich CLI (Command Line Interface) application for managing employee data using **JavaScript (Node.js)**. This app is a **rewrite and improvement** of my previous project written in **C++**, with added enhancements like bulk input, interactive editing, real file persistence, and modular design.
44

@@ -9,7 +9,7 @@ A feature-rich CLI (Command Line Interface) application for managing employee da
99
This project simulates a basic employee database management system that runs entirely in the terminal. It's designed for learning purposes, suitable for beginner-to-intermediate developers who want to understand:
1010

1111
- How to structure CLI apps in Node.js
12-
- How to manage JSON-file-based data without a database
12+
- How to manage employee data with MongoDB using Mongoose ORM
1313
- How to modularize code and separate logic
1414
- How to mimic real-world HR-like data operations
1515

@@ -20,48 +20,62 @@ This project simulates a basic employee database management system that runs ent
2020
This Node.js project is a **refactored and modernized version** of my previous C++ project:
2121

2222
### 🔁 Rewritten From:
23+
2324
- [Project-Algoritma-Pemrograman](https://github.com/Nekonepan/College/tree/main/C%2B%2B/Project-Algoritma-Pemrograman)
2425

2526
### 🎯 Enhancements Compared to C++ Version:
2627

27-
| Feature | C++ Version | Node.js Version |
28-
|----------------------|-------------------------------|-----------------------------------------------|
29-
| Save to File | ✅ TXT |JSON (Array of Objects) |
30-
| Employee Input | ✅ Manual | ✅ Single & Bulk Input |
31-
| ID / Name Search | ✅ Only by ID | ✅ By ID & Name (with list selection) |
32-
| Edit Data | ❌ None | ✅ Full interactive editing |
33-
| Sort Data | ✅ Yes (no persistence) | ✅ With option to save results to file |
34-
| Table View | ✅ Static | ✅ Dynamic with `console.table()` |
35-
| Input Validation | ❌ Very limited | ✅ Rich & interactive validation |
36-
| Log Deleted Data | ❌ None | ✅ Yes (`logs/deleted-logs.json`) |
37-
| Backup | ❌ None | ✅ Yes (`backup/data-karyawan-backup.json`) |
38-
| Restore | ❌ None | ✅ Yes (from backup file with confirmation) |
28+
| Feature | C++ Version | Node.js Version |
29+
| ---------------- | ----------------------- | ------------------------------------------- |
30+
| Save to File | ✅ TXT |MongoDB via Mongoose |
31+
| Employee Input | ✅ Manual | ✅ Single & Bulk Input |
32+
| ID / Name Search | ✅ Only by ID | ✅ By ID & Name (with list selection) |
33+
| Edit Data | ❌ None | ✅ Full interactive editing |
34+
| Sort Data | ✅ Yes (no persistence) | ✅ With option to save results to file |
35+
| Table View | ✅ Static | ✅ Dynamic with `console.table()` |
36+
| Input Validation | ❌ Very limited | ✅ Rich & interactive validation |
37+
| Log Deleted Data | ❌ None | ✅ Yes (DeletedEmployee collection) |
38+
| Backup | ❌ None | ✅ Built-in via MongoDB timestamps/logs |
39+
| Restore | ❌ None | ✅ Yes (from backup file with confirmation) |
3940

4041
---
4142

4243
## ⚙️ Setup Requirements
4344

44-
- ✅ Node.js installed (v14+ recommended)
45-
- ✅ Basic terminal or command prompt
45+
- ✅ Node.js installed (v20+ recommended)
46+
- ✅ MongoDB Atlas account (free: https://www.mongodb.com/atlas)
47+
- ✅ Basic terminal/command prompt
4648
- ✅ (Optional) Text editor like VS Code
4749

4850
---
4951

5052
## 🚀 How to Run the Project
5153

5254
### 1. **Clone this repository**
55+
5356
```
5457
git clone https://github.com/Nekonepan/Employee-Data-Application-Project-JavaScript-based-node.js.git
5558
cd Employee-Data-Application-Project-JavaScript-based-node.js
5659
```
60+
5761
### 2. **Install dependencies**
62+
5863
```
5964
npm install
6065
```
61-
### 3. **Run the app**
66+
67+
### 3. **Configure MongoDB**
68+
69+
1. Create free account at [MongoDB Atlas](https://www.mongodb.com/atlas/database)
70+
2. Create cluster, get connection string
71+
3. Copy `.env.example` to `.env` and set `MONGO_URI`
72+
73+
### 4. **Run the app**
74+
6275
```
6376
node main.js
6477
```
78+
6579
> 📌 You'll be guided through an interactive menu system.
6680
6781
---
@@ -70,39 +84,40 @@ node main.js
7084

7185
```
7286
|-- main.js # Main application logic
73-
|-- data/
74-
|-- data-karyawan.json # Primary employee data file
75-
|-- backup/
76-
|-- data-karyawan-backup.json # Backup file
77-
|-- logs/
78-
|-- deleted-logs.json # Log of deleted employee data
79-
|-- package.json # Metadata and dependencies
80-
|-- node_modules/ # Installed dependencies
87+
|-- config/
88+
| `-- db.js # MongoDB connection
89+
|-- models/
90+
| |-- Employee.js # Employee schema
91+
| |-- DeletedEmployee.js # Deleted logs schema
92+
| `-- EmployeeLog.js # Audit logs
93+
|-- services/ # Feature services
94+
|-- package.json # Dependencies (mongoose, mongodb, etc.)
95+
|-- .env # MongoDB URI
96+
|-- node_modules/ # Dependencies
8197
```
8298

8399
---
84100

85101
## ✅ Features Implemented
86102

87103
| Feature | Status |
88-
|-------------------------------------------------------|--------|
89-
| Input single & multiple data entries ||
90-
| Edit data with summary & confirmation ||
91-
| Search by ID or Name (list selection if duplicate) ||
92-
| Sort data by ID (ascending/descending, optional save) ||
93-
| Empty field validation & interactive prompts ||
94-
| Confirm before save or restore ||
95-
| Modularized functions per feature ||
96-
| File backup (JSON) & deleted data logging ||
97-
104+
| ----------------------------------------------------- | ------ |
105+
| Input single & multiple data entries ||
106+
| Edit data with summary & confirmation ||
107+
| Search by ID or Name (list selection if duplicate) ||
108+
| Sort data by ID (ascending/descending, optional save) ||
109+
| Empty field validation & interactive prompts ||
110+
| Confirm before save or restore ||
111+
| Modularized functions per feature ||
112+
| MongoDB persistence & audit logging ||
98113

99114
---
100115

101116
## ⚙️ How the App Works
102117

103118
Here’s a simplified breakdown of the logic flow behind the app:
104119

105-
1. 📂 **Program loads existing employee data** from `data-karyawan.json` at startup.
120+
1. 📂 **Program connects to MongoDB Atlas** via Mongoose on startup.
106121
2. 📜 A **main menu** is displayed using `inquirer`, with options like View, Add, Search, Edit, Sort, Statistics, Backup/Restore, and Exit.
107122
3. 📥 When adding data:
108123
- User is asked how many records to add (input `0` = cancel)
@@ -123,75 +138,74 @@ Here’s a simplified breakdown of the logic flow behind the app:
123138
- Show total employee count
124139
- Group employees by job position
125140
- Count employees by ID prefix
126-
8. 📁 Data is stored persistently in **JSON format** for easier read/write operations, backups, and logs.
141+
8. 📁 Data stored in **MongoDB collections** with Mongoose schemas for persistence and auditing.
127142

128143
The application runs in a loop until the user chooses to exit.
129144

130-
131145
---
132146

133-
## 📝 Data Format
147+
## 📝 Data Format (MongoDB Collections)
148+
149+
### Employee Collection (`employees`):
150+
151+
Mongoose schema:
152+
153+
```
154+
ID: { type: String, required: true, unique: true }
155+
NAMA: { type: String, required: true }
156+
JABATAN: { type: String, required: true }
157+
TELP: { type: String, required: true }
158+
timestamps: true // createdAt, updatedAt
159+
```
160+
161+
Data stored as MongoDB documents matching the schema.
162+
163+
### DeletedEmployee Collection (`deletedemployees`):
134164

135-
### Data is stored in the `data-karyawan.json` file with the format:
165+
Mongoose schema:
136166

137167
```
138-
[
139-
{
140-
"ID": "A123",
141-
"NAMA": "Nekonepan",
142-
"JABATAN": "Manager",
143-
"TELP": "081234567890"
144-
},
145-
{
146-
"ID": "B321",
147-
"NAMA": "Lutfan Alaudin",
148-
"JABATAN": "HRD",
149-
"TELP": "080987654321"
150-
}
151-
]
168+
ID: String
169+
NAMA: String
170+
JABATAN: String
171+
TELP: String
172+
deleted_at: { type: Date, default: Date.now }
152173
```
153174

154-
- Data is structured as an array of objects
155-
- Each object represents one employee record
156-
- This format makes it easier to read, write, backup, and restore data
175+
Logs deleted records with timestamp.
157176

158-
### Deleted data is stored in `logs/data-terhapus.json` with the format:
177+
### EmployeeLog Collection (`employeelogs`):
178+
179+
Mongoose schema for change history:
159180

160181
```
161-
[
162-
{
163-
"ID": "H739",
164-
"NAMA": "Farhan Wulandari",
165-
"JABATAN": "Supervisor",
166-
"TELP": "08323250265",
167-
"deletedAt": "2025-08-18T10:30:45.123Z"
168-
}
169-
]
182+
action: { type: String, enum: ["CREATE", "UPDATE", "DELETE"] }
183+
data_before: Object (null for CREATE)
184+
data_after: Object (null for DELETE)
185+
timestamp: { type: Date, default: Date.now }
170186
```
171187

172-
- Each deleted record is logged with the same structure as the main data
173-
- An additional field `"deletedAt"` records the exact time the deletion occurred
188+
Tracks all data modifications.
174189

175190
---
176191

177192
## 📊 Summary & Takeaways
178193

179-
- 🔧 Implemented **modular practices** in a Node.js CLI application
180-
- 💾 Built a **CRUD system without a database**, using JSON file persistence
181-
- 🧠 Focused on **algorithmic logic** and data handling, not UI/Frontend
182-
- 🧰 Migrated from **procedural C++ (TXT storage)** into **modular JavaScript (JSON storage)**
183-
- 📁 Added features: **backup system** and **deletion logs with timestamp**
184-
- ✅ Finished with clean documentation, maintainable structure, and extensible design
194+
- 🔧 Implemented **modular practices** in a Node.js CLI application
195+
- 💾 Built **full CRUD system with MongoDB Atlas** and Mongoose ORM
196+
- 🧠 Focused on **algorithmic logic** and data handling, not UI/Frontend
197+
- 🧰 Migrated from **procedural C++ (TXT storage)** into **modular JavaScript (MongoDB database)**
198+
- ✅ Finished with clean documentation, maintainable structure, and extensible design
185199

186200
---
187201

188202
## 🌱 Potential Future Enhancements
189203

190204
| Development Ideas | Status |
191-
|------------------------------------------|---------|
205+
| ---------------------------------------- | ------- |
192206
| 🔒 Add login system & user access rights | ⏺️ ToDo |
193207
| 🧾 Export employee data to CSV/Excel | ⏺️ ToDo |
194-
| 🌐 Migrate backend to Express + MongoDB | ⏺️ ToDo |
208+
| 🌐 Migrate backend to Express + MongoDB | ✅ Done |
195209
| 🧪 Add unit testing with Jest | ⏺️ ToDo |
196210

197211
> "These are planned features for future versions"
@@ -204,6 +218,7 @@ This project is currently marked as complete but may receive further updates.
204218
Feel free to fork, remix, or use it for your own learning.
205219

206220
If you want to know what the previous version of C++ looked like before it was refactored into Node.js, you can look at these two files:
221+
207222
- [data-karyawan-alpro.cpp](https://github.com/Nekonepan/College/blob/main/C%2B%2B/Project-Algoritma-Pemrograman/Data-Karyawan/data-karyawan-alpro.cpp)
208223
- [data-karyawan-alpro-array2D.cpp](https://github.com/Nekonepan/College/blob/main/C%2B%2B/Project-Algoritma-Pemrograman/Data-Karyawan-2D/data-karyawan-alpro-array2D.cpp)
209224

0 commit comments

Comments
 (0)