email_service

package module
v0.0.0-...-9e9902e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 1 Imported by: 0

README

Email Service

This code is implementation of Coding Challenge.

Package structure

Basically, the package structure follows the Standard Go Project Layout.

.
├── api                     # API Specification
├── cmd                     # Entrypoint of launching app
├── deploy                  # The code to create environment
├── internal                # Code for internal use
│   ├── app                 # Code for app specific
│   │   ├── container       # Create DI container
│   │   ├── http            # Code for API specific
│   │   │   ├── hander      # Request handler
│   │   │   ├── request     # Data object for reuqest
│   │   │   └── response    # Data object for response
│   │   └── service         # Business logic
│   └── pkg                 # Common codes
├── web                     # Frontend codes
├── .env.example
├── docker-compose.yaml
├── Dockerfile
├── LICENSE
└── README.md

How to run app

Common
Prepare mail services
for local
Prepare .env file

Copy .env.example to .env and edit it.

Should input these values

  • MAIL_FROM_ADDRESS
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_KEY
  • AWS_SES_ENDPOINT
  • AWS_REGION
  • SENDGRID_API_KEY
Execute

Execute the below command.

COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILCDKIT=1 docker-compose up --build

And then, you aceess to localhost:8080

for AWS
Create environment

See deploy

How to execute test

Execute all tests.

go test ./...

Points of design

Ease to test

Ensure to write the test code easily, it uses DI to set an instance to others.

Ease to set configuration

This service allows users to get configuration variables from .env file and environmental variables of OS.

Ease to run app

On local pc, it uses Docker Compose to run app.

Aside from that, it provides the CDK code to create an environment on AWS.

Points of improvement

Select email vendor

Currently, this service sends email using AWS SES and SendGrid.

First, it sends email using AWS SES. If an error occurs at that time, send it using SendGrid.

So, it always uses SES unless the error occurs on SES.

It is better to be able to select email vendor when user send an email.

Support HTML mail

Currently, it supports text email only.

However, most of emails are HTML email.

It is better to support HTML email.

Send email to multiple email address

Now, this service sneds an email only one address.

But, there is possible that user want to send an email to multiple addresses.

It is better to send an email to multiple addresses.

Send email as CC or BCC

This service allows users to send an email as a To address only.

It is better to change it can send an email as a CC or BCC.

Handle error properly

The API returns error as Internal Server Error when error occurs by sending email.

However, it is better to return the error by error details.

References

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL