What is the MEAN Stack?

What is the MEAN Stack?

The MEAN stack is a full-stack, JavaScript-based framework for developing web applications. MEAN stands for MongoDB Express Angular Node, after the four key technologies that make up the different layers of the stack.

  • MongoDB - document database
  • Express(.js) - Node.js web framework
  • Angular(.js) - a client-side JavaScript framework
  • Node(.js) - the premier JavaScript web server

There are variations to the MEAN stack such as MERN (replacing Angular.js with React.js) and MEVN (replacing Angular.js with Vue.js), but regardless of which client-side framework is your favorite, MEAN is the ideal JavaScript stack, from top to bottom.



How does the MEAN stack work?

The MEAN architecture is designed to make building web applications in JavaScript, and handling JSON, incredibly easy. Mean Stack Diagram


Angular.js Front End

At the very top of the MEAN stack is Angular.js, the self-styled “Superheroic JavaScript MVW Framework” (MVW stands for “Model View and Whatever”).

Angular.js allows you to extend your HTML tags with metadata in order to create dynamic, interactive web experiences much more powerfully than, say, building them yourself with static HTML and JavaScript (or jQuery).

Angular has all of the bells and whistles you’d expect from a front-end JavaScript framework, including form validation, localization, and communication with your back-end service. So how do you build the service it talks to?


Express.js and Node.js Server Tier

The next level down is Express.js, running on a Node.js server. Express.js calls itself a “fast, unopinionated, minimalist web framework for Node.js,” and that is indeed exactly what it is.

Express.js has powerful models for URL routing (matching an incoming URL with a server function), and handling HTTP requests and responses. By making XML HTTP Requests (XHRs) or GETs or POSTs from your Angular.js front-end, you can connect to Express.js functions that power your application.

Those functions in turn use MongoDB’s Node.js drivers, either via callbacks for using Promises, to access and update data in your MongoDB database.


MongoDB Database Tier

If your application stores any data (user profiles, content, comments, uploads, events, etc.), then you’re going to want a database that’s just as easy to work with as Angular, Express, and Node.

That’s where MongoDB comes in: JSON documents created in your Angular.js front end can be sent to the Express.js server, where they can be processed and (assuming they’re valid) stored directly in MongoDB for later retrieval.

Again, if you’re building in the cloud, you’ll want to look at MongoDB Atlas. If you’re looking to set up your own MEAN stack, read on!



Is MEAN a full-stack solution?

Yes, MEAN follows the traditional 3-tier stack pattern, including the display tier (Angular.js), application tier (Express.js and Node.js), and database tier (MongoDB).



Why choose the MEAN stack?

If you’re building a JavaScript application, particularly in Node.js, then you should give MEAN a serious look.

MongoDB stores data in a JSON-like format (BSON, a binary JSON extension), the MongoDB Query Language (MQL) is defined in JSON, and its command line interface (CLI) is a JavaScript interpreter. Not only is MongoDB essentially a JavaScript/JSON data store, it’s full of advanced features like indexing and querying deep into JSON documents, has powerful native Node.js drivers, and is designed for horizontal scale-out. It’s even easier to develop apps in the cloud using MongoDB Atlas, the cloud-native database-as-a-service from the creators of MongoDB.

The E and A of MEAN (Express and Angular) are two of the most popular and well-supported JavaScript frameworks for back-end and front-end development, respectively. Express makes routing and managing HTTP requests and responses super easy, and includes great support for middleware to handle JSON endpoints and form posts. Angular is a powerful tool for building dynamic HTML pages that communicate with a back-end server.

Whether you’re building a high-throughput API, a simple web application, or a microservice, MEAN is the ideal stack for building Node.js applications.



MEAN Stack Use Cases

While MEAN is particularly suited to real-time applications, particularly those running natively in the cloud, and single-page (dynamic) web applications built in Angular.js, it can be used many ways.

  • Workflow management tools
  • News aggregation sites
  • Todo and Calendar applications
  • Interactive forums

And much much more.





Get Started Free with MongoDB Atlas

Run MongoDB in the cloud for free with MongoDB Atlas. No credit card required.