transaction-history-backend

command module
v0.0.0-...-9859e96 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 9 Imported by: 0

README

Transactions History Backend

Endpoints available

  • GET /users: Returns all the users whit their names and total balance
  • GET /transactions/user/{id}: Returns the transactions of the user with the given id
  • GET /summary/user/{id}: Returns the summary of all transactions of the user with the given id including the transactions per month
  • GET /summary/email/{id}/to/{email}: Sends the summary of all transactions of the user with the given id to the given email

Description

This is a project to show the transactions history of a user. It is a simple project that uses the following technologies:

  • Go 1.19
  • Gin Gonic
  • Gorilla Mux
  • Gomail
  • Docker
  • Docker Compose
  • AWS S3
  • AWS Lambda
  • AWS Simple Email Service

Architecture

The project uses a simple architecture with the following layers:

  • Controller: This layer is in charge of receiving the requests and sending the responses. It is the entry point of the application.
  • Service/Handlers: This layer is in charge of the business logic. It is the core of the application.
  • Repository: This layer is in charge of the database operations. It is the data access layer of the application (in this case is a CSV file hosted in a AWS S3 Bucket).

How to run in local environment

  1. Clone the repository transaction-history-backend
  2. Inside transaction-history-backend/deployments/local-docker folder, add a .env file with the following content:
AWS_LAMBDA_RUNTIME_API=
AWS_ACCESSKEYID=
AWS_SECRETACCESSKEY=
AWS_DEFAULTREGION=
AWS_BUCKET=
EMAIL_SMTP_HOST=
EMAIL_SMTP_PORT=
EMAIL_SMTP_SECURE=
EMAIL_SMTP_USERNAME=
EMAIL_SMTP_PASSWORD=
EMAIL_IAM_USERNAME=
  1. Once .env is completed, run the following command in the same folder as before in order to to start the server:
docker-compose up -d --build
  • Container name es transactions-history-backend and exposes the following ports:
    • 0.0.0.0:3003->3030/tcp
  1. The server will be running in your host on port 3003. You can test it with the following command:
curl http://localhost:3003/users
  1. To stop the server, run the following command:
docker stop transactions-history-backend
  1. To remove the container, run the following command:
docker rm transactions-history-backend

How to deploy in production environment

  1. Follow previous steps to clone the repository and build the docker image
  2. Make some changes
  3. Push the changes to the repository at develop branch
  4. Create a pull request to master branch
  • The pull request action trigger a Github Action that runs the tests, build and deploy the application into a $LATEST version of the lambda function, this is done using the .github/workflows/go-latest.yml file
  1. Once the pull request is approved, the changes will be deployed automatically to production environment at New Version (current v3) of the lambda function using the .github/workflows/go-stable.yml file

How to run tests

  1. Follow previous steps to clone the repository and build the docker image
  2. Run the following command in the same folder as before in order to to start the server:
docker exec -it transactions-history-backend go test ./...

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
aws

Jump to

Keyboard shortcuts

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