Non-Fiction, Informative, Educational

Backend Development with Node.js eBook

A Coursebook on Backend Development with Node.js

by Campos Hyon

  • English
  • 150 pages
  • 2026
  • SamEnrico

A Coursebook on Backend Development with Node.js

Formats

Free sample

Chapter 1: The Silent Engine--–- Every second, millions of people scroll through their social media feeds, send chat messages, order food, and stream videos. None of them see what makes it all possible. Behind every like, every notification, every "Your payment was successful" message, there is a silent engine running somewhere in a data center — often in complete darkness, without a screen, without a mouse, without anyone watching it. That engine is backend code. And for the next three hundred pages, you are going to learn how to build it.Welcome to the invisible half of the internet.If you have written Java Script before, you have probably only seen the frontend — the part users interact with directly. You know how to make a button change color when clicked. You know how to fetch data from an API. But you have never built that API. You have never written the code that stores a user's password, verifies their identity, serves a million profile pictures without crashing, or sends a push notification the instant someone mentions your name. That changes now.This chapter is not about syntax. It is not about which framework is popular this month. It is about understanding the machine you are about to command — the Node.js runtime, the event loop that powers it, and why most backend bugs come from misunderstanding something you cannot see.By the end of this chapter, you will have written your first raw HTTP server, intentionally broken it to observe the event loop freezing, and fixed it using asynchronous patterns. You will understand why Node.js can handle thousands of concurrent connections on a single thread while a traditional server would need hundreds of threads. And most importantly, you will never accidentally block the event loop in production — a mistake that has taken down systems at Netflix, Uber, and Pay Pal.Let us begin.The Illusion of Simultaneity Close your eyes and imagine a chef in a busy restaurant. Orders come in continuously: a steak, a salad, a pasta, another steak. A traditional chef works on one order at a time. They put the steak on the grill, wait for it to cook (staring at it), then move to the salad, then the pasta. Customers wait longer because the chef is idle while food cooks.Now imagine a different chef. They put the steak on the grill, then immediately start chopping the salad. While the salad is being tossed, they boil water for the pasta. When a timer beeps, they flip the steak. This chef is not faster at any single task — the steak still takes ten minutes to cook. But they complete all three orders in the time the first chef finishes just one. This is non‑blocking I/O. This is Node.js.Node.js does not multitask in the way you might think. Your Java Script code runs on a single thread. Only one line of your code executes at any given moment. But when your code asks the operating system to do something slow — read a file, query a database, send an HTTP request — Node.js does not wait. It says "Tell me when you are done" and immediately moves to the next line of code. When the slow operation finishes, Node.js comes back to handle the result.This is radically different from languages like PHP, Ruby (in its traditional configuration), or Python (with standard WSGI servers), where each request typically occupies an entire thread or process, and that thread sits idle while waiting for a database response. Those models can handle hundreds of concurrent users — if you have hundreds of threads and enough memory, because each thread consumes about 2-8 MB just to exist. Node.js starts with a single thread and can handle thousands of concurrent connections because it never sits idle.But this power comes with a trap. If you write code that blocks — code that keeps the thread busy for a long time with calculation, parsing, or synchronous I/O — nothing else can run. The chef stops cooking all orders to stare at a single steak. The server freezes.What Node.js Actually Is Before you write a single line of code, you need to understand what you are working with. Node.js is not a programming language. It is not a framework. It is a runtime — a program that takes Java Script code and executes it outside of a web browser.Two pieces of software make Node.js possible:Chrome's V8 Engine – This is the same engine that runs Java Script in the Google Chrome browser. V8 takes your Java Script and compiles it to machine code at lightning speed. Without V8, your code would be interpreted line by line, orders of magnitude slower.libuv – This is the secret sauce. libuv is a C library that provides an asynchronous event loop, a thread pool, and cross-platform abstractions for file system operations, networking, timers, and child processes. When you call fs.read File or http.get, you are not actually reading a file yourself. You are handing that task to libuv, which does the work using the operating system's native asynchronous interfaces (like epoll on Linux or kqueue on mac OS) or, when necessary, its own thread pool.When you install Node.js from the official website, you get both V8 and libuv bundled together, along with a standard library that exposes these capabilities as Java Script APIs.Here is what Node.js is not:It is not a web server (though you can build one)It is not a database (though you can connect to them)It is not a framework like Express (though Express runs on it)It is not limited to backend development (people use it for command-line tools, desktop apps via Electron, and even Io T devices)Node.js is the environment. Everything else — your code, the frameworks you install, the databases you query — lives inside it.The Browser Is Not the Server If you have written Java Script before, your mental model of "where code runs" is probably the browser. In the browser, you have a window object, a document object, a DOM tree, and events like click and submit. You cannot access the file system. You cannot open arbitrary network connections. You are sandboxed for security.In Node.js, everything changes.There is no window. There is no document. Instead, you have a global object (similar to window, but without the browser-specific properties). You have process, which gives you information about the running process: command-line arguments, environment variables, the current working directory, and the ability to exit the process.You can also access the file system using the fs module. You can create HTTP servers using the http module. You can spawn child processes. You have access to the operating system in ways that a browser would never allow.Here is the most important difference: in the browser, your code runs in response to user actions — clicks, keyboard events, network responses. In Node.js, your code runs from the moment you start the process until you stop it. There is no user closing a tab to free memory. You are responsible for everything: accepting connections, managing memory, handling errors, and shutting down gracefully when the operating system signals that it is time.This is liberating and terrifying. You have complete control. You also have complete responsibility.The Event…

This is the end of the free sample. Get the eBook to keep going. Buy now

About this book

A Coursebook on Backend Development with Node.js

Details

Author
Campos Hyon
Publisher
SamEnrico
Language
English
Genre
Non-Fiction, Informative, Educational
Released
2026-05-04
Pages (approx.)
150
Available as
eBook, Audiobook

Read better in the ZLOADR app

Your eBooks on your phone or tablet. Sign in with your SamEnrico account and start reading.

More by Campos Hyon

See all