Understanding Mern
July 27, 2024
Table of Contents
What is MERN stack?
Mern stack consists of technologies such as ReactJS, Node.js, MongoDB, Express.js. It is completely based on JavaScript. MERN stack is a full stack consisting of frontend, backend and a database.
A simple analogy to understand it better.
Imagine you are in a bookstore and there is inventory to keep track of all the books, brining in books, selling books, it tracks all the transactions happening like a storage system.
MongoDB
is that storage system. It keep track of the files, performs read/write operations. In a bookstore you need staff to take care of the management.
As staff acts like a middleman between the suppliers(database) of books holding conversations with customers(frontend). Express.js that acts like the staff or management in the bookstore. For example, they handle the flow of data, get customer requests, handle transactions.
What is a key attraction in a bookstore? Its aesthetic and environment. Purple aesthetic and Pink aesthetic for the princesses and magic and romance section. Dark and grey for the thriller section, Vintage aesthetic for historical books. Whether the bookshelves are pretty or not, if the layout and architecture are proper and well laid, its the front of the bookstore. React is like that, the frontend of the bookstore where the customers interact with the books and the environment. Customers (users) interact with the storefront (React), explore the shelves (UI components), and make book selections (interactions).
If there needs to be additional books or selling the middleman which is Express.js comes in and React sends these queries to the (Express.js) to fetch or update data. Nodejs is the house that contains the bookstore, it supports the storage (MongoDB), staff (Express.js), Front of the store (React). It acts as the backbone of the stack and operates it.
A brief overview of the technologies:
React
React is one of the most popular JavaScript open-source library used. React is used to build user interfaces. It is used for the frontend. Using react users can make dynamic and responsive web applications. Node.js
Nodejs
Node.js is an open-source, JavaScript runtime environment. It executes JavaScript code outside of a web browser as it can be run as a standalone application. It supports cross-platform which means it works on Windows, OSX, Linux etc. It is lightweight and easy to use framework perfect for beginners to get their hands on.
Express.js
Express is a web framework, written in JavaScript that allows you to create server-side applications. It is hosted within the Node.js runtime environment.
MongoDB
It is a popular open-source NoSQL database management system. It is a document-oriented database used to store, query, manage large amount of data. It can handle unstructured data like It is highly scalable for building web applications.
ADVANTAGES AND DISADVANTAGES OF MERN
-
ADVANTAGES
IT IS ALL JAVASCRIPT
MERN stack is entirely built upon JavaScript, server-side (Node.js) and client-side (React.js) makes it a unified language. It provides consistency, ease with switching between server and client side and overall makes it easier for developers especially beginners to work on it.
SCALABILITY
MERN stack technologies provide high-performance and are extremely scalable.
React.JS: With Virtual DOM, it only updates parts of the DOM that needs to be updated and does it in batches which makes the UI responsive.
Node.js: Node.js is asynchronous, non-blocking I/O model. It can handle multiple requests simultaneously without waiting for each to complete. The asynchronous architecture makes thee application responsive and functions well under heavy loads.
Load Balancing: Node.js can set up load balancing by distributing incoming requests across multiple servers to optimize the resources.
NOSQL DATABASE
MongoDB supports sharding which includes distributing data across multiple servers, it allows the database to handle large volumes of data and perform read/write operations. It uses horizontal scaling so if one of your server goes down your application can still run.
Disadvantages
A learning Curve
As a beginner learning the entire MERN stack can be challenging and confusing as each technologies have their own concepts. You might also want to use third-party libraries which means you need to familiarize yourself with different APIs.
Security Concerns
As you use third parties it can make your application vulnerable and prone to security concerns. It is important to regularly moderate and update dependencies for avoid security mishaps.
Conclusion
In this article, I gave a brief overview on MERN technology and how it all works together. Taking into consideratiion it’s advantages and disadvantages as well. I hope with this article I was able to clear a few doubts!