liveBook · Manning

Adapter

As explained in Microservices Patterns, Second Edition

A software component that connects application logic to an external interface or system by translating between their interfaces.

An adapter connects business logic to the outside world in a hexagonal architecture. Inbound adapters handle external requests and invoke business logic; outbound adapters let business logic access external systems. section 3.3.2

Adapters work through ports defined by the business logic:

  • An inbound adapter invokes an inbound port, such as a service interface, when handling a request. section 3.3.2
  • An outbound adapter implements an outbound port and makes requests to an external system, such as a database or remote service. section 3.3.2

FTGO application

FTGO uses REST API and web UI adapters to handle incoming requests. Outbound adapters connect business logic to MySQL and services such as Stripe and Twilio. section 2.1.1

Figure 3.16 An example of a hexagonal architecture, which consists of the business logic and one or more adapters that communicate with external systems. The business logic has one or more ports. Inbound adapters, which handles requests from external systems, invoke an inbound port. An outbound adapter implements an outbound port and invokes an external system.
Hexagonal architecture

Shows business logic at the center, with ports connecting it to inbound and outbound adapters. section 3.3.2

The business logic depends on ports, not on adapters; adapters depend on the business logic. This keeps external interfaces around the core rather than making the core depend on them. section 3.3.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines inbound and outbound adapters through ports, responsibilities, and examples such as controllers, DAOs, and service proxies.
Examples
Uses REST and web UI adapters, plus database and cloud-service adapters in the FTGO application.
What you can do after
Apply the pattern by routing incoming requests through inbound ports and implementing outbound ports for databases or external services.
How it connects
Connects ports, business logic, and hexagonal architecture, contrasting adapters with the presentation and persistence tiers of layered architecture.

Also explained in

Compare how 17 books explain adapter →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.