This project is a simple application that processes a file containing debit and credit transactions on an account and generates a summary email with relevant information. The application is built using Go and packaged into a Docker container for easy deployment.
- Docker
- Pull the Docker image from the GitHub Container Registry:
docker pull --platform linux/x86_64 ghcr.io/zejiran/transactions-email-processor:master
- Create a
.env
file in the same directory as the Dockerfile with the following environment variables:
SENDER_MAIL=sender@gmail.com
PASSWORD=secret-password
RECIPIENT_MAIL=recipient@example.com
Make sure to replace the email addresses with your own sender and recipient addresses.
- Run the Docker container with the -v flag to mount a directory for input files:
docker run --platform linux/x86_64 --env-file ./.env -v /<absolute-host-path>/files:/files ghcr.io/zejiran/transactions-email-processor:master
The -v
flag maps the files
directory on the host machine to the /files
directory in the container. This allows you to provide input files from the host machine to the container.
- Alternatively, you can specify environment variables as command arguments:
docker run --platform linux/x86_64 --env-file ./.env --env RECIPIENT_MAIL=new.recipient@example.com -v /<absolute-host-path>/files:/files ghcr.io/zejiran/transactions-email-processor:master
The input file should be in CSV format with the following columns:
Id,Date,Transaction
Each row represents a transaction, where the Id
is a unique identifier, Date
is the date of the transaction in the format MM/DD
, and Transaction
is the transaction amount. Credit transactions are indicated with a plus sign (+) and debit transactions with a minus sign (-).
The email template used for generating the email body is located in the email/dist/email_template.html
file. You can modify the template HTML to customize the email content, styling, and layout. Make sure to keep the placeholders for the dynamic data intact.
The application requires the following environment variables to be set:
SENDER_MAIL
: The email address of the sender.PASSWORD
: The password or app-specific password for the sender's email account.RECIPIENT_MAIL
: The email address of the recipient.
Make sure to set these environment variables in the .env
file before running the Docker container.
main.go
: The main Go application code that reads the input file, processes the transactions, generates the email body, and sends the email.Dockerfile
: The Dockerfile for building the Docker image of the application.email/src/email_template.heml
: The source HEML code used for creating the HTML template.email/dist/email_template.html
: The HTML template used for generating the email body.files/example_transactions.csv
: An example input file with debit and credit transactions.
- The email sending functionality is currently configured for Gmail. If you are using a different email provider, you may need to update the SMTP server details in the
sendEmail
function inmain.go
.
Please feel free to reach out if you have any questions or need further assistance!
- MIT license
- Copyright 2023 © Juan AlegrÃa.