Skip to content

Commit 739ba4f

Browse files
committed
docs: update README to reflect JSON data management and new features
1 parent 1918e65 commit 739ba4f

File tree

1 file changed

+108
-62
lines changed

1 file changed

+108
-62
lines changed

README.md

Lines changed: 108 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -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 text-file-based data without a database
12+
- How to manage JSON-file-based data without a database
1313
- How to modularize code and separate logic
1414
- How to mimic real-world HR-like data operations
1515

@@ -22,17 +22,28 @@ This Node.js project is a **refactored and modernized version** of my previous C
2222
### 🔁 Rewritten From:
2323
- [Project-Algoritma-Pemrograman](https://github.com/Nekonepan/College/tree/main/C%2B%2B/Project-Algoritma-Pemrograman)
2424

25-
### 🎯 Enhancements Compared to C++ version:
26-
| Feature | C++ Version | Node.js Version |
27-
|-------------------------------|-------------------------------|----------------------------------|
28-
| Save to File | ✅ TXT | ✅ TXT |
29-
| Employee Input | ✅ Manual | ✅ Multi-input |
30-
| ID / Name Search | ✅ (Just ID) | ✅ ID & Name |
31-
| Edit Data | ❌ None | ✅ Yes |
32-
| Sort Data | ✅ Yes (Without Saving Data) | ✅ With Saving Data |
33-
| Table View | ✅ Fixed | ✅ Flexible with console.table() |
34-
| Input Validation | ❌ Limited | ✅ Interactive |
35-
| Backup / Log | ❌ None | ✅ Yes (Folder `logs/`) |
25+
### 🎯 Enhancements Compared to C++ Version:
26+
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) |
39+
40+
---
41+
42+
## ⚙️ Setup Requirements
43+
44+
- ✅ Node.js installed (v14+ recommended)
45+
- ✅ Basic terminal or command prompt
46+
- ✅ (Optional) Text editor like VS Code
3647

3748
---
3849

@@ -52,104 +63,139 @@ npm install
5263
node main.js
5364
```
5465
> 📌 You'll be guided through an interactive menu system.
55-
56-
---
57-
58-
## ⚙️ Setup Requirements
59-
60-
- ✅ Node.js installed (v14+ recommended)
61-
- ✅ Basic terminal or command prompt
62-
- ✅ (Optional) Text editor like VS Code
6366
6467
---
6568

6669
## 📂 Folder Structure
6770

6871
```
69-
├── main.js # Main application logic
70-
├── data-karyawan.txt # Primary employee data file
71-
├── backup/ # Folder for backups
72-
├── logs/ # Log of deleted or modified data
73-
├── package.json # Metadata and dependencies
74-
└── node_modules/ # Installed dependencies
72+
|-- 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
7581
```
7682

7783
---
7884

7985
## ✅ Features Implemented
8086

81-
| Feature | Status |
82-
| ----------------------------------|----------|
83-
| Input multiple data entries ||
84-
| Edit data with confirmation ||
85-
| Search by ID or Name ||
86-
| Sort (ascending/descending by ID) ||
87-
| Empty field validation & format ||
88-
| Confirm before save ||
89-
| Modular functions per feature ||
90-
| File backup & logging ||
87+
| 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+
9198

9299
---
93100

94101
## ⚙️ How the App Works
95102

96103
Here’s a simplified breakdown of the logic flow behind the app:
97104

98-
1. 📂 **Program loads existing employee data** from `data-karyawan.txt` at startup.
99-
2. 📜 A **main menu** is displayed using `inquirer`, with options like View, Add, Search, Edit, Sort, and Exit.
105+
1. 📂 **Program loads existing employee data** from `data-karyawan.json` at startup.
106+
2. 📜 A **main menu** is displayed using `inquirer`, with options like View, Add, Search, Edit, Sort, Statistics, Backup/Restore, and Exit.
100107
3. 📥 When adding data:
101-
- User is asked how many records to add
102-
- Each input is validated (non-empty, phone format, unique ID)
108+
- User is asked how many records to add (input `0` = cancel)
109+
- Each input is validated (non-empty, unique ID)
103110
- Data is optionally saved after confirmation
104111
4. 🔍 When searching:
105112
- User can search by ID or Name (case-insensitive, partial match supported)
113+
- If multiple results are found (e.g., duplicate names), a list is displayed to select the correct record
106114
5. ✏️ When editing:
107-
- User selects the data to edit
115+
- User selects data from search results (by ID or Name)
108116
- Empty inputs are ignored (retain original value)
117+
- A summary table is shown after edit
109118
- Confirmation is required before saving
110119
6. 🔃 When sorting:
111120
- User can choose Ascending or Descending by ID
112121
- Sorted result can be saved or discarded
113-
7. 📁 Data is stored persistently in text format with `|` separators
122+
7. 📊 Statistics:
123+
- Show total employee count
124+
- Group employees by job position
125+
- Count employees by ID prefix
126+
8. 📁 Data is stored persistently in **JSON format** for easier read/write operations, backups, and logs.
114127

115128
The application runs in a loop until the user chooses to exit.
116129

130+
117131
---
118132

119133
## 📝 Data Format
120134

121-
Data is stored in the `data-karyawan.txt` file with the format:
122-
```
123-
ID|NAMA|JABATAN|TELP
135+
Data is stored in the `data-karyawan.json` file with the format:
136+
137+
```json
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+
]
124152
```
125153

126-
Example:
127-
```
128-
A123|Nekonepan|Manager|081234567890
129-
B321|Lutfan Alaudin|HRD|080987654321
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
157+
158+
Deleted data is stored in `logs/data-terhapus.json` with the format:
159+
160+
```json
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+
]
130170
```
131171

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
174+
132175
---
133176

134177
## 📊 Summary & Takeaways
135178

136-
- 🔧 Implementing modular practices in JavaScript CLI
137-
- 💾 Simulating a CRUD system without a database
138-
- 🧠 Focusing on algorithmic logic, not UI
139-
- 🧰 Migrating from procedural C++ to modular JavaScript
140-
- ✅ Finished with clean documentation and structure
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)****modular JavaScript (JSON storage)**
183+
- 📁 Added features: **backup system** and **deletion logs with timestamp**
184+
- ✅ Finished with clean documentation, maintainable structure, and extensible design
141185

142186
---
143187

144188
## 🌱 Potential Future Enhancements
145189

146-
| Development Ideas | Status |
147-
|-----------------------------------------|---------|
148-
| 🔒 Login & user access rights | ⏺️ ToDo |
149-
| 🧾 Export data to CSV or JSON | ⏺️ ToDo |
150-
| 🌐 Migrate to Express + MongoDB API | ⏺️ ToDo |
151-
| 📦 Create CLI global package via `npm` | ⏺️ ToDo |
152-
| 🧪 Unit testing (Jest) | ⏺️ ToDo |
190+
| Development Ideas | Status |
191+
|------------------------------------------|---------|
192+
| 🔒 Add login system & user access rights | ⏺️ ToDo |
193+
| 🧾 Export employee data to CSV/Excel | ⏺️ ToDo |
194+
| 🌐 Migrate backend to Express + MongoDB | ⏺️ ToDo |
195+
| 📦 Publish as a global CLI via `npm` | ⏺️ ToDo |
196+
| 🧪 Add unit testing with Jest | ⏺️ ToDo |
197+
198+
> "These are planned features for future versions"
153199
154200
---
155201

@@ -176,4 +222,4 @@ If you like this project or find it useful, feel free to:
176222
- 🛠️ Fork it and build your own version
177223
- 📬 Reach out for questions or collaboration
178224

179-
# Happy coding! 💻✨
225+
# Happy coding! 💻✨

0 commit comments

Comments
 (0)