Skip to content

FormaServe/f_EMS

Repository files navigation

RedMon Logo

Employee Management System

A Node.js web application for managing employee data stored in an IBM i database.

This repo is used for giving demonstrations and examples of full-stack development with IBM i.

It was first built as part of a modernisation workshop at the IBM i Community Event "BeNeLux 2025" in Tilburg, Netherlands.

Features

  • View Employees: Browse all employees in a responsive table
  • Search: Search employees by number, first name, or last name
  • Add Employee: Create new employee records with comprehensive data fields
  • Edit Employee: Update existing employee information
  • Delete Employee: Remove employee records with confirmation
  • Responsive Design: Bootstrap-based UI with FontAwesome icons

Tech Stack

  • Backend: Node.js with Express.js
  • Templates: Pug (Jade)
  • Styling: Bootstrap 5 with FontAwesome icons
  • Database: IBM i accessed via Mapepire
  • Testing: Jest with Supertest

Installation

  1. Clone the repository. In a windows command prompt or powershell window run:

    git clone https://github.com/FormaServe/f_EMS.git
  2. Change into the project directory:

    cd f_EMS
  3. Install dependencies:

    npm install
  4. Configure environment variables by copying .env.example to .env:

    cp .env.example .env
  5. Update .env with your IBM i connection details:

    MAPEPIRE_SERVER=your-ibmi-server
    MAPEPIRE_USER=your-username
    MAPEPIRE_PASSWORD=your-password
    MAPEPIRE_PORT=8076

Usage

Development Mode

Run with automatic reload:

npm run dev

Debug Mode (Extra logging in the console)

npm run dev:debug

Production Mode

npm start

The application will be available at http://localhost:3000

Testing

Run the test suite:

npm test

Database Schema

The application manages the EMPLOYEE table.

To create the table, use the following SQL statement on your IBM i system:

call qsys.create_sql_sample('AY_DEMO');

Replace AY_DEMO with your target schema if different. (Must be in uppercase!)

This table has the following structure:

| Field | Type | Length | Description |
|-------|------|--------|-------------|
| EMPNO | CHARACTER | 6 | Employee Number (Primary Key) |
| FIRSTNME | VARCHAR | 12 | First Name |
| MIDINIT | CHARACTER | 1 | Middle Initial |
| LASTNAME | VARCHAR | 15 | Last Name |
| WORKDEPT | CHARACTER | 3 | Work Department Code |
| PHONENO | CHARACTER | 4 | Phone Number Extension |
| HIREDATE | DATE | - | Hire Date |
| JOB | CHARACTER | 8 | Job Title/Code |
| EDLEVEL | SMALLINT | 4 | Education Level |
| SEX | CHARACTER | 1 | Gender (M/F) |
| BIRTHDATE | DATE | - | Birth Date |
| SALARY | DECIMAL | 9,2 | Annual Salary |
| BONUS | DECIMAL | 9,2 | Annual Bonus |
| COMM | DECIMAL | 9,2 | Commission |

Project Structure

Employee/
├── app.js                # Main Express application
├── examples              # Workshop examples and testing
├── package.json          # Dependencies and scripts
├── routes/               # Route handlers
│   └── employees.js      # Employee CRUD routes
├── views/                # Pug templates
│   ├── layout.pug        # Base layout
│   ├── index.pug         # Employee list
│   ├── error.pug         # Error page
│   └── employee/         # Employee-specific views
│       ├── form.pug      # Add/Edit form
│       └── view.pug      # Employee details
├── public/               # Static assets
│   ├── css/              # Custom styles
│   ├── js/               # Client-side JavaScript
│   └── documentation/    # Application documentation
├── models/               # Data access layer
│   └── employee.js       # Employee model
└── tests/                # Unit tests
    ├── employee.test.js  # Model tests
    └── routes.test.js    # Route tests

API Routes

  • GET /employees - List all employees
  • GET /employees/search?q=term - Search employees
  • GET /employees/new - Show create form
  • GET /employees/:id - View employee details
  • GET /employees/:id/edit - Show edit form
  • POST /employees - Create new employee
  • POST /employees/:id - Update employee
  • POST /employees/:id/delete - Delete employee

Development Guidelines Followed

  • Use camelCase for variable names
  • Prefer arrow functions over traditional functions
  • All database operations should use async/await
  • Include proper error handling with try-catch blocks
  • Write unit tests for new features
  • Follow RESTful conventions for routes
  • All documentation to be stored in public/documentation/

Support the Project

If you find this project helpful, consider buying me a coffee! ☕

ko-fi

Your support helps me continue creating free educational resources and open-source projects for the IBM i community.

License

This project is licensed under the Apache License 2.0. It covers the entire project, including all source code, documentation, and assets.

© 2025 FormaServe Systems Ltd.

About

f_EMS - Employee Management System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors