Getting Started with Backend Development: Web Servers, Node.js, and Bun Explained

Santwan PathakSantwan Pathak
8 min read

Hey everyone!
If you’re ready to dive into the world of backend development, you’re in the right place. This blog kicks off our backend dev series—where we’re going beyond the frontend and digging into the engines powering the web: servers, requests, runtime environments, and real-world backend architecture.

Whether you're aiming to build large-scale applications like Shopify or simple ToDo apps, understanding how a backend works is absolutely essential. And yes, we’ll write actual code along the way — not just talk theory.

Let’s get started!


What's the Prerequisite?

You only need one thing before jumping in:

Basic knowledge of JavaScript — just the fundamentals like variables, functions, and loops.

No need to master Node.js, Bun, or understand how backend protocols work. You don’t even need to know what a server really is.

This blog is designed for absolute beginners in backend development. We’ll start from scratch and build everything step by step — explaining not just the how, but also the why behind each concept.

By the end, backend buzzwords like HTTP, status codes, request/response cycle, and routing will feel like second nature.


Understanding Backend Architecture

Before we jump into the code, let’s take a moment to understand what we’re actually building and how it fits into the bigger picture of web development.

Client-Server Architecture

At the heart of every backend system lies a simple but powerful concept: the client-server model.

Client (Browser / Mobile App) → Web Server → Database (Optional)
  • Client: This is the user-facing side — it could be a browser, mobile app, smartwatch, or anything capable of making a request.

  • Web Server: The brain of your backend. It receives client requests, processes them, and sends back a response. This is our main focus in this series.

  • Database (not covered yet): A place to store, retrieve, and manage data. Examples include MongoDB, PostgreSQL, etc.

In this blog, we’ll focus solely on building the web server — step by step — so you understand exactly what’s happening under the hood.


What is a Web Server?

Let’s bust a myth:

❌ A server isn’t always a giant machine in a datacenter.

✅ A web server is simply a piece of software whose job is to receive requests and send responses.

No matter the language — PHP, .NET, Node.js, Python — the core idea stays the same:

Listen on a port → Process the request → Send a response

You can even build a web server on your local laptop — and that’s exactly what we’ll do.


Node.js vs Bun – JavaScript Runtimes for the Backend

First, What’s a Runtime?

Before comparing Node.js and Bun, let’s answer a basic question:
JavaScript was originally made to run in browsers... so how are we using it to build backend servers?

The answer: JavaScript Runtime Environments — tools that allow JavaScript to run outside the browser (on your computer or a server).

These runtimes provide:

  • Access to the file system

  • Ability to create servers

  • Tools for running scripts, installing packages, and much more

Let’s explore the two most popular runtimes today: Node.js and Bun.

🟢 Node.js – The Veteran in the Game

eleased: 2009
Used by: Netflix, PayPal, LinkedIn, Walmart, and many more
Built with: C++, JavaScript, and Google Chrome’s V8 engine

Key Features:

  • Event-Driven, Non-blocking I/O:
    Perfect for handling thousands of concurrent network requests — great for APIs, real-time apps (like chats), and more.

  • Massive Package Ecosystem (npm):
    With over 2 million packages, npm is the largest open-source library in the world. You can find ready-made solutions for almost anything.

  • Cross-Platform:
    Runs on Windows, macOS, and Linux with minimal setup.

  • Active Community & Support:
    Tons of tutorials, Stack Overflow answers, and official documentation to help you.

  • Used in Production Everywhere:
    Node.js powers high-scale applications like Discord, Trello, and Uber.

🛠️ Typical Use Cases:

  • RESTful APIs

  • Real-time apps (WebSocket servers)

  • Microservices

  • Backend for web/mobile apps

  • CLI tools


🟣 Bun – The New Speedster

Released: 2022 (very recent)
Built with: Zig programming language (known for speed and safety)
Engine: JavaScriptCore (used by Safari)

Key Features:

  • Blazing Fast Performance:
    Up to 3x faster than Node.js in some benchmarks. Ideal for high-performance apps.

  • All-in-One Toolchain:
    Bun replaces several tools in the Node ecosystem with one unified solution:

    | Feature | Bun Replaces | | --- | --- | | HTTP Server | express, http | | Package Manager | npm, yarn | | Task Runner | npm scripts, gulp | | Bundler | webpack, esbuild, vite | | Test Runner | jest, mocha |

  • Built-in TypeScript Support:
    No need to set up TypeScript compilers or configs — it just works.

  • Minimal Setup:
    Fewer configuration files, faster install times, and cleaner development workflow.

Things to Keep in Mind:

  • Still new and evolving — some npm packages might not work perfectly yet

  • Smaller community compared to Node.js

  • Best suited for newer projects or experimental builds

🔗 Our Approach in This Blog

You don’t need to master Node.js or Bun before starting.

We'll focus on Node.js throughout this series for three reasons:

  1. It’s more stable and widely adopted

  2. Most job roles still prefer Node.js experience

  3. Tons of beginner resources are available for support

But you’re always welcome to explore Bun once you’re comfortable!


Installing Node.js and Bun

Both are available for all major OS:

For this lesson, we’ll start by using Node.js to create a basic HTTP server.


Let's Build: Your First Web Server in Node.js

Here’s how you get started:

Step-by-Step Setup

  1. Create a project folder

     mkdir backend && cd backend
     mkdir 01-web-server && cd 01-web-server
    
  2. Open it in VS Code

  3. Create a file

     server-node.js
    
  4. Check Node Installation

     node -v
    

Code: Creating an HTTP Server in Node.js

// 1. Import Node's built-in http module
const http = require("http");

// 2. Define hostname and port
const hostname = "127.0.0.1";
const port = 3000;

// 3. Create a server instance with a callback
const server = http.createServer((req, res) => {
  res.statusCode = 200; // OK
  res.setHeader("Content-Type", "text/plain");
  res.end("Hello from your first Node server!");
});

// 4. Start listening
server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

📡 This creates a local server that responds to every request with "Hello from your first Node server!"


How This Works – A Breakdown

Let’s write our first backend program — a simple HTTP server using Node’s built-in http module.

// 1. Import Node's built-in http module
const http = require("http");

🔹 http is a core module in Node.js — no need to install it.
It provides functions to create a web server and handle HTTP requests/responses.

// 2. Define hostname and port
const hostname = "127.0.0.1";
const port = 3000;

🔹 hostname: 127.0.0.1 refers to localhost — your own computer.
🔹 port: A unique number used by the server to listen for requests (3000 is a common dev port).

// 3. Create a server instance with a callback
const server = http.createServer((req, res) => {
  res.statusCode = 200; // OK
  res.setHeader("Content-Type", "text/plain");
  res.end("Hello from your first Node server!");
});

🔹 http.createServer() creates the server.
🔹 It takes a callback with two parameters:

  • req = the incoming request from the client

  • res = the response you send back

Inside the callback:

  • res.statusCode = 200 → means “OK” (request was successful)

  • res.setHeader() → tells the client that the content is plain text

  • res.end() → finalizes the response and sends it to the client

// 4. Start listening
server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

🔹 .listen() starts the server on the specified hostname and port.
🔹 The callback logs a message to the terminal once the server is up and running.

Output:

When you run the file with:

node server-node.js

Open your browser or send a request from postman and go to:
📍 http://127.0.0.1:3000
You’ll
see:

Hello from your first Node server!

Boom! 🎉 You've just created your first backend server.


Why This Matters

Understanding this flow sets the foundation for everything you’ll build later:

  • Express.js

  • REST APIs

  • File serving

  • Auth systems

  • Database communication

If you know how to create and manage a server at this raw level, the frameworks and tools later on will make a lot more sense.


Summary – What We Covered

TopicKey Takeaways
Backend ArchitectureClient → Server → Database (we focused on server)
Web ServerJust software that serves responses
JavaScript RuntimeNode.js and Bun allow JS to run outside the browser
CodeYou wrote your first HTTP server in Node.js
PhilosophyLearn by building, no need to “master” Node first

What's Next?

In the upcoming parts of this blog series

  • we will see handling different routes and HTTP methods in this Node server.

  • We’ll explore how to write web servers using Bun

  • Try to understand the need of these frameworks

Until then, play around with the Node.js server.
Try changing the port, printing the request URL, or sending different responses. Try sending a request from http://127.0.0.1:3000/login or http://127.0.0.1:3000/hello or any other url.

Try to find out what’s wrong with our present server XD !!!!!!!

0
Subscribe to my newsletter

Read articles from Santwan Pathak directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Santwan Pathak
Santwan Pathak

"A beginner in tech with big aspirations. Passionate about web development, AI, and creating impactful solutions. Always learning, always growing."