Skip to content

Software Architecture Patterns

Artem edited this page Aug 19, 2023 · 13 revisions

Layered/N-tier architecture style

Layers are a way to separate responsibilities and manage dependencies. Each layer has a specific responsibility. A higher layer can use services in a lower layer, but not the other way around.

Layered

A Layered architecture divides an application into logical layers

  • In a closed layer architecture, a layer can only call the next layer immediately down.
  • In an open layer architecture, a layer can call any of the layers below it.
flowchart TB
direction TB
    subgraph l1 [ ]
        direction LR
        p00["Presentation"]~~~r1[ ]~~~p01[Component]~~~p02[Component]~~~p03[Component]~~~p04{{Closed}}
    end
    subgraph l2 [ ]
        direction LR
        b0["Business"]~~~o0[ ]~~~r2[ ]~~~b1[Component]~~~b2[Component]~~~b3[Component]~~~b4{{Closed}}
    end
    subgraph l3 [ ]
        direction LR
        p10["Services"]~~~r3[ ]~~~s1[Component]~~~s2[Component]~~~s3[Component]~~~s4{{Open}}
    end
    subgraph l4 [ ]
        direction LR
        s0["Persistence"]~~~o1[ ]~~~r4[ ]~~~p11[Component]~~~p12[Component]~~~p13[Component]~~~p14{{Closed}}
    end
    subgraph l5 [ ]
        direction LR
        d0["Database #nbsp; #nbsp; #nbsp;"]~~~r5[ ]~~~d1[("#nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp;")]~~~d2[("#nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp;")]~~~d3[("#nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp; #nbsp;")]~~~d4{{Closed}}
    end

r0[Request] --> l1 --> l2 --> l3 --> l4 --> l5
l2 --> l4
style r0 fill:#FFFFFF00, stroke:#FFFFFF00;
style r1 fill:#FFFFFF00, stroke:#FFFFFF00;
style r2 fill:#FFFFFF00, stroke:#FFFFFF00;
style r3 fill:#FFFFFF00, stroke:#FFFFFF00;
style r4 fill:#FFFFFF00, stroke:#FFFFFF00;
style r5 fill:#FFFFFF00, stroke:#FFFFFF00;
style o0 fill:#FFFFFF00, stroke:#FFFFFF00;
style o1 fill:#FFFFFF00, stroke:#FFFFFF00;
style p00 fill:#FFFFFF00, stroke:#FFFFFF00;
style b0 fill:#FFFFFF00, stroke:#FFFFFF00;
style p10 fill:#FFFFFF00, stroke:#FFFFFF00;
style d0 fill:#FFFFFF00, stroke:#FFFFFF00;
style s0 fill:#FFFFFF00, stroke:#FFFFFF00;
Loading
PROS CONS
High abstraction Deep call chains
High isolation Can hide complexity
Structured communication May harm performance
Easy to scale out Lowest layers must cover all use cases

N-Tier

An N-Tier architecture divides an application into physical layers (different physical servers)

flowchart LR
   ib[Internet] --> lb[Load Balancer] --> api[Application] --> eb[Event Bus] --> cr[Crawler] --> db[Database]
Loading
PROS CONS
High abstraction Network is a point of failure
High isolation Network may be slow
Structured communication Coarse interfaces
Easy to scale out Hard to debug
Price

Monolitic

Service-Oriented Architecture

PROS CONS

Microsevices

Client-Server

The client–server model is a distributed system that partitions tasks between clients requests and server.

flowchart LR
   a[Mobile] & b[PC] & c[Cloud] --> i((Transport)) --> s{{Server}}
Loading
PROS CONS
Secured Requires Network
Simple Communication Difficult to scale out
Centralized Control Single Point of failure
Easy to manage Hard to debug

Broker

Master-slave

MVC

MVVM

PROS CONS

Clone this wiki locally