Node.js Architecture - Introduction to Node.js

Node.js Architecture - Introduction to Node.js

Daily short news for you
  • For over a week now, I haven't posted anything, not because I have nothing to write about, but because I'm looking for ways to distribute more valuable content in this rapidly exploding AI era.

    As I shared earlier this year, the number of visitors to my blog is gradually declining. When I looked at the statistics, the number of users in the first six months of 2025 has dropped by 30% compared to the same period last year, and by 15% compared to the last six months of 2024. This indicates a reality that users are gradually leaving. What is the reason for this?

    I think the biggest reason is that user habits have changed. They primarily discover the blog through search engines, with Google being the largest. Almost half of the users return to the blog without going through the search step. This is a positive signal, but it's still not enough to increase the number of new users. Not to mention that now, Google has launched the AI Search Labs feature, which means AI displays summarized content when users search, further reducing the likelihood of users accessing the website. Interestingly, when Search Labs was introduced, English articles have taken over the rankings for the most accessed content.

    My articles are usually very long, sometimes reaching up to 2000 words. Writing such an article takes a lot of time. It's normal for many articles to go unread. I know and accept this because not everyone encounters the issues being discussed. For me, writing is a way to cultivate patience and thoughtfulness. Being able to help someone through my writing is a wonderful thing.

    Therefore, I am thinking of focusing on shorter and medium-length content to be able to write more. Long content will only be used when I want to write in detail or delve deeply into a particular topic. So, I am looking for ways to redesign the blog. Everyone, please stay tuned! 😄

    » Read more
  • CloudFlare has introduced the pay per crawl feature to charge for each time AI "crawls" data from your website. What does that mean 🤔?

    The purpose of SEO is to help search engines see the website. When users search for relevant content, your website appears in the search results. This is almost a win-win situation where Google helps more people discover your site, and in return, Google gets more users.

    Now, the game with AI Agents is different. AI Agents have to actively seek out information sources and conveniently "crawl" your data, then mix it up or do something with it that we can't even know. So this is almost a game that benefits only one side 🤔!?

    CloudFlare's move is to make AI Agents pay for each time they retrieve data from your website. If they don’t pay, then I won’t let them read my data. Something like that. Let’s wait a bit longer and see 🤓.

    » Read more
  • Continuing to update on the lawsuit between the Deno group and Oracle over the name JavaScript: It seems that Deno is at a disadvantage as the court has dismissed the Deno group's complaint. However, in August, they (Oracle) must be held accountable for each reason, acknowledging or denying the allegations presented by the Deno group in the lawsuit.

    JavaScript™ Trademark Update

    » Read more

Issues

Hello readers of 2coffee.dev, the Node.js Architecture is a series of articles I wrote a long time ago, from the early days of blogging. Over time, this series has attracted a lot of attention. However, the expression was still vague and not to the taste of readers, so today I have decided to rewrite some articles in this series to express myself better and update a few new pieces of information.

This series provides readers with an overview of the architectural model of Node.js and how it works. This will help readers understand how Node.js executes the written programs. From there, one can learn how to optimize and organize the code better.

The planned number of articles is 4. The contents of each part are interrelated, so you should not skip any articles; please read them in order to follow along consistently. In the first article, I will recap some information about JavaScript, along with the basic concept of Node.js. What is the relationship between JavaScript and Node.js?

JavaScript

JavaScript is no stranger to anyone in the programming community. JavaScript reigns supreme in browsers, being the most widely used language for programming interfaces. Thanks to it, we have the rich web experiences we have today. Many websites focus on interaction and unique user experience to attract users' attention.

JavaScript was created in 10 days by Brandan Eich, an employee of Netscape, in September 1995. Originally named Mocha, it was later renamed Mona and then LiveScript before finally becoming the well-known JavaScript we know today.

In 1996, JavaScript was officially named ECMAScript. ECMAScript 2 was released in 1998, and ECMAScript 3 followed in 1999. It has continuously evolved into the JavaScript we have today, which now runs on most browsers and on devices ranging from mobile to desktop. As of 2016, over 92% of websites used JavaScript, and it currently ranks first on GitHub regarding the popularity of projects utilizing JavaScript.

JavaScript in the Browser and JavaScript Runtime

JavaScript can only run when the browser supports JavaScript. This means that the browser is the entity that decides the execution of JavaScript code. To achieve this, most modern browsers must have a JavaScript Engine, which is a component responsible for interpreting and executing JavaScript code.

The JavaScript Engine plays the role of converting JavaScript code into machine code. The JavaScript Engine functions as an interpreter, comprising a Memory Heap (which stores objects like variables and functions) and a Call Stack (which executes functions).

JavaScript Engine

Creating or producing JavaScript Engines can be costly, and sometimes they may not align with available resources. Therefore, browsers often choose to integrate an existing JavaScript Engine that fits their product development philosophy.

For example, Chrome uses the V8 JavaScript Engine, Mozilla Firefox uses the SpiderMonkey JavaScript Engine, and Microsoft Edge (old version) before using the Chromium engine used the Chakra JavaScript Engine.

Additionally, browsers provide Web APIs that allow JavaScript code to access certain objects like window and document. These are not specifications of JavaScript. They are created by the browser and allow JavaScript to interact.

Because browsers use different JavaScript Engines, they may interpret JavaScript code differently. This leads to situations where some code can yield different results. This is evidenced by a website that runs smoothly on Chrome but behaves unexpectedly on IE or Firefox.

Thus, Ecma International has established rules for naming JavaScript versions, along with efforts to standardize JavaScript in browsers with the hope of eliminating fragmentation. ES5 is the ECMAScript version from 2009 to 2015, and from 2015 onwards, versions have been released sequentially as ES6 - 2015, ES7 - 2016, and so on. Each year, the committee approves and releases the next version. As of the time of writing this article in 2021, there is ES12. Each version brings improvements and new features; however, the implementation depends entirely on whether the browser developers support it.

In summary, despite having a complete specification, whether to adhere to it or not remains uncertain. This has been a persistent issue to this day.

What is the Relationship between JavaScript and Node.js?

JavaScript was initially the most popular programming language for web interfaces in the world. Recognizing the potential of JavaScript, what if developers could use only JavaScript to program servers? Node.js was created with the effort to bring JavaScript to server-side development.

In 2009, Ryan Dahl decided to use the fastest JavaScript Engine - Chrome's V8 - to make it work in a server environment, laying the foundation for the birth of Node.js. Node.js uses the V8 Engine to interpret JavaScript code into machine code. Since Node.js is written for operating systems rather than browsers, some Web APIs for browsers like window and document are not implemented in Node.

It is also essential to note that Node.js does not support all JavaScript features (ECMAScript standards) immediately but must do so through updates. This means that if you want to use new ES features, you must wait for updates.

In summary, Node.js provides a runtime environment for JavaScript outside the browser.

You can refer to the installation guide for Node.js Installing Node.js, Running Your First Node.js Application.

Is Node.js a Programming Language?

No! Node.js is just a runtime environment for JavaScript. In fact, Node only provides a runtime environment for JavaScript through Chrome's V8 Engine.

Below are a few conclusions about Node.js.

  • Node.js is not a programming language.
  • Node.js is not a Framework for server applications; it is a platform.
  • Node.js provides a runtime environment for server-side JavaScript.

Node.js is composed of many interconnected components that create a perfect environment. Below is a diagram describing the architecture of Node.js:

Architecture Model

The components are described as follows:

  • V8: This is the V8 Engine from Chrome, which includes Memory Heap, Call Stack, Garbage Collector, and converts JavaScript code into machine code for the operating system.
  • Libuv: This is an important library that includes Thread Pool and Event Loop, Event Queue. It is a cross-platform C library focusing on asynchronous I/O tasks.
  • Node.js Standard Library: This includes libraries and functions related to the operating system for Timers like setTimeout, File system like fs, Network Calls like http.
  • llhttp: Parses HTTP request/response (formerly known as http-parse).
  • c-ares: A C library for asynchronous DNS used in the dns module.
  • open-ssl: Functions for encryption used in TLS (SSL), crypto module.
  • zlib: Compression and decompression functions that can run synchronously, asynchronously, and streaming.
  • Node.js API: Provides JavaScript API used by applications.

Conclusion

Node.js is not a programming language but a runtime environment for server-side JavaScript, built on Chrome's V8 Engine. With the ability to convert JavaScript code into machine code and provide distinct APIs, Node.js enables developers to extend the use of JavaScript beyond the browser, facilitating the development of modern server applications. The architecture of Node.js consists of several crucial components such as V8, Libuv, Node.js Standard Library, llhttp, c-ares, open-ssl, and zlib, each component performing specific tasks to ensure performance and flexibility. Notably, Libuv plays a core role with Event Loop and Thread Pool, helping Node.js efficiently handle asynchronous I/O tasks.

This is just the introduction, and the subsequent parts of the series will delve deeper into how the components of Node.js interact to create a complete system. Please stay tuned to explore more details about this powerful technology.

References:

Premium
Hello

The secret stack of Blog

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.

Comments (0)

Leave a comment...