The Wayback Machine - https://web.archive.org/web/20240609200050/https://www.geeksforgeeks.org/design-patterns-architecture/
Open In App

Design Patterns Architecture

Last Updated : 31 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Design patterns and architectural styles play a crucial role in shaping the structure and behavior of software systems. Let’s explore several architectural patterns and styles, each with its own characteristics, using examples and suitable diagrams.

Layered Architecture (N-Tier Architecture)

Layered architecture divides an application into distinct layers, with each layer responsible for a specific set of functionality. This promotes the separation of concerns and modularity.

p1

  • Presentation Layer (UI) : This is where the user interacts with the application. It handles user input and displays information.
  • Application Layer (Business Logic) : This layer contains the core logic of the application, such as processing user requests and managing business rules.
  • Data Access Layer (Database) 😀ata is retrieved and stored. It interacts with the database, ensuring separation of data concerns.

This separation of concerns makes the system modular and easier to maintain.

Microservices Architecture

Microservices architecture decomposes an application into small, independently deployable services that communicate via APIs. This promotes scalability and flexibility.

Example:

In an e-commerce platform, you might have microservices for user management, product catalog, order processing, and payment processing.

p2

  • User Management Microservice handles user authentication and profiles.
  • Product Catalog Microservice manages product information.
  • Order Processing Microservice deals with order creation and tracking.
  • Payment Processing Microservice handles payments.

This architecture promotes scalability and flexibility by allowing services to evolve independently.

Service-Oriented Architecture (SOA)

SOA is an architectural style that structures an application as a collection of loosely coupled services, often with standardized communication protocols.

Example:

In an enterprise system, you might have services for customer management, inventory control, and order processing.

p3

  • Customer Management Service manages customer data.
  • Inventory Control Service tracks product availability.
  • Order Processing Service handles order creation and fulfillment.

SOA promotes reusability and interoperability by separating functionality into distinct services.

Event-Driven Architecture (EDA)

EDA involves components that communicate through events. Events trigger actions in response, making systems highly decoupled and responsive to changes.

Example:

A stock trading system where price updates trigger buy/sell orders.

p4

  • Price Update Events trigger buy/sell orders.
  • Order Execution Events update order status.

EDA makes systems highly responsive and decoupled, allowing for real-time reactions to changes.

Hexagonal Architecture (Ports and Adapters)

Hexagonal architecture emphasizes the separation of the core business logic from external dependencies, making it easy to test and adapt.

Example:

A banking application where the core business logic is isolated from database and user interface.

TerraBrasilis-Hexagonal-Architecture-Ports-and-Adapters-Design-Pattern

  • Core Business Logic is at the center.
  • Adapters connect to external resources like databases and UI.

This separation simplifies testing and makes the application adaptable to changes.

Component-Based Architecture

Component-based architecture involves building software from reusable, self-contained components.

Example:

A content management system (CMS) where components handle rendering, authentication, and content storage.

principles_of_component_based_design

  • Rendering Component handles page rendering.
  • Authentication Component manages user access.
  • Content Storage Component stores and retrieves content.

Components can be reused across different parts of the application.

Blackboard Architecture

In this architecture, different specialized modules work together on a common data structure (the blackboard) to solve complex problems.

Example:

An AI system for image recognition where modules collaborate to identify objects.

Blackboad_pattern_system_structure

  • Image Recognition Module processes images.
  • Object Identification Module identifies objects.
  • Decision Module makes decisions based on recognized objects.

Modules share information on the blackboard, enabling problem-solving through collaboration.

Space-Based Architecture

Space-based architecture uses distributed data spaces to share information among components, promoting scalability and fault tolerance.

Example:

A real-time recommendation engine where user interactions are stored in a distributed space for processing.

1_c6wglR6ZNiPHLX7sSiDYvQ

  • User Interactions are stored in a distributed space.
  • Processing Components analyze the data to make recommendations.

This architecture promotes scalability and fault tolerance by distributing data and processing.

CQRS (Command Query Responsibility Segregation)

CQRS separates the read (query) and write (command) sides of an application, allowing for optimization and scalability of each side.

Example:

A banking application where the command side handles transactions, while the query side serves account balances.

1_9PIFrsO4_ZGes2uTXCVTgQ

  • Command Side handles transactions.
  • Query Side serves account balances.

This segregation allows optimizing and scaling each side independently.

Clean Architecture

Clean architecture focuses on organizing code in concentric circles or layers, with the innermost circle containing the core business logic and outer circles representing frameworks and interfaces.

Example:

A mobile app with core business logic, user interface, and database access layers.

blog-consulting18b

  • Core Business Logic at the center.
  • User Interface and Database Access layers surround it.

This structure enforces separation of concerns and facilitates maintainability.

Serverless architecture

Serverless architecture involves deploying code as individual functions that are executed in response to events, without managing server infrastructure.

Example:

An image processing service that scales automatically in response to incoming image uploads.

How-does-serverless-work

  • Image Upload Events trigger processing functions.
  • Scalability is automatic, as the cloud provider manages server infrastructure.

Serverless is highly scalable and cost-effective, as you only pay for actual execution time.

Conclusion

These architectural patterns and styles provide a framework for designing and building robust, scalable, and maintainable software systems. The choice of architecture depends on the specific requirements and constraints of your project. Each of these patterns comes with its own advantages and trade-offs, so it’s important to select the one that best fits your needs.



Similar Reads

Difference Between Architectural Style, Architectural Patterns and Design Patterns
Many software professionals think that architectural styles and patterns are the same. Sadly, some of the software developers don’t understand the difference between architectural patterns and design patterns. In this article, we're going to summarize the differences between them. According to MSDN, architectural styles and patterns are the same th
7 min read
Connectivity and Composition Patterns | Design Patterns for Cloud Native Applications
In cloud-native applications, the architectural design becomes a critical aspect, defining the success of the entire solution. Connectivity and composition patterns are fundamental design principles that dictate how different components within a cloud-native application communicate and collaborate. Let's delve deeper into the significance of these
9 min read
Architecture for Mobile Development | Design Patterns
Hey there, tech enthusiasts! Ever wonder what makes your favorite mobile apps so smooth and user-friendly? Well, the secret lies in their architecture – the behind-the-scenes structure that turns code into the awesome apps we can't live without. Important Topics for Mobile Development Architecture Classic MVC or MVC (Model-View-Controller) Architec
9 min read
Event-Driven Architecture Patterns in Cloud Native Applications
Cloud Native Applications are a new way of building software that takes advantage of the cloud and uses smaller, more focused pieces called microservices. Design patterns are important for building these applications because they provide guidelines and examples on how to solve common problems. In this article, we will focus on Event-Driven Architec
7 min read
Architecture Patterns for Resilient Systems
Resilient architecture patterns help our systems stay strong even when facing challenges. In this article, we will see some resilience architecture patterns. We'll explore how these patterns work by looking at real-life examples. By the end of this article, you'll have a clear picture of how these patterns work and how to use them to make your syst
6 min read
Composite Design Pattern | JavaScript Design Patterns
The Composite Design pattern is a way of organizing objects. It helps us handle different objects in a similar way when they are put together to create a structure with parts and wholes. These parts and wholes are like building blocks that can be split into smaller pieces and then put together to make a tree-like structure. The composite design pat
6 min read
Template Method Design Pattern | C++ Design Patterns
Template Method Pattern introduces a template in a superclass that defines the steps of an algorithm. These steps may include both common tasks shared among subclasses and specific tasks that need customization. Subclasses then implement or override these steps to modify the algorithm according to their specific needs. Important Topics for Template
7 min read
Boosting Web Design with Accessible Design Patterns and Testing Methods
One of the most important design principles that may help you boost your next web design is having Accessible Design Patterns and Testing Methods. Accessible design patterns simply refer to Design patterns that can be easily recognized and used by a wide range of users, from casual visitors to professionals. When we talk about testing in web design
5 min read
State Method Design Pattern | C++ Design Patterns
In software design, managing the behavior of an object according to its internal state is a common issue. The state pattern addresses this issue by allowing an object to alter its behavior every time its internal state changes. This pattern encapsulates each state in a separate class, which makes it easier to add new states and modify existing stat
7 min read
Strategy Method Design Pattern | C++ Design Patterns
Strategy Pattern is a behavioral design pattern that defines a family of interchangeable algorithms and allows them to be used interchangeably within a context. This pattern enables the algorithm to be selected at runtime, providing flexibility and promoting code reusability. Important Topics for the Strategy Method in C++ Design Patterns Example o
4 min read