Skip to content

david-slatinek/cr24-account-service

Repository files navigation

Description

Go Docker Shell Script AWS Amazon EC2 RabbitMQ Amazon DynamoDB Swagger k6

API for managing bank accounts. The API allows you to create, read, update and delete bank accounts.

The API was made with Go and was hosted on AWS EC2 as a container with Docker. For the database, we chose DynamoDB, which was hosted on AWS DynamoDB.

We used RabbitMQ for log management and Swagger for documentation.

Table of Contents

Prerequisites

Go to the db/ directory and create a .env file. Add the following environment variables:

AWS_ACCESS_KEY_ID = <your_aws_access_key_id>
AWS_SECRET_ACCESS_KEY = <your_aws_secret_access_key>
REGION = <your_aws_region>

All these variables can be set to any value. They are only used to create the database locally.

Create a .env file in the env/ directory and add the following environment variables:

AWS_ACCESS_KEY_ID = <your_aws_access_key_id>
AWS_SECRET_ACCESS_KEY = <your_aws_secret_access_key>
AWS_REGION = <your_aws_region>
GIN_MODE = release
JWT_SECRET = <your_jwt_secret>
AMQP_URL = <your_amqp_url>
EXCHANGE_QUEUE_NAME = <your_exchange_queue_name>

AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION must the same as in the db/.env file. AMQP_URL and EXCHANGE_QUEUE_NAME are optional. If you do not specify them, the logs will not be sent to the queue.

How to run

Firstly, you need to install Docker and Docker Compose.

Then run:

git clone

or download the repository.

Then run

cd db
docker-compose up

to start the database.

Then open another terminal and run

docker-compose up

in the root directory of the repository to start the API.

Usage

The API is documented with Swagger. You can access the documentation at http://localhost:8080/docs/index.html.

The API is protected with JWT. To get the token, you need to generate it. You can do this online at jwt.io.

The token must contain the following payload:

{
  "sub": "<your_id>",
  "iat": "<current_timestamp>",
  "exp": "<current_timestamp + desired_expiration_time>"
}

The JWT token must be sent in the Authorization header in the following format:

Authorization <your_jwt_token>

Testing documentation

For testing documentation, see https://github.com/david-slatinek/cr24-account-service/wiki.

Contributor

David Slatinek Github avatar
David Slatinek