Have you ever thought about how to design a large enterprise system? Before starting any major software development, we first have to pick a suitable architecture. That architecture has to give us the functionality and the quality guarantees we need. So before applying these architectures to our design, we should understand the different architectural systems.

1. What Is an Architecture Pattern
According to Wikipedia,
An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design patterns, but have a broader scope.
In this article, I will briefly introduce the usage, advantages, and disadvantages of the following ten common architectural patterns.
- Layered pattern
- Client-server pattern
- Master-slave pattern
- Pipe-filter pattern
- Broker pattern
- Peer-to-peer pattern
- Event-bus pattern
- Model-view-controller pattern
- Blackboard pattern
- Interpreter pattern
2. Layered Pattern
This pattern is used to build programs that can be decomposed into a group of subtasks, each of which is a particular level of abstraction. Each layer provides services to the layer above it.
Below are the four most common layers in a general information system:
- Presentation layer (also known as the UI layer)
- Application layer (also known as the service layer)
- Business logic layer (also known as the domain layer)
- Data layer (also known as the persistence layer)
Usage:
- Common desktop applications
- E-commerce web applications

3. Client-Server Pattern
This pattern consists of two parts, one server and multiple clients. The server component provides services to multiple client components. Clients request services from the server, and the server provides the corresponding services to those clients. In addition, the server keeps listening for client requests.
Usage:
- Online applications, for example email, document sharing, and banking

4. Master-Slave Pattern
This pattern consists of two parts, master and slaves. The master component distributes tasks to identical slave components, and after collecting the results returned by the slaves, it computes the final result.
Usage:
- In database replication, the master database acts as the authoritative database and the slave databases synchronize from it
- In computer systems, peripheral devices connected to a bus (master and slave drives)

5. Pipe-Filter Pattern
This pattern is used to build systems that produce and process a data stream. Each processing step contains a filter component. The data to be processed can then pass through the pipe. These pipes can serve as buffers or for synchronization.
Usage:
- Compilers. A series of filters performs lexical analysis, parsing, semantic analysis, and code generation
- Bioinformatics workflows

6. Broker Pattern
This pattern is used to build distributed systems with decoupled components. These components communicate through remote calls. The broker component is responsible for coordinating communication among the other components.
A service publishes its capabilities (service address and features) to the broker. When a client requests a service from the broker, the broker looks up the registry and redirects the client’s request to a suitable service address.
Usage:
- Message middleware, for example Apache ActiveMQ, Apache Kafka, RabbitMQ, and JBoss Messaging

7. Peer-to-Peer Pattern
In this pattern, each component is called a peer. A peer can act as a client, requesting services from other peers, or as a server providing services to other peers. A peer can play the role of client or server, or both at the same time, and can change its role at any moment.
Usage:
- File-sharing networks, for example Gnutella and G2
- Multimedia protocols, for example P2PTV and PDTP

8. Event-Bus Pattern
This pattern mainly deals with events and has four major components: event source, event listener, channel, and event bus. An event source publishes messages to a specific channel on the event bus. Event listeners subscribe to specific channels. When a message enters a channel, the listeners that previously subscribed to that channel are notified of the message.
Usage:
- Android development
- Notification services

9. Model-View-Controller Pattern
This pattern, also known as the MVC pattern, divides an interactive application into three parts:
- Model - contains the core functionality and data
- View - displays information to the user (multiple views may be defined)
- Controller - handles user input
The purpose is to separate the program’s internal information from the information presented to the user, in a way the user can accept. This decouples the components and improves code reuse.
Usage:
- Internet application architectures using mainstream programming languages
- Web frameworks, for example Django and Rails

10. Blackboard Pattern
This pattern is useful for problems that have no deterministic solution. The blackboard pattern mainly consists of three parts:
- Blackboard - a structured global memory containing objects from the solution space
- Knowledge source - specialized modules with their own representation
- Control component - selects, configures, and executes the modules
All components can access the blackboard. Components can generate new data objects and add them to the blackboard. Components can view specific types of data on the blackboard, or use existing knowledge sources to find data through pattern matching.
Usage:
- Speech recognition
- Vehicle identification and tracking
- Protein structure identification
- Deciphering sonar signals

11. Interpreter Pattern
This pattern is used to design a component that interprets programs written in a dedicated language. It mainly specifies how to evaluate each line of a program, that is, the sentences or expressions written in a particular language. The basic idea is that every symbol of the language has a corresponding class.
Usage:
- Database query languages, for example SQL
- Languages that describe communication protocols

12. Comparison of Architecture Patterns
The table below gives the advantages and disadvantages of each architecture pattern:

