Software Architectural Patterns (Part 2)
Monolithic Architecture:
Represents a traditional and unified approach where all components of an application are tightly integrated into a single, cohesive unit.
Structure: All functionalities integrated into a single application. These components may include these features:
- Authorization: Manages user permissions and access to the application.
- Presentation: Handles HTTP requests and provides responses in HTML, XML, or JSON formats.
- Business Logic: Contains the core logic(business logic) that powers the application’s features and functionality.
- Database Layer: Consists of data access objects responsible for interacting with the application’s database.
- Application Integration: Controls and manages the integration with other services or external data sources.
Usage: Simpler applications, can become cumbersome as the app grows.
Frequently observed in ecommerce, as once the infrastructure is established (including the online store, order processing, payment processing, and customer service), the architecture requires minimal updates.
Microservice Architecture:
Decomposes a large application into smaller, independent services, each responsible for a specific business capability. These services communicate over a network using lightweight protocols (e.g., REST, gRPC).Microservices promote scalability, flexibility, and the ability to deploy and update services independently.
Components: API Gateway, Microservices (e.g., Catalog, Shopping Cart, Ordering).
Monolithic applications have a client-side UI, a database, and a server-side application, all built on a single code base. In contrast, distributed architecture uses microservices, each handling a specific feature or business logic, communicating via APIs instead of within a single code base.
Usage: Large, complex applications requiring high scalability and independent deployment.
Model-View-Controller Architecture (MVC):
Separates an application into three interconnected components: the model (data), the view (user interface), and the controller (logic). It promotes a clear separation of concerns and facilitates easier maintenance and testing.
Components: Model, View, Controller
- Model: This component represents the data and business logic of the application. It encapsulates the application’s data structure and the rules for manipulating that data.
- View: Responsible for managing the user interface and displaying information to the user. It receives input from users and sends commands to the controller.
- Controller: The controller handles user input, updates the model, and refreshes the view accordingly. It acts as an intermediary that processes user input and manages the flow of data between the model and the view.
Model-View-View-Model (MVVM):
Similar to MVC but specifically designed for user interfaces. It separates the UI into three components: the model (data), the view (UI), and the view model (mediator between the view and the model). MVVM is commonly used in frontend development, especially in frameworks like Angular and Knockout.js.
Usage: Web applications to separate concerns for easier management.
A basic CRUD (Create, Read, Update, Delete) application using MVC architecture includes developing a model to represent the data, a view for the user interface, and a controller to manage user input and data operations.
Popular MVC Frameworks : Ruby on Rails | Django | Laravel | Spring MVC
Master-Slave Architecture:
Distributed computing model where one central entity, the master node, controls and delegates tasks to subordinate entities known as slave nodes.
Components: Master Server (writes), Slave Servers (reads), Database.
- Master Node: The master node manages the overall state of the system and delegates specific tasks to slave nodes.
- Slave Node: Each slave node operates independently and reports back to the master node after completing its assigned tasks.
Usage: Load balancing and high availability, suitable for large-scale databases.
The client-server model is the most widely used architecture on the internet. Examples include sending emails via SMTP, IMAP, or POP; making HTTP requests to a web server; and transferring data to a server using FTP.
Conclusion:
These architectural patterns provide guidelines and best practices for designing software systems, but the choice of pattern depends on factors such as the requirements, scalability needs, and constraints of the project. Different pattern exists for different purpose, understanding their basic might save you from future conflicts.
Few other well know architecture patterns as follows: Hexagonal Architecture (Ports and Adapters), Server-less Architecture also known as Function-as-a-Service (FaaS), Component-Based Architecture
Reference: