Skip to main content

Welcome to a Grasp lesson

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

Lesson 8

Introduction to Architectural Patterns

Recommended resources

Hello! Welcome to your final lesson in the "Foundations of System Architecture" module.

In our last lesson, we contrasted the high-level architectural styles of monolithic, service-oriented, and microservice architectures. We saw how they represent different strategies for applying the "Separation of Concerns" principle to an entire system.

Today, we will zoom in to explore the building blocks used to construct these systems. Our learning outcome is to describe common architectural patterns (e.g., Layered, Event-Driven) at a high level. These patterns are like the proven design blueprints in an architect's toolkit. Understanding them provides you with a crucial vocabulary for discussing, designing, and evaluating software systems.

This lesson bridges the gap between the high-level styles we've discussed and the more detailed design decisions you'll make as an architect. Mastering this vocabulary is essential for communicating your architectural vision and justifying the "Why" behind your choices.

1. Architecture Patterns vs. Design Patterns

Before we dive into specific patterns, it's important to clarify a common point of confusion: the difference between architectural patterns and design patterns.

  • Architectural Patterns define the fundamental structure of a software system. They are high-level and concern the overall organization of components, their responsibilities, and the relationships between them (e.g., how the UI, business logic, and database interact).
  • Design Patterns are more granular. They provide reusable solutions to common problems within a component or a small group of related components (e.g., how to create objects, or how to structure a class to allow its behavior to be changed at runtime).

To solidify this distinction, please read the following brief explanation.

Enterprise software architecture patterns: The complete guide

The article 'Enterprise software architecture patterns: The complete guide' by vfunction clearly distinguishes between these two concepts.

Please read the section titled 'Software architecture patterns vs. design patterns'. Focus on understanding the difference in scope and level of abstraction.

Think of it this way: the architectural pattern is like deciding whether to build a skyscraper (monolith) or a campus of smaller buildings (microservices). The design patterns are like deciding how to design the internal plumbing, electrical wiring, or room layouts within each building.


2. A Visual Overview of Common Patterns

There are many architectural patterns, each suited to different kinds of problems. Let's start with a visual overview to get a sense of the variety.

Overview of Software Architecture Patterns
This image provides a quick visual reference for several patterns we will discuss, including Layered, Event-Driven, and Pipes and Filters. It also recaps Monolithic and Microservices, which we covered as architectural styles.

Now, let's explore some of the most important patterns from this collection in more detail.


3. Layered (N-Tier) Architecture

The Layered pattern is one of the most traditional and widely used. It organizes a system into horizontal layers, where each layer has a specific responsibility. A request moves sequentially from the top layer to the bottom.

The most common implementation is a 3-tier architecture:

  1. Presentation Layer: The user interface (e.g., a web page or mobile app screen).
  2. Business Logic Layer: Contains the core application logic and business rules.
  3. Data Access Layer: Responsible for communicating with the database.

Top 9 Software Architecture Patterns Every Developer Must Know!

The video 'Top 9 Software Architecture Patterns' from ByteMonk provides a clear, concise explanation of the Layered pattern with a practical e-commerce example.

Watch from 00:34 to 01:50. Pay attention to how the e-commerce site functions are separated into the presentation, business logic, and data access layers.

Key Characteristics:

  • Separation of Concerns: Each layer handles a distinct aspect of the application.
  • Request Flow: Layers are typically "closed," meaning a request must pass through the layer directly above it. For example, the presentation layer can only call the business layer, not the data layer directly.
  • When to use it: This is the default pattern for many traditional enterprise applications and simple web apps. It's often the internal structure of a monolithic application. It's easy to understand and get started with.
  • Trade-offs: While simple and well-organized, it can become rigid. A small change might require modifications across multiple layers. It can also lead to performance overhead as data is passed between layers.

4. Event-Driven Architecture (EDA)

In contrast to the direct, synchronous calls of a Layered architecture, the Event-Driven Architecture (EDA) uses asynchronous communication. Components communicate by producing and consuming events.

  • An event is a message that signifies a state change or an action (e.g., OrderPlaced, UserRegistered).
  • Producers are components that generate and publish events.
  • Consumers are components that subscribe to events and react to them.

This is all orchestrated by a message bus or event broker, which routes events from producers to interested consumers.

Top 5 Most Used Architecture Patterns

This clip from the ByteByteGo channel illustrates the core concept of EDA, highlighting its decoupled nature.

Watch from 01:27 to 02:15. Focus on how components broadcast and subscribe to events, which allows for a 'highly decoupled' system.

Key Characteristics:

  • Loose Coupling: Producers don't know who the consumers are, and vice-versa. You can add new consumers without changing the producers at all.
  • Asynchronous: The producer fires an event and doesn't wait for a response. This makes the system highly responsive.
  • When to use it: Ideal for systems that need to react to changes in real-time, such as IoT platforms, financial trading systems, or modern web applications with complex workflows. It is the backbone of many microservice-based architectures, enabling communication without tight dependencies.
  • Trade-offs: While highly scalable and flexible, EDA introduces complexity. Tracing a request that spans multiple events can be difficult, and ensuring data consistency across asynchronous services (eventual consistency) is a significant challenge. This increases the need for sophisticated monitoring and observability, which aligns with your experience in IT infrastructure.
Test your understanding!

Imagine you are designing an e-commerce platform. When a customer places an order, the system needs to:

  1. Process the payment.
  2. Update the inventory.
  3. Send a confirmation email to the customer.
  4. Notify the shipping department.

How would you implement this workflow using a Layered architecture versus an Event-Driven architecture? What is the key difference in the communication flow?

Show answer
  • Layered Architecture: The business logic layer would likely have an PlaceOrder method. This method would make a series of synchronous, direct calls: first to a payment service, then to an inventory service, then to an email service, and finally to a shipping service. If any of these calls fail, the entire process might have to be rolled back. The PlaceOrder method has to know about and directly orchestrate all the other services.

  • Event-Driven Architecture: The UI service would publish an OrderPlaced event to a message bus. Four separate, independent consumer services would be listening for this event: a Payment service, an Inventory service, a Notification service, and a Shipping service. Each one would receive the event and perform its task concurrently and independently.

  • Key Difference: The Layered approach uses orchestration (a central controller making direct calls), leading to tighter coupling. The Event-Driven approach uses choreography (independent components reacting to events), leading to looser coupling.


5. Other Notable Patterns

Let's briefly touch on a few other important patterns to round out your vocabulary.

Microkernel (or Plugin) Architecture

This pattern is ideal for systems that need to be extensible. It consists of a minimal core system and a set of plugins or extensions that provide additional features.

Think of an IDE like VS Code or Eclipse. The core application provides basic text editing and a windowing system. Features like Java support, Git integration, or a database client are all added as plugins.

  • When to use it: Web browsers, IDEs, and other applications where third-party developers can add functionality.
  • Key Benefit: High extensibility and fault isolation (a crashing plugin usually won't take down the core system).

Pipes and Filters Architecture

This pattern is excellent for processing streams of data. It consists of a series of processing steps (filters) connected by channels (pipes). Data enters one end, flows through the pipes, and is transformed by each filter in sequence.

The classic example is using pipes on a UNIX command line:
cat logfile.log | grep "ERROR" | sort | uniq > errors.txt

Here, cat, grep, sort, and uniq are the filters, and the | symbol is the pipe.

  • When to use it: Data processing pipelines (ETL jobs), data analytics, and compilers.
  • Key Benefit: Simplicity and reusability. Each filter does one thing well, and you can easily compose them into complex workflows.

6. Comparing the Patterns and Making a Choice

As an architect, your job isn't to know that these patterns exist, but to understand their trade-offs so you can choose the right one for a given problem. There is no "best" pattern.

The following resource provides an excellent comparative analysis that will help you think about these trade-offs systematically.

Enterprise software architecture patterns: The complete guide

The vfunction article provides a detailed table comparing major patterns across dimensions like scalability, complexity, and performance.

Please read the section 'Comparative analysis of enterprise architecture patterns'. Focus on the comparison table and the subsequent explanations of performance and maintenance considerations. You don't need to memorize the details, but aim to understand the reasoning behind the comparisons.

To bring this home to your goal of being a freelance consultant, a key skill is asking the right questions to guide the architectural decision process.

Choosing Software Architecture Patterns for Business ...

The article 'Choosing Software Architecture Patterns for Business...' provides a set of critical questions to ask when selecting an architecture. This aligns perfectly with your goal of understanding the 'Why'.

Read the final section, 'Making the Right Choice: Key Questions for Your Team'. Think about how you would use these questions in a conversation with a potential client to understand their needs and guide them to an appropriate architectural solution.


Conclusion

This lesson concludes our foundational module. We've journeyed from the role of an architect and key quality attributes to high-level architectural styles and, finally, to the specific architectural patterns that bring those styles to life.

Key Takeaways:

  • Architectural patterns are high-level, reusable blueprints for structuring a software system.
  • Layered Architecture organizes a system into strict layers (e.g., presentation, business, data), promoting separation of concerns through direct, synchronous communication. It's simple but can be rigid.
  • Event-Driven Architecture uses asynchronous events to create loosely coupled, highly scalable systems. It's flexible and resilient but introduces operational complexity.
  • Other patterns like Microkernel and Pipes and Filters solve specific problems related to extensibility and data processing, respectively.
  • Choosing a pattern is a matter of analyzing trade-offs based on the system's required quality attributes (scalability, maintainability, etc.) and business goals.

You now have a foundational vocabulary of architectural styles and patterns. In our next module, "Architecting Network Communication," we will move from these logical structures to the physical realities of how system components talk to each other. We'll start at the ground level by exploring IP addresses, ports, and sockets from an application design perspective, a topic you specifically requested, linking your deep infrastructure knowledge to the world of software architecture.