Software Architecture

Ruǎnjiàn Jiàgòu 软件架构 (DISA, DABM)

Architectural Styles Overview

Architectural styles are reusable solution structures that address specific design challenges. They define high-level patterns for organizing software components and their relationships.

Component-Centric Styles

These styles focus on component organization and relationships.

Layered Architecture

Organizes components into horizontal layers where each layer only depends on the layer below it. Promotes separation of concerns and maintainability.

Layered Architecture: Presentation, Business Logic, Data Access

Clean Architecture

Organizes components in concentric circles with dependencies pointing inward toward the core domain. Business rules remain independent of external frameworks and databases. The major difference to the layered architecture is that the database sits "on top" (like the GUI), not "at the bottom".

Clean Architecture: Frameworks, Interface Adapters, Use Cases, Entities

Hexagonal Architecture

Isolates the application core from external concerns using ports (interfaces) and adapters (implementations). Enables easy testing and technology swapping.

Hexagonal Architecture: Primary Adapter, Port, Application Core, Port, Secondary Adapter

Onion Architecture

Places the domain model at the center with all dependencies pointing inward. Similar to Clean Architecture but emphasizes domain-driven design principles.

Onion Architecture: Infrastructure, Application Services, Domain Services, Domain Model

Domain-Driven Architecture

Structures the system around domain boundaries using Bounded Contexts. Each context encapsulates its own domain model, language, and rules. Communication between contexts happens through well-defined interfaces, keeping domain concepts consistent within each boundary.

Domain-Driven Architecture: Bounded Contexts for Orders, Inventory, Billing

Volatility-Based Architecture

Decomposes the system along axes of expected change. Each component encapsulates a specific type of volatility, so that when change occurs, its impact is contained to a single component rather than rippling across the system.

Volatility-Based Architecture: System Core with volatile components

Model-View-Controller (MVC)

Separates application logic into three interconnected components: Model (data), View (presentation), and Controller (user input handling).

MVC: User, View, Controller, Model

Actor Model

Organizes computation as independent actors that communicate exclusively through asynchronous message passing. Each actor processes messages sequentially, eliminating shared state and race conditions.

Actor Model: Actors communicating via messages

Vertical Slices Architecture

Also known as Feature Folder Architecture. Organizes code by feature or use case rather than by technical layer. Each slice contains everything needed for a specific feature, from request to response.

Vertical Slices: Feature A and Feature B with Handler, Model, Validation

Distribution-Oriented Styles

These styles focus on how components are distributed and communicate across networks.

Microservices Architecture

Structures applications as collections of loosely coupled, independently deployable services. Each service focuses on a specific business capability.

Microservices: API Gateway, services, databases

Event-Driven Architecture

Components communicate by producing and consuming events asynchronously. Promotes loose coupling and scalability through event-based communication.

Event-Driven: Producer, Event Bus, Consumer, Processor

Client-Server Architecture

Separates workloads between service providers (servers) and service requesters (clients). Forms the foundation for most networked applications.

Client-Server: Client, Server, Database

Service-Oriented Architecture (SOA)

Organizes applications as reusable services that communicate through well-defined interfaces. Emphasizes service reuse and enterprise-wide integration.

SOA: Consumer, Broker, Provider, Registry

Peer-to-Peer Architecture

Distributes tasks among equally privileged participants (peers) without central coordination. Each node acts as both client and server.

Peer-to-Peer: Four interconnected peers

Pipe and Filter Architecture

Breaks processing into sequential steps (filters) connected by communication channels (pipes). Each filter processes data independently and incrementally.

Pipe and Filter: Source, Filter 1, Filter 2, Filter 3, Sink

Choosing the Right Style

Select architectural styles based on your system's specific requirements: scalability needs, maintainability focus, flexibility requirements, resource constraints, and team organization. Real-world systems often combine multiple styles.