Chapter 2. Designing a MEAN stack architecture
This chapter covers
- Introducing a common MEAN stack architecture
- Single-page applications
- Discovering alternative MEAN stack architectures
- Designing an architecture for a real application
- Planning a build based on architecture design
In chapter 1, we took a look at the component parts of the MEAN stack and how they fit together. In this chapter, we’re going to look in more detail at how they fit together.
We’ll start off by looking at what some people think of as the MEAN stack architecture, especially when they first encounter the stack. Using some examples, we’ll explore why you might use a different architecture and then switch things up a bit and move things around. MEAN is a powerful stack that can be used to solve a diverse range of problems ... if you get creative with how you design your solutions.
A common way to architect a MEAN stack application is to have a representational state transfer (REST) API feeding a single-page application (SPA). The API is typically built with MongoDB, Express, and Node.js, with the SPA being built in Angular. This approach is particularly popular with those who come to the MEAN stack from an Angular background and are looking for a stack that provides a fast, responsive API. Figure 2.1 illustrates the basic setup and data flow.