https://github.com/zejiran/transactions-email-processor
📬 Process a file containing debit and credit transactions on an account and generate a summary email with relevant information
https://github.com/zejiran/transactions-email-processor
email file-processing golang transactions
Last synced: about 1 year ago
JSON representation
📬 Process a file containing debit and credit transactions on an account and generate a summary email with relevant information
- Host: GitHub
- URL: https://github.com/zejiran/transactions-email-processor
- Owner: zejiran
- License: mit
- Created: 2023-05-18T17:46:04.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-23T09:18:36.000Z (about 3 years ago)
- Last Synced: 2024-06-21T15:47:49.841Z (almost 2 years ago)
- Topics: email, file-processing, golang, transactions
- Language: Go
- Homepage:
- Size: 250 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```shell
docker pull --platform linux/x86_64 ghcr.io/zejiran/transactions-email-processor:master
```
2. 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.
3. Run the Docker container with the -v flag to mount a directory for input files:
```shell
docker run --platform linux/x86_64 --env-file ./.env -v //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.
4. Alternatively, you can specify environment variables as command arguments:
```shell
docker run --platform linux/x86_64 --env-file ./.env --env RECIPIENT_MAIL=new.recipient@example.com -v //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

### 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
[](http://badges.mit-license.org)
- **[MIT license](LICENSE)**
- Copyright 2023 © Juan AlegrÃa.