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.
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:
- How to structure CLI apps in Node.js
- How to manage employee data with MongoDB using Mongoose ORM
- How to modularize code and separate logic
- How to mimic real-world HR-like data operations
This Node.js project is a refactored and modernized version of my previous C++ project:
| Feature | C++ Version | Node.js Version |
|---|---|---|
| Save to File | ✅ TXT | ✅ MongoDB via Mongoose |
| Employee Input | ✅ Manual | ✅ Single & Bulk Input |
| ID / Name Search | ✅ Only by ID | ✅ By ID & Name (with list selection) |
| Edit Data | ❌ None | ✅ Full interactive editing |
| Sort Data | ✅ Yes (no persistence) | ✅ With option to save results to file |
| Table View | ✅ Static | ✅ Dynamic with console.table() |
| Input Validation | ❌ Very limited | ✅ Rich & interactive validation |
| Log Deleted Data | ❌ None | ✅ Yes (DeletedEmployee collection) |
| Backup | ❌ None | ✅ Built-in via MongoDB timestamps/logs |
| Restore | ❌ None | ✅ Yes (from backup file with confirmation) |
- ✅ Node.js installed (v20+ recommended)
- ✅ MongoDB Atlas account (free: https://www.mongodb.com/atlas)
- ✅ Basic terminal/command prompt
- ✅ (Optional) Text editor like VS Code
git clone https://github.com/Nekonepan/Employee-Data-Application-Project-JavaScript-based-node.js.git
cd Employee-Data-Application-Project-JavaScript-based-node.js
npm install
- Create free account at MongoDB Atlas
- Create cluster, get connection string
- Copy
.env.exampleto.envand setMONGO_URI
node main.js
📌 You'll be guided through an interactive menu system.
|-- main.js # Main application logic
|-- config/
| `-- db.js # MongoDB connection
|-- models/
| |-- Employee.js # Employee schema
| |-- DeletedEmployee.js # Deleted logs schema
| `-- EmployeeLog.js # Audit logs
|-- services/ # Feature services
|-- package.json # Dependencies (mongoose, mongodb, etc.)
|-- .env # MongoDB URI
|-- node_modules/ # Dependencies
| Feature | Status |
|---|---|
| Input single & multiple data entries | ✅ |
| Edit data with summary & confirmation | ✅ |
| Search by ID or Name (list selection if duplicate) | ✅ |
| Sort data by ID (ascending/descending, optional save) | ✅ |
| Empty field validation & interactive prompts | ✅ |
| Confirm before save or restore | ✅ |
| Modularized functions per feature | ✅ |
| MongoDB persistence & audit logging | ✅ |
Here’s a simplified breakdown of the logic flow behind the app:
- 📂 Program connects to MongoDB Atlas via Mongoose on startup.
- 📜 A main menu is displayed using
inquirer, with options like View, Add, Search, Edit, Sort, Statistics, Backup/Restore, and Exit. - 📥 When adding data:
- User is asked how many records to add (input
0= cancel) - Each input is validated (non-empty, unique ID)
- Data is optionally saved after confirmation
- User is asked how many records to add (input
- 🔍 When searching:
- User can search by ID or Name (case-insensitive, partial match supported)
- If multiple results are found (e.g., duplicate names), a list is displayed to select the correct record
- ✏️ When editing:
- User selects data from search results (by ID or Name)
- Empty inputs are ignored (retain original value)
- A summary table is shown after edit
- Confirmation is required before saving
- 🔃 When sorting:
- User can choose Ascending or Descending by ID
- Sorted result can be saved or discarded
- 📊 Statistics:
- Show total employee count
- Group employees by job position
- Count employees by ID prefix
- 📁 Data stored in MongoDB collections with Mongoose schemas for persistence and auditing.
The application runs in a loop until the user chooses to exit.
Mongoose schema:
ID: { type: String, required: true, unique: true }
NAMA: { type: String, required: true }
JABATAN: { type: String, required: true }
TELP: { type: String, required: true }
timestamps: true // createdAt, updatedAt
Data stored as MongoDB documents matching the schema.
Mongoose schema:
ID: String
NAMA: String
JABATAN: String
TELP: String
deleted_at: { type: Date, default: Date.now }
Logs deleted records with timestamp.
Mongoose schema for change history:
action: { type: String, enum: ["CREATE", "UPDATE", "DELETE"] }
data_before: Object (null for CREATE)
data_after: Object (null for DELETE)
timestamp: { type: Date, default: Date.now }
Tracks all data modifications.
- 🔧 Implemented modular practices in a Node.js CLI application
- 💾 Built full CRUD system with MongoDB Atlas and Mongoose ORM
- 🧠 Focused on algorithmic logic and data handling, not UI/Frontend
- 🧰 Migrated from procedural C++ (TXT storage) into modular JavaScript (MongoDB database)
- ✅ Finished with clean documentation, maintainable structure, and extensible design
| Development Ideas | Status |
|---|---|
| 🔒 Add login system & user access rights | ⏺️ ToDo |
| 🧾 Export employee data to CSV/Excel | ⏺️ ToDo |
| 🌐 Migrate backend to Express + MongoDB | ✅ Done |
| 🧪 Add unit testing with Jest | ⏺️ ToDo |
"These are planned features for future versions"
This project is currently marked as complete but may receive further updates. Feel free to fork, remix, or use it for your own learning.
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:
This project started as a simple C++ console app and has now evolved into a more modular, maintainable, and interactive CLI application using JavaScript and Node.js. It was built as a personal learning project, but it’s fully functional and easy to expand.
Whether you're here to learn, improve it, or just curious, thank you for stopping by!
If you like this project or find it useful, feel free to:
- ⭐ Star the repository
- 🛠️ Fork it and build your own version
- 📬 Reach out for questions or collaboration