This project is an API built using Java, Java Spring, AWS Simple Email Service (SeS) and Clean Architecture principles. The API allows you to send e-mails using AWS SeS.
- Clone the repository:
git clone https://github.com/alonsofritz/simplified-authenticator-spring.git
-
Install dependencies with Maven
-
Update
application.properties
putting your AWS Credentials
aws.access.key=your-access-key
aws.secret.key=your-secret-key
aws.region=us-east-1
email.sender=your-email
Obs: The sender email must be verified in AWS SeS.
- Start the application with Maven
- The API will be accessible at http://localhost:8080
Obs: You can change the port in application.properties
file, changing the server.port
property.
The API provides the following endpoints:
GET EMAIL
POST /api/email/send - Send a e-mail from your sender to the destination
BODY
{
"to": "johndoe@email.com",
"subject": "test",
"body": "test"
}
RESPONSE
{
"message": "E-mail sent successfully"
}
The application follows a structure that resembles Clean Architecture, with some adaptations:
- Application Layer:
- Responsibility: Starts the application and manages the controllers.
- Example:
EmailServiceApplication
,EmailSenderController
.
- Domain Layer:
- Responsibility: Contains business rules and entities.
- Example:
EmailSenderUseCase
,EmailServiceException
.
- Infrastructure Layer:
- Responsibility: Manages communication with external services and configurations.
- Example:
SesEmailSender
,SesConfig
.
- Adapters Layer:
- Responsibility: Defines contracts and interfaces for communication between layers.
- Example:
EmailSenderGateway
.
- EmailServiceApplication
- Description: Main class that starts the Spring Boot application.
- SesEmailSender
- Description: Implements the
EmailSenderGateway
interface to send emails using Amazon SES. - Attributes:
- emailSender:
String
(configured via@Value
fromapplication.properties
) - amazonSimpleEmailService:
AmazonSimpleEmailService
(injected via@Autowired
)
- emailSender:
- Methods:
sendEmail(String to, String subject, String body)
: Sends an email using Amazon SES.
- Description: Implements the
- SesConfig
- Description: Configures the
AmazonSimpleEmailService
client to be used in the application. - Methods:
amazonSimpleEmailService()
: Creates and configures a bean of typeAmazonSimpleEmailService
.
- Description: Configures the
- EmailSenderGateway
- Description: Interface that defines the contract for sending emails.
- Methods:
sendEmail(String to, String subject, String body)
: Abstract method for sending email.
- EmailServiceException
- Description: Custom exception for errors in the email service.
RELATIONSHIPS
EmailServiceApplication
has no direct dependencies on other classes.SesEmailSender
implements theEmailSenderGateway
interface.SesEmailSender
usesAmazonSimpleEmailService
configured by theSesConfig
class.SesEmailSender
throwsEmailServiceException
in case of email sending failure.