Backend Frameworks

Learn servers, HTTP, REST APIs, Node.js, Express.js, routing, middleware, authentication and API development.

2nd September, 2026

What is Backend Development?

Backend development is the server-side part of an application. It handles data, business logic, authentication and communication with databases.

🍽️ Everyday Example: A Restaurant

Think of a web application like a restaurant.

👤
Customer

User using the application

🖥️
Frontend

What the customer sees

👨‍🍳
Backend

Kitchen doing the work

🗄️
Database

Stores information

How a web application works

User
                                                    ↓
                                                    Frontend
                                                    ↓
                                                    HTTP Request
                                                    ↓
                                                    Backend Server
                                                    ↓
                                                    Database
                                                    ↓
                                                    Backend Server
                                                    ↓
                                                    HTTP Response
                                                    ↓
                                                    Frontend
                                                    ↓
                                                    User

Backend Development Topics

Learn each topic step by step with examples and practice.

1 What is Server-Side Development?

📖 Explanation

Server-side development is the programming that happens on a server instead of directly inside the user's browser.

The backend receives requests from the frontend, performs some work, communicates with databases and sends a response.

🍕 Everyday Example

Imagine ordering pizza online.

  1. You choose a pizza on the website.
  2. The frontend sends your order to the backend.
  3. The backend checks the product and price.
  4. The backend creates the order.
  5. The database stores the order.
  6. The backend tells the frontend that the order was successful.

Example Flow

Browser
                                                    ↓
                                                    "Buy Headphones"
                                                    ↓
                                                    Backend
                                                    ↓
                                                    Check product
                                                    ↓
                                                    Check stock
                                                    ↓
                                                    Create order
                                                    ↓
                                                    Database
                                                    ↓
                                                    "Order created"
                                                    ↓
                                                    Browser
🎯 Practice

Imagine you have a login page. Write down 5 things the backend needs to do after the user clicks "Login".

2 HTTP and REST APIs

📖 What is HTTP?

HTTP is a communication protocol used by browsers, servers and applications to communicate.

📨 Everyday Example: Sending a Letter

Think about HTTP like sending a letter.

📨 Request
                                                    ↓
                                                    Server
                                                    ↓
                                                    📬 Response

The request asks the server to perform an action. The response contains the result.

HTTP Methods

Method Purpose Example
GET Get data Get products
POST Create data Create account
PUT Replace/update data Update profile
PATCH Partially update data Change username
DELETE Delete data Delete account

🔌 REST API

A REST API provides URLs that applications can use to work with resources.

GET /products GET /products/10 POST /products PUT /products/10 DELETE /products/10

Example JSON Response

{
                                                        "id": 10,
                                                        "name": "Headphones",
                                                        "price": 999
                                                    }
🎯 Practice

Design a REST API for a student management system.

  • Get all students
  • Get one student
  • Create a student
  • Update a student
  • Delete a student
3 Node.js

📖 Explanation

Node.js allows JavaScript to run outside the browser. This means we can use JavaScript to build servers and backend applications.

Before Node.js
JavaScript
                                                    ↓
                                                    Browser
With Node.js
JavaScript
                                                    ↓
                                                    Node.js
                                                    ↓
                                                    Server
🧠 Everyday Example

JavaScript is the language. Node.js gives JavaScript an environment where it can work on the server.

Basic Node.js Server

const http = require("http");

                                                    const server = http.createServer((req, res) => {
                                                        res.end("Hello from the server!");
                                                    });

                                                    server.listen(3000);

The server is now listening on:

http://localhost:3000
🎯 Practice

Change the response so the server displays:

Welcome to my backend!
4 Express.js

📖 Explanation

Express.js is a web framework for Node.js that makes building servers and APIs easier.

🚂 Simple Analogy

Node.js provides the basic engine. Express.js provides convenient tools that make building your backend easier.

Install Express

npm init -y

                                                    npm install express

Basic Express Server

const express = require("express");

                                                    const app = express();

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

                                                    app.listen(3000, () => {
                                                        console.log("Server running on port 3000");
                                                    });
🎯 Practice

Create these three routes:

/ /about /contact

Each route should return a different message.

5 Routing

📖 Explanation

Routing determines what should happen when a user requests a particular URL.

🛣️ Everyday Example

Think of routes like roads.

Home
                                                    ↓
                                                    Products
                                                    ↓
                                                    Product Details
                                                    ↓
                                                    Cart

Different roads take you to different destinations. Similarly, different URLs can perform different operations.

Express Routing Example

app.get("/products", (req, res) => {

                                                        res.json([
                                                            {
                                                                id: 1,
                                                                name: "Laptop"
                                                            },
                                                            {
                                                                id: 2,
                                                                name: "Phone"
                                                            }
                                                        ]);

                                                    });

Route Parameters

app.get("/products/:id", (req, res) => {

                                                        const id = req.params.id;

                                                        res.json({
                                                            message: `You requested product ${id}`
                                                        });

                                                    });

If the user visits:

/products/5

then:

req.params.id

contains:

5
🎯 Practice

Create routes for:

GET /students GET /students/:id GET /courses GET /courses/:id
6 Middleware

📖 Explanation

Middleware is a function that runs between the incoming request and the final route handler.

🛂 Everyday Example: Airport Security
Passenger
                                                    ↓
                                                    Ticket Check
                                                    ↓
                                                    Security
                                                    ↓
                                                    Gate
                                                    ↓
                                                    Flight

Middleware works in a similar way.

Request Flow

Request
                                                    ↓
                                                    Middleware
                                                    ↓
                                                    Route
                                                    ↓
                                                    Response

Example Middleware

const logger = (req, res, next) => {

                                                        console.log(req.method, req.url);

                                                        next();

                                                    };

                                                    app.use(logger);

next() tells Express to continue to the next middleware or route.

What can middleware do?

  • Logging
  • Authentication
  • Validation
  • Parsing request data
  • Error handling
  • Security checks
🎯 Practice

Create middleware that prints:

Someone visited the server!

every time a request arrives.

7 Authentication

📖 Explanation

Authentication answers the question:

🔐 "Who are you?"

🏠 Everyday Example: House Key
🔑 Key
                                                    ↓
                                                    Door Lock
                                                    ↓
                                                    🏠 Access Granted

Authentication works similarly. A user provides credentials and the server verifies them.

Login Flow

User
                                                    ↓
                                                    Login Form
                                                    ↓
                                                    POST /login
                                                    ↓
                                                    Backend
                                                    ↓
                                                    Check User
                                                    ↓
                                                    Check Password
                                                    ↓
                                                    Create Session / Token
                                                    ↓
                                                    Send Response

Example Login Request

POST /login

                                                    {
                                                        "email": "user@example.com",
                                                        "password": "mypassword"
                                                    }

JWT Authentication

One common API authentication approach is using a JSON Web Token (JWT).

Login
                                                    ↓
                                                    Server verifies credentials
                                                    ↓
                                                    Server creates JWT
                                                    ↓
                                                    Client stores token
                                                    ↓
                                                    Client sends token with future requests
                                                    ↓
                                                    Server verifies token
                                                    ↓
                                                    Protected resource

Protected Request

GET /profile

                                                    Authorization: Bearer <token>
⚠️ Important Security Rule

Never store user passwords as plain text. Passwords should be securely hashed before being stored.

🎯 Practice

Draw the complete login process:

User
                                                    ↓
                                                    ?
                                                    ↓
                                                    ?
                                                    ↓
                                                    ?
                                                    ↓
                                                    Login Successful
8 Error Handling

📖 Explanation

Errors are a normal part of backend development. A good backend should detect errors and return useful responses.

Common Errors

  • User doesn't exist
  • Invalid password
  • Product doesn't exist
  • Invalid input
  • Database unavailable
  • Server failure

HTTP Status Codes

Status Meaning
200 Success
201 Created
400 Bad Request
401 Not Authenticated
403 Forbidden
404 Not Found
500 Internal Server Error

Example

app.get("/products/:id", (req, res) => {

                                                        const product = null;

                                                        if (!product) {

                                                            return res.status(404).json({
                                                                message: "Product not found"
                                                            });

                                                        }

                                                        res.json(product);

                                                    });
🎯 Practice

Create an endpoint that returns:

Status: 404

                                                    {
                                                        "message": "Student not found"
                                                    }

when a student doesn't exist.

9 Building APIs

📖 Explanation

Now we combine everything we've learned to build a real backend API.

🎓 Example: Student Management API

Imagine a school application that allows users to create, view, update and delete students.

API Structure

GET /students GET /students/:id POST /students PUT /students/:id DELETE /students/:id

Complete Basic API

const express = require("express");

                                                    const app = express();

                                                    app.use(express.json());

                                                    let students = [
                                                        {
                                                            id: 1,
                                                            name: "Rahul",
                                                            course: "React"
                                                        },
                                                        {
                                                            id: 2,
                                                            name: "Priya",
                                                            course: "Node.js"
                                                        }
                                                    ];


                                                    // GET all students

                                                    app.get("/students", (req, res) => {
                                                        res.json(students);
                                                    });


                                                    // GET one student

                                                    app.get("/students/:id", (req, res) => {

                                                        const student = students.find(
                                                            student => student.id === Number(req.params.id)
                                                        );

                                                        if (!student) {
                                                            return res.status(404).json({
                                                                message: "Student not found"
                                                            });
                                                        }

                                                        res.json(student);
                                                    });


                                                    // CREATE student

                                                    app.post("/students", (req, res) => {

                                                        const newStudent = {
                                                            id: students.length + 1,
                                                            name: req.body.name,
                                                            course: req.body.course
                                                        };

                                                        students.push(newStudent);

                                                        res.status(201).json(newStudent);
                                                    });


                                                    // DELETE student

                                                    app.delete("/students/:id", (req, res) => {

                                                        const id = Number(req.params.id);

                                                        students = students.filter(
                                                            student => student.id !== id
                                                        );

                                                        res.json({
                                                            message: "Student deleted"
                                                        });

                                                    });


                                                    app.listen(3000, () => {
                                                        console.log("Server running on port 3000");
                                                    });
🎯 Practice

Add a PUT /students/:id endpoint that allows the user to update a student's name and course.

📚 Backend Learning Roadmap

Follow this order instead of trying to learn everything at once.

1

JavaScript

Understand variables, functions, arrays, objects, promises, async/await and modules.

2

Backend Fundamentals

Understand servers, clients, requests and responses.

3

HTTP & REST APIs

Learn GET, POST, PUT, PATCH, DELETE and HTTP status codes.

4

Node.js

Learn how to run JavaScript on the server.

5

Express.js

Build servers and APIs more easily.

6

Routing

Create different API endpoints.

7

Middleware

Learn logging, validation, authentication and request processing.

8

Authentication

Learn login systems, password hashing, sessions and tokens.

9

Error Handling

Learn how to handle and communicate errors properly.

10

Build APIs

Combine everything into a real-world backend project.

Final Project

🚀 Task Management API

Build this project after completing the lessons.

✨ Features

  • 👤 User registration
  • 🔐 User login
  • 📝 Create tasks
  • 📋 View tasks
  • ✏️ Update tasks
  • 🗑️ Delete tasks
  • 🔒 Protected routes
  • 🚨 Error handling

🔌 API Endpoints

POST /auth/register POST /auth/login GET /tasks GET /tasks/:id POST /tasks PUT /tasks/:id DELETE /tasks/:id

🏗️ Backend Architecture

⚛️
React
Frontend
🔌
REST API
Communication
🟢
Node.js
Runtime
🚂
Express
Backend Framework
↓
🛡️
Middleware
Authentication & Validation
🧠
Business Logic
Application Rules
🗄️
Database
Data Storage

🎯 What You Will Know

JavaScript
                                                    ↓
                                                    Backend Fundamentals
                                                    ↓
                                                    HTTP
                                                    ↓
                                                    REST APIs
                                                    ↓
                                                    Node.js
                                                    ↓
                                                    Express.js
                                                    ↓
                                                    Routing
                                                    ↓
                                                    Middleware
                                                    ↓
                                                    Authentication
                                                    ↓
                                                    Error Handling
                                                    ↓
                                                    Database
                                                    ↓
                                                    API Development
                                                    ↓
                                                    Full-Stack Development 🚀

✅ Backend Developer Checklist

Fundamentals
  • Understand client/server architecture
  • Understand HTTP
  • Understand REST
  • Understand JSON
  • Understand status codes
Node & Express
  • Create Node.js servers
  • Build Express applications
  • Create routes
  • Use middleware
  • Handle requests and responses
Security
  • Authentication
  • Password hashing
  • JWT/tokens
  • Protected routes
  • Input validation
Real-World Development
  • Error handling
  • Database integration
  • CRUD APIs
  • API testing
  • Build complete projects