Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 2

Monolithic vs. Modular Frontends

Recommended resources

Hello again! In our last lesson, we established that frontend architecture is driven by the need to balance key quality attributes like scalability, maintainability, and performance. We learned that there's no single "best" architecture, only a series of trade-offs.

Today, we'll apply that thinking to one of the most fundamental architectural decisions you can make: how to structure your application's codebase and deployment units. This lesson directly addresses the choice between monolithic and more modular architectures. You'll learn to compare these patterns not just as technical styles, but as solutions to different organizational and developmental challenges. This will equip you to decide when a simple, unified structure is best, and when the needs of a large, growing team justify the complexity of a more distributed system.

Untangling the Terminology

The conversation around "monoliths" and "micro-frontends" is often confusing because several distinct concepts get bundled together. Before we compare them, it's crucial to separate these ideas. The best architectural discussions are based on precise language.

Monoliths, Microfrontends, Monorepos, and the Real Tradeoffs

This article by Steve Kinney provides an exceptionally clear framework for thinking about these patterns. It argues that we're often confusing three separate debates.

Read the introduction and the section "The Three Axes People Confuse". Pay close attention to the distinction between: Runtime architecture (monolith vs. microfrontend) Repository topology (monorepo vs. polyrepo) Deployment topology (single vs. multiple deployables)

As the article clarifies, our main focus today is on the runtime architecture: is your application composed and delivered as a single unit (a monolith), or as a collection of independently deliverable applications (micro-frontends)? The choice of repository structure (monorepo/polyrepo) is a related but separate decision.


The Monolithic Architecture: The Default Starting Point

A monolithic frontend is an application built and deployed as a single, indivisible unit. All features, components, and assets are part of one codebase and release cycle.

This diagram illustrates the structural difference between a monolithic application and a micro-frontend approach. In the monolith, the entire web application layer is a single entity, often built with one framework like React.

While the term "monolith" sometimes has a negative connotation, a well-structured monolith is often the best choice, especially for new projects and smaller teams. The real enemy is not the monolith itself, but what it can become without discipline: a "Big Ball of Mud" where everything is tangled together.

To avoid this, we strive to build a Modular Monolith. This is still a single deployable application, but its internal codebase is organized into distinct, loosely-coupled modules with clear boundaries.

This diagram shows a logical progression. A simple "Monolithic Frontend" can evolve into a "Modular Monolith" by organizing code into domains. This modular structure can, if necessary, later be broken out into separate "Microfrontends."

Let's dig into the characteristics and trade-offs of the monolithic approach.

Frontend System Design: Micro Frontends, Monolith vs MFE

This article offers a practical breakdown of what a monolithic frontend entails, its build cycle, and its inherent pain points when an organization scales.

Read the entire section on Monolithic Frontend Architecture. The diagram of the "Coupling Cascade" is particularly insightful for understanding how monolithic codebases degrade over time without strong internal boundaries.

As you've just read, the monolithic approach has clear trade-offs when viewed through the lens of our quality attributes:

Advantages:

  • Simplicity & Maintainability (initially): A single codebase, build tool, and deployment pipeline is simpler to set up and manage. It's easier for a small team to reason about the entire system.
  • Performance: All dependencies can be optimized into a single, de-duplicated bundle (with code-splitting for routes). There's no runtime overhead from fetching separate applications.
  • Consistency: It's straightforward to enforce a single design system, shared component library, and state management strategy.

Disadvantages (at scale):

  • Development Scalability: This is the biggest challenge. As more developers contribute, you face increased merge conflicts, longer build and test times, and cognitive overhead. It becomes difficult for teams to work without stepping on each other's toes.
  • Reliability: The entire application is deployed as one unit. A bug in a minor feature can block the release of critical fixes, or even bring down the entire application in production.
  • Maintainability (long-term): Without strict discipline, boundaries between modules erode. This tight coupling makes the code brittle and difficult to change or refactor.

This video humorously but accurately captures the developer experience as a monolithic application grows in complexity.

Micro Frontend Architecture in Angular 🔥 | Monolithic vs Micro FE | Real-World Setup Explained

In "Micro Frontend Architecture in Angular," the speaker uses a series of memes to illustrate how developer productivity and confidence decline as a monolith ages.

Watch the segment from this point. It vividly illustrates the "Pain Points at Scale" we've been discussing, from initial happiness to the eventual fear of deploying changes.


Micro-Frontends: Solving Organizational Scale

Micro-frontends are an architectural style where a web application is composed of multiple, independently deliverable frontend applications.

Think of an e-commerce site. In a micro-frontend architecture, the search team, the product detail team, and the checkout team could each own their application end-to-end. They would develop, test, and deploy their part of the site without coordinating with the other teams. An "application shell" or "host" application would then be responsible for loading and composing these independent frontends into a cohesive user experience.

The primary driver for adopting micro-frontends is to solve the development scalability problem. It's an organizational pattern more than a purely technical one.

Every Frontend Architecture Pattern Explained in 23 Minutes

The video "Every Frontend Architecture Pattern Explained" provides a concise explanation of the micro-frontend concept.

Watch the segment on microfrontends. Notice how the explanation is framed around team independence and the ability for a large number of developers to contribute in parallel.

Let's examine the trade-offs.

Advantages:

  • Development Scalability: Autonomous teams can ship features independently, leading to faster delivery cycles in large organizations.
  • Clear Ownership: Teams have full ownership of their vertical slice of the product, fostering accountability and expertise.
  • Resilience (Fault Isolation): If one micro-frontend fails, it doesn't necessarily take down the entire application. The host can display an error for that section while the rest of the site remains functional.
  • Technology Flexibility: Teams can, in theory, use different frameworks or upgrade their stacks independently. This is most valuable for incremental migrations of legacy applications.

Disadvantages:

  • Operational Complexity: This is the biggest drawback. You now have multiple repositories, build pipelines, servers, and deployment processes to manage. This requires significant DevOps maturity.
  • Performance: There is a risk of performance degradation due to duplicated dependencies (e.g., each micro-frontend loading its own copy of React) and the overhead of fetching multiple application bundles at runtime.
  • Consistency: Maintaining a consistent user experience, design system, and accessibility standards across independent teams requires strong governance and shared tooling.
  • Complex Communication: Sharing state or coordinating actions between micro-frontends is much harder than within a monolith and requires explicit contracts like custom events or using the URL as a state mechanism.

This video section clearly outlines these benefits.

Micro Frontend Architecture in Angular 🔥 | Monolithic vs Micro FE | Real-World Setup Explained

This video also provides a clear list of the benefits that micro-frontends offer.

Watch the segment on the benefits. It covers faster development, smaller codebases, improved scalability, increased resilience, and technology flexibility.


Making the Choice: A Framework for Decision

The decision to use a monolith or micro-frontends is a trade-off between simplicity and scalability. There's an inflection point where the coordination overhead of a growing monolith becomes more painful than the operational complexity of micro-frontends.

Frontend System Design: Micro Frontends, Monolith vs MFE

This article provides an excellent set of heuristics for making the decision.

First, study the table and the graph in the section Monolith vs Micro Frontend Tradeoffs. The graph visualizing the "Crossover point" is a key concept. Next, review the Decision Flowchart and the Quick Decision Matrix. These provide concrete, situation-based recommendations that are extremely useful in practice.

The key takeaway from this analysis is clear and is echoed by most experienced architects:

Start with a modular monolith.

Do not choose micro-frontends from day one unless you are in a large organization with pre-existing, well-defined team boundaries and a clear need for independent deployment. The complexity tax of micro-frontends is too high for small teams and early-stage products. Instead, focus on building a monolith with strong internal module boundaries. This gives you a clean, maintainable architecture that can be evolved and, if the organizational need arises, broken apart into micro-frontends later.

Monoliths, Microfrontends, Monorepos, and the Real Tradeoffs

This article concludes with very direct and actionable advice on how to choose.

Read the final two sections, "How to Choose" and "The Recommendation I Would Actually Give". This reinforces the "monolith first" strategy and provides clear questions to ask before moving to micro-frontends.


Conclusion

In this lesson, we dissected two major architectural patterns and evaluated them against the quality attributes we learned previously. You now have a robust framework for making this critical decision.

Here are the key takeaways:

  • Monolithic Architecture: A single, deployable unit. It's simple, fast to start with, and ideal for smaller teams and projects where the domain is not yet stable. Its main weakness is poor development scalability.
  • Modular Monolith: The recommended default. It's a monolith with disciplined internal boundaries, offering good maintainability without the operational overhead of a distributed system.
  • Micro-Frontend Architecture: An application composed of independently deployable frontends. It solves organizational scaling problems for large, autonomous teams but introduces significant operational complexity.
  • The Decision: The choice is a trade-off between organizational scalability and operational complexity. The right answer depends on your team's size, structure, and the maturity of your product. Always ask: "What organizational problem am I trying to solve?"

In our next lesson, we will move from the structure of the codebase to the structure of the application itself. We will explore another fundamental choice: evaluating when to choose a single-page application (SPA) versus a multi-page application (MPA). This will bring rendering strategies and the user's navigation experience to the forefront of our architectural analysis.