Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 04 - Architecture - Coggle Diagram
Chapter 04 - Architecture
Definitions
Architecture style describes how to implement a specific architecture (e.g DSL, event-driven)
Architecture pattern explains how to address a specific concern within an architecture but is broader than a design pattern. (e.g DDD, MVC)
Layer pattern
Based on blue book
As the system involves and the need to add new features. Hexagonal architecture came to rescue.
A layer can only
be coupled
by itself or below
layers
Strict Layers Architecture
is one that allows coupling only to the layer directly below.
A Relaxed Layers Architecture
allows any higher-level layer to couple to any layer below it.
Lower layers may actually
loosely couple to higher layers
, but this is only by means of a mechanism such as Observer or Mediator
Layers
Application Services reside in the
Application Layer
and it is this layer the direct clients of the domain model, though themselves possessing no business logic.
Domain Layer
is the one where all the business logic must reside.
Infrastructure layer
are all the technical components and frameworks that provide low-level services for the application, for instance, databases, messagings etc.
The
User Interface
is to contain only code that addresses user view and request concerns. It should not have business logic
how to solve the problem of
dependencies of the layers
below depend on the
implementations of the
upper layers?
DIP
dependence inversion principal
High-level modules should not depend on low-level modules. Both should depend on abstractions.
The essence of this definition is communicating that a
component that provides low-level services
(Infrastructure, for this discussion) should
depend on interfaces defined by high-level components
(for this discussion, User Interface, Application, and Domain)
Ports and Adapters (Hexagonal)
Hexagonal promotes a different way of looking at the areas of a system. There are two primary areas, the outside and the inside. The outside enables disparate clients to submit input and also provides mechanisms to retrieve persisted data, store the application’s output (for example, a database), or send it elsewhere along its way (for example, messaging).
Ports
: It is like a gateway and it should be responsible for the input or output of data from and to the application. Ports are simple interfaces that represents what some infrastructure needs to do.
Example of to the application: HTTP request, gRPC
Example of from the application: messaging, databases, external libraries
source:
https://www.thinktocode.com/2018/07/19/ports-and-adapters-architecture/
Adapters
is responsible for the complete action and talks with the infrastructure.
Service Oriented Architecture (SOA)
The idea is not create a definition about SOA, but to show how DDD fits in the SOA Manifest - Disclaimer
SOA Manifesto give option to see a service as SOAP or a RESTFul resource.
Solution space using soa is expected to see many BCs and each one with a different architecture.
When using DDD our goal is to create a Bounded Context with a complete, linguistically well-defined domain model. We don’t want architecture to influence the size of the domain model.
We want to avoid a very granular BC or a BC composed by a N number of services.
a single business service does not equate to defining a single Subdomain (2) or Bounded Context. No doubt as we perform both problem space and solution space assessments, we will find that a business service comprises a number of each.
REST
Fulfills the promise of loose coupling
In general, it’s very easy to add new resources and links to them in existing resource representations
The design of HTTP and the maturity of the tooling with support for features such as URI rewriting and caching
CQRS (command-query responsibility segregation)
Definitions
Query method: retrieve data and it cannot change the objects states
An architectural pattern that can be use just in part or in the whole application. This pattern segregate the responsibilities between reading and writing data given to the application more scalability and avoid database lock.
Command method: changes the status of a object, but it does not return anything.
Processor could be a instance of a command/query
Image
Major areas CQRS
Client and Query Processor
The client (at the far left in the diagram) may be a Web browser or a custom desktop user interface
This processor just know how to run simples queries. The idea here is to get the content from a specific query model and show it to the client
Query Model
Big denormalized data model
Can use views as a well to assemble data from different tables
It is not meant to deliver domain behavior, only data for display (and possibly reporting).
Views is a nice example on how to gathering these datas
Client Drives Command Processing
Client send the command name and its parameters through the app as the means of executing behavior on aggregation.
Command Processors
It is the one responsible for process the command
It has multiples styles. These styles are categorized, dedicated, messaging
Command Model (or Write Model) Executes Behavior
as a command method is executed it publish an event. This event is the linchpin for updating the query model.
Event Subscriber Updates the Query Model
A special subscriber registers to receive all Domain Events published by the command model. The subscriber uses each Domain Event to update the query model to reflect the most recent changes to the command model.
Event-Driven Architecture (EDA)
Pipes and Filters
A Filter in an EDA may be used to perform some processing while leaving the message data intact.