Build User Management System Using NodeJS (original) (raw)

Last Updated : 30 Mar, 2026

A user management system is an essential application for handling user accounts and information. It involves creating, reading, updating, and deleting user accounts, also known as CRUD operations.

Features of the User Management App

Create a simple web application where administrators can manage users. The application will feature:

Steps to Build User Management System

Follow these steps to build a basic user management system with CRUD functionality.

Step 1: Create a Project Folder

Open your terminal (Command Prompt/PowerShell) and run the following commands:

mkdir user-management-system cd user-management-system

Step 2: Initialize a NodeJS Project

This will create a package.json file.

npm init -y

Step 3: Install Dependencies

Run the following command to install the required dependencies

npm install express ejs body-parser

This installs:

After installation, the dependencies section in package.json should look like this:

"dependencies": { "body-parser": "^1.20.2", "ejs": "^3.1.10", "express": "^4.19.2" }

Step 4: Create Server File

Create an 'app.js' file, inside this file require the Express Module,to create a constant 'app' for creating an instance of the express module, then set the EJS as the default view engine.

index.js ``

const express = require('express'); const bodyParser = require('body-parser'); const app = express(); const PORT = 3000; // Middleware app.set('view engine', 'ejs'); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); // Sample Users Data let users = [ { userUniqueId: "1", userName: "Aditya Gupta", userEmail: "aditya@gmail.com", userAge: "22" }, { userUniqueId: "2", userName: "Vanshita Jaiswal", userEmail: "vanshita@gmail.com", userAge: "21" }, { userUniqueId: "3", userName: "Sachin Yadav", userEmail: "sachin@gmail.com", userAge: "22" } ]; // Home Route - Display Users app.get("/", (req, res) => { res.render("home", { data: users }); }); // Add User Route app.post("/", (req, res) => { const newUser = { userUniqueId: req.body.userUniqueId, userName: req.body.userName, userEmail: req.body.userEmail, userAge: req.body.userAge }; users.push(newUser); res.render("home", { data: users }); }); // Delete User Route app.post('/delete', (req, res) => { const requestedUserUniqueId = req.body.userUniqueId; users = users.filter(user => user.userUniqueId !== requestedUserUniqueId); res.render("home", { data: users }); }); // Update User Route app.post('/update', (req, res) => { users.forEach(user => { if (user.userUniqueId === req.body.userUniqueId) { user.userName = req.body.userName; user.userEmail = req.body.userEmail; user.userAge = req.body.userAge; } }); res.render("home", { data: users }); }); // Start Server app.listen(PORT, () => { console.log(Server running at http://localhost:${PORT}); });

``

Step 5: Set Up Views Directory

Create a views folder in your root directory and inside it, create a file called home.ejs.

Step 6: Create the Home Page (home.ejs)

Inside views/home.ejs, add the following code:

index.js `

User Management System

Current Users

<% data.forEach(user => { %> <% }) %>
User Id User Name User Email Age Delete
<%= user.userUniqueId %> <%= user.userName %> <%= user.userEmail %> <%= user.userAge %> Delete

Add User

Submit

Update User

Update

`

In your terminal, navigate to the project folder and run

node app.js

**Output: