A secondary port is a contract the application core defines for something it needs from outside. The core calls the port; an external adapter implements it. That keeps the core from depending directly on a database, email service, or other infrastructure. section 5.4.1 section 5.3.2
Think of the port as a socket and the adapter as a plug:
- The port describes what the core needs in its own terms, without naming a specific external service. section 5.5.2
- An adapter implements that contract and translates the request into infrastructure-specific work. section 5.5.2
- Inject the adapter into the core rather than having the core create it; wire them together at the application entry point. section 5.5.2
One alert, different plugs
A server monitor can depend on an IAlertPort with a SendAlert method. A Twilio adapter can send an SMS, while a console adapter can print an alert. The monitor calls the same port either way, so changing the alert mechanism need not change its business logic. section 5.5.2
Figure 5.11 On the Driven Side, the Domain Logic never talks to the database directly; it simply calls a Secondary Port (Interface). The actual database or email server is hidden inside a Secondary Adapter that implements the interface, allowing you to swap out your infrastructure without changing a single line of business logic.

The diagram shows the key boundary: domain logic calls a secondary port, while infrastructure stays behind an adapter. section 5.4.1
