-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Lutfan Alaudin Naja edited this page Apr 1, 2026
·
1 revision
- Overview
- Project Structure
- Setup Guide
- Usage Instructions
- Features
- Database Schema
- Code Architecture
- Development
- Troubleshooting
- License
This is a CLI (Command Line Interface) application for managing employee data built with Node.js and MongoDB. It's a modern rewrite of a previous C++ project with enhanced features like bulk input, interactive editing, MongoDB persistence, and audit logging.
Key Technologies:
- Node.js (v20+)
- MongoDB Atlas + Mongoose ORM
- Inquirer.js for interactive CLI
- Modular service-based architecture
Employee-Data-Application-Project-JavaScript-based-node.js/
├── main.js # Main CLI entrypoint & menu
├── config/
│ └── db.js # MongoDB connection
├── models/ # Mongoose schemas
│ ├── Employee.js
│ ├── DeletedEmployee.js # Soft delete logs
│ └── EmployeeLog.js # Audit trail
├── services/ # Feature modules
│ ├── show-data.js
│ ├── add-data.js
│ ├── search-data.js
│ ├── edit-data.js
│ ├── delete-data.js
│ ├── sort-data.js
│ └── show-statistic.js
├── .env # MongoDB URI
├── package.json
├── README.md
└── LICENSE (MIT)
- Node.js ≥ 20.x
- MongoDB Atlas account (free tier)
- Git (optional)
# 1. Clone the repository
git clone https://github.com/Nekonepan/Employee-Data-Application-Project-JavaScript-based-node.js.git
cd Employee-Data-Application-Project-JavaScript-based-node.js
# 2. Install dependencies
npm install
# 3. Setup MongoDB Atlas
# a. Create free account at mongodb.com/atlas
# b. Create cluster & database 'employeeDB'
# c. Copy connection string
# d. Create .env file
cp .env.example .env
# Edit .env: MONGO_URI=your_connection_string
# 4. Run the app
node main.jsMONGO_URI=your_mongodb_connection_string_here1. Tampilkan Semua Data # View all employees
2. Tampilkan Statistik # Employee statistics
3. Tambah Data Baru # Add new employee(s)
4. Urutkan Data # Sort by ID
5. Cari Karyawan # Search by ID/Name
6. Edit Data # Edit existing employee
7. Hapus Data # Delete employee
8. Keluar # Exit
Adding Multiple Employees:
> Pilih jumlah data (0 = cancel): 2
> ID karyawan ke-1: EMP001
> Nama: John Doe
> Jabatan: Developer
> No Telp: 08123456789
> Save? [Y/n]: Y
Searching & Editing:
> Cari dengan ID/Nama: John
> Select employee: [1] John Doe (EMP001)
> Edit fields (Enter to skip):
> New Name: Jane Doe
> Confirm changes? [Y/n]: Y
| Feature | Description | Status |
|---|---|---|
| Bulk Input | Add multiple employees at once | ✅ |
| Smart Search | ID or partial name matching | ✅ |
| Interactive Edit | Field-by-field editing w/ preview | ✅ |
| Data Sorting | Asc/Desc by ID, optional export | ✅ |
| Statistics | Count, job grouping, ID prefix | ✅ |
| Audit Logging | Track CREATE/UPDATE/DELETE | ✅ |
| Soft Delete | Log deleted records | ✅ |
| Validation | Unique IDs, required fields | ✅ |
employees
{
ID: { type: String, required: true, unique: true },
NAMA: { type: String, required: true },
JABATAN: { type: String, required: true },
TELP: { type: String, required: true },
createdAt: Date,
updatedAt: Date
}deletedemployees (logs)
{
ID: String,
NAMA: String,
JABATAN: String,
TELP: String,
deleted_at: Date
}employeelogs (audit)
{
action: 'CREATE' | 'UPDATE' | 'DELETE',
data_before: Object | null,
data_after: Object | null,
timestamp: Date
}main.js → Services → Models → MongoDB
↓
inquirer prompts
Key Design Patterns:
- Modular Services: Each feature in separate file
- Repository Pattern: Models handle data access
- Dependency Injection: Services imported in main.js
- Async/Await: All DB operations are asynchronous
npm install
npm run dev # Add to package.json scripts- Create new service in
/services/ - Add menu option in
main.js - Update README & Wiki
# Manual testing via CLI
node main.js
# Add Jest tests (future)
npm test
Fully self-contained CLI app. No server deployment needed.
| Issue | Solution |
|---|---|
Cannot connect to MongoDB |
Check .env URI, whitelist IP in Atlas |
Module not found |
Run npm install
|
ID already exists |
Use unique ID format (EMP001, DEV002) |
No data found |
Add sample data first |
Common MongoDB Atlas Setup:
Network Access → Add IP → 0.0.0.0/0 (Allow all)
Database Access → Create user → Read/Write
This project is MIT licensed.