The use case defines an
EmailSender port, and an infrastructure SendGridEmailSender implements itThe use case should define an EmailSender port, and an infrastructure SendGridEmailSender should implement it. The port belongs to the inner layer, and the inner layer's needs decide its shape. The adapter in the outer layer depends on the port. So all dependencies point inward, which is the dependency rule.
Why the other options are wrong:
• "The infrastructure layer defines EmailSender": the use case still imports from an outer layer, so the dependency points outward.
• "The use case imports the SendGrid SDK directly": the inner layer now depends on a specific technology.
• "The controller sends the email after the use case returns": this moves a business step into the delivery layer.