Giter Site home page Giter Site logo

zejiran / transactions-email-processor Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 256 KB

📬 Process a file containing debit and credit transactions on an account and generate a summary email with relevant information

License: MIT License

Dockerfile 11.68% Go 88.32%
email file-processing golang transactions

transactions-email-processor's Introduction

Transactions Email Processor

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.

Prerequisites

  • Docker

How to Run

  1. Pull the Docker image from the GitHub Container Registry:
docker pull --platform linux/x86_64 ghcr.io/zejiran/transactions-email-processor:master
  1. Create a .env file in the same directory as the Dockerfile with the following environment variables:
[email protected]
PASSWORD=secret-password
[email protected]

Make sure to replace the email addresses with your own sender and recipient addresses.

  1. 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.

  1. Alternatively, you can specify environment variables as command arguments:
docker run --platform linux/x86_64 --env-file ./.env --env [email protected] -v /<absolute-host-path>/files:/files ghcr.io/zejiran/transactions-email-processor:master

File Format

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 (-).

Customization

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.

Configuration

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.

Repository Structure

  • 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.

Example Received Email

example

Notes

  • 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 in main.go.

Please feel free to reach out if you have any questions or need further assistance!

License

License

transactions-email-processor's People

Contributors

imgbotapp avatar zejiran avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.