An on-premise, full-stack Employee Management System designed for tracking employee work hours, tasks, breaks, and leave requests. It features role-based access control for Employees, Managers, and Administrators, and is built with a Node.js backend and a modern vanilla JavaScript front-end.
- Role-Based Access Control:
- Employee: Can clock in/out, manage daily tasks, take breaks, and request leave.
- Manager: Can view detailed performance reports for their team, export data, and approve/reject leave requests.
- Administrator: Can create/manage all users and configure their access permissions.
- Real-Time Dashboard: Employees see a live-updating dashboard showing their current status (On Task, On Break, Idle), and total work, task, and break times for the day.
- Comprehensive Reporting: Managers can generate detailed reports for any employee over any date range, including a chronological activity timeline and task summary.
- Excel Export: All reports can be exported to a multi-sheet
.xlsxfile for offline analysis and record-keeping. - User-Specific IP Restrictions: Admins can define a list of allowed IP addresses for each employee and manager, preventing logins from unauthorized networks.
- On-Premise Ready: Built to run on a local server with a professional-grade PostgreSQL database for data security and integrity.
- Backend: Node.js, Express.js
- Database: PostgreSQL
- Authentication: JSON Web Tokens (JWT)
- Frontend: Vanilla JavaScript (ES6+), HTML5, CSS3
- Key Libraries:
pg(for PostgreSQL),jsonwebtoken,xlsx(for Excel export)
Follow these steps to set up and run the application on a local server.
- Node.js (v16 or later recommended)
- PostgreSQL (v14 or later recommended)
- A command-line terminal (like PowerShell, Command Prompt, or Terminal)
- pgAdmin 4 (usually included with the PostgreSQL installer)
First, you need to create a dedicated database for the application.
- Install PostgreSQL: Follow the official installer for your server's operating system. During installation, you will be prompted to set a password for the default superuser,
postgres. Remember this password. - Open pgAdmin 4: Launch the pgAdmin application.
- Connect to Server: Double-click the server instance (e.g., "PostgreSQL 16") and enter the password you created.
- Create the Database:
- Right-click on Databases in the left-hand browser.
- Select Create -> Database....
- Enter the database name:
ems_db - Click Save.
-
Clone the Repository:
git clone https://github.com/your-username/ems-final.git cd ems-final -
Install Dependencies:
npm install
-
Configure the Database Connection:
- Open the
server.jsfile in a code editor. - Find the
CONNECTION_STRINGconstant near the top of the file. - Replace
"YOUR_PASSWORD_HERE"with the actual password you set for thepostgresuser.
// Example from server.js const CONNECTION_STRING = "postgres://postgres:YourActualPassword123@localhost:5432/ems_db";
- Open the
-
Start the Server:
npm start
The first time you run this, the application will automatically create all the necessary tables in your
ems_dbdatabase and seed the initial administrator account. You should see output like this:Connected to local PostgreSQL database Tables created and checked successfully. Seeding database with default admin user... Server running at http://localhost:3000 -
Access the Application:
- Open a web browser and navigate to
http://localhost:3000.
- Open a web browser and navigate to
- Log in as Admin:
- Username:
admin - Password:
admin123
- Username:
- Navigate to User Management:
- You will be taken to the admin dashboard.
- Create a New User (e.g., an Employee):
- Fill out the "Create New User" form.
- For testing on your local machine, in the "Allowed IPs" field, enter
::1. This is the IP address forlocalhost. - Click "Create User".
- Log Out of the admin account.
- Log In as the New Employee with the credentials you just created. You should now see the employee dashboard.
- The Allowed IPs field for each user controls where they can log in from.
- It accepts a comma-separated list of IP addresses (e.g.,
192.168.1.100, 192.168.1.101, ::1). - If the field is left empty, that user can log in from any IP address.
- The Admin role is exempt from all IP restrictions to prevent being locked out.
To run this application continuously on an on-premise server, it is highly recommended to use a process manager like pm2.
- Install
pm2globally:npm install pm2 -g
- Start the application with
pm2:pm2 start server.js --name "ems-app" - Enable Startup on Reboot:
This command will generate another command that you need to run. Copy and paste that command to enable the startup script.
pm2 startup
- Save the current process list:
pm2 save
Now, your EMS application will run in the background and automatically restart if it crashes or if the server reboots. You can monitor it with pm2 list and view logs with pm2 logs ems-app.