Blood Bank Management System Project with Source Code | How to Create a Node.js Express Project - Step-by-Step Guide | React & Node JS Project Tutorial | Part 3

Learn how to create a fully functional Blood Bank Management System using modern technologies. This step-by-step guide is perfect for both beginners and experienced developers, offering source code and practical insights. With a focus on React JS, Node JS, and Bootstrap, you'll develop an efficient system for managing blood donations, inventory, and donors. Start building your blood bank management system today!

Technologies Used

  • React JS
  • Node JS
  • Bootstrap
  • HTML & CSS

Basic Requirement

  1. Node JS
  2. Editor
  3. Web browser

How to Create a Node.js Express Project

Node.js, coupled with Express.js, is a powerful framework for building scalable and fast web applications. Whether you're just starting with Node.js or want to brush up on the basics, this guide will take you through the process of creating a Node.js Express project from scratch.

What is Node.js?

Node.js is a server-side runtime environment built on Chrome's V8 JavaScript engine. It allows you to use JavaScript to create backend services like APIs or web applications, making it an excellent choice for full-stack JavaScript development.

What is Express.js?

Express.js is a minimal and flexible web application framework for Node.js that provides a robust set of features for building web and mobile applications. It simplifies the process of creating web servers and APIs, allowing you to handle routes, requests, and responses efficiently.

Step 1: Install Node.js

Before you can start working on your Node.js project, you need to have Node.js installed on your machine. Here's how to do that:

  • Visit Node.js official website and download the latest stable version.
  • Install it by following the instructions for your operating system.
  • Verify installation by running node -v and npm -v in your terminal.

Step 2: Initialize a New Node.js Project

mkdir my-express-app
cd my-express-app
npm init
        

After answering the prompts, a package.json file will be created in your project folder.

Step 3: Install Express.js

Install Express.js using npm:

npm install express --save
        

Step 4: Install Nodemon

For auto-restarting the server during development, install and use Nodemon:

npm install -g nodemon
        

Step 5: Add Start Script in package.json

"scripts": {
    "start": "nodemon app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
},
        

Step 6: Run Project

npm start
        

Step 7: Create the Basic Server

In the root of your project folder, create a file called app.js and add the following code:

const express = require('express');
const app = express();
const PORT = 4000;

app.get('/', (req, res) => {
  res.send('Hello, World!');
});

app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});
        

Step 8: Adding Routes

You can easily add more routes to your Express.js application, for example:

app.get('/test', (req, res) => {
    res.send('Test Route');
});
        

Step 9: Run url in your web browser

http://localhost:4000/
http://localhost:4000/test
        

Step 4: Project Folder Structure

Once you have initialized the project and installed Express, your folder structure should look something like this:

        my-express-app/
        ├── controllers/           # Logic for handling requests
        │   └── controller.js      # Your controller file
        ├── routes/                # Application routes
        │   └── index.js           # Main route file
        ├── models/                # Data models (e.g., Mongoose models)
        ├── node_modules/          # Installed dependencies
        ├── app.js                 # Main server file
        ├── package.json           # Project dependencies and scripts
        └── package-lock.json      # Dependency lock file
        

In this structure:

  • controllers/ contains your application's logic for handling incoming requests and sending responses.
  • routes/ handles your application's endpoints, with index.js managing the routes.
  • models/ is where you'll define your data models, often using a library like Mongoose.
  • node_modules/ contains all the installed dependencies for your project.
  • app.js is the entry point for your application, where Express is configured and the server is started.