Node js Architecture in less than 5 minutes!

Subscribe to my newsletter and never miss my upcoming articles

Get a cookie into your mouth, get finished this read before the cookie ends up!

So, You want to know the architecture behind Node js, right?

Just take a tour under this section!

What is Node js?

We all know Node js is-

  • an environment to run Javascript outside a browser.

  • a server-side framework.

  • Open source runtime to communicate with the server.

  • Created by Ryan Dhal in 2009, it has evolved since creation to allow developers to build almost anything!

Take a deep breath and rethink! Javascript outside a browser? Seriously! With a machine? With a server? How come?

These questions may be puzzled you many times, isn’t it?

When we are going to elaborate on the architecture behind Node js, we have to move with the dependencies it has.

First of all, Node js built based on Google Chrome’s V8 Engine, which itself made for running javascript on the browser (Chrome). If it was not for the V8 engine, Node would have absolutely no way to understand javascript code. That means V8 is a fundamental part of Node Architecture.

V8 engine helps to convert javascript code to machine code, that a computer can actually understand.

But only V8 is not enough for a server-side framework to be worked. There has to be something that can connect and make deals with the computer operating system. And here comes the mighty Libuv to play this role!

So, what is Libuv?

Libuv is an open-source library with a strong focus on asynchronous IO and input-output duo! It gives node access to the underlying computer operating system, file system, networking, and more.

But not the end. Event Looping and Thread pool are two extremely important features of node js. You got it! Libuv implements them as well.

LibuvLibuv

Libuv create a layer to get access to a computer operating system, file system, networking, and many more

What Event loop does?

Event loop is responsible for handling easy tasks like executing Callbacks and Network IO.

And what about the Thread pool?

Well, Thread Pool is for more heavy work like file access or compression.

Note, libuv is actually completely written in C++ and not in JavaScript. Besides javascript, V8 itself, also uses C++ code. Heart breaking news for Javascript lover, right?

Well, my friend, the beauty of this is that Node JS makes a connection between all these libraries, no matter if written in C++ or JavaScript. And now we developers have access to their functions in pure JavaScript!

How our life is easier than before? Just think, you don’t have to do all these pieces of stuff with C++ and get messed!

So what other libraries that I mentioned by saying ‘all these libraries’?

Actually, only V8 engine and Libuv are not enough for Node js to completely work!

It has to parse Http, some DNS request stuff, Kleptography. and compression!

These 4 C++ Libraries help Node to do these kinds of stuff.

  • Http-parser for Parsing Http.

  • C-ares or something like that for some DNS request stuff

  • OpenSSL for Kleptography.

  • Zlib for compression.

To make this read no longer than 5 minutes, I have to ring the bell here and not going to discuss all these libraries and their tasks. It is enough for you to get the main idea of Node architecture! After having all these libraries nicely fit together, we end up with Node JS ready to be used on the server-side. Have a great future on node js, folks!

Comments (2)

Lotifur Shabbir's photo

Learn two different things from this. Thank you Brother. Keep going.

Nure Kamal Mithu's photo

Welcome brother.. Really inspiring for me! Keep me on your prayers!