This Banking API is designed with hexagonal architecture to ensure scalability and maintainability. Built in Golang and powered by Gorilla Mux for routing, this API provides banking functionalities like account management and transactions.
Before running the API, ensure the following are installed on your system:
- Go - for application development.
- MySQL - database for storing banking data.
- Docker & Docker Compose (optional, for containerized database setup).
To run the application, define the following environment variables. Default values are specified inside start.sh
:
SERVER_ADDRESS
: IP address where the server will run.SERVER_PORT
: Port for the server.DB_USER
: Username for the database.DB_PASSWD
: Password for the database.DB_ADDR
: IP address of the database server.DB_PORT
: Port of the database server.DB_NAME
: Name of the database to connect to.
-
Clone the repository
git clone https://github.com/yourusername/banking-api.git cd banking-api
-
Run the Application Use the
start.sh
script to download dependencies and run the application:./start.sh
Note:
start.sh
sets up default environment variables. Modify these as needed.
You have two options for setting up your MySQL database:
-
Using Docker Compose
Adocker-compose.yml
file is available inresources/docker
. This file includes an initialization script to create tables and insert default data.To start the Docker container, navigate to the
resources/docker
directory and run:docker-compose up
-
Manual Setup Using SQL Script
Alternatively, you can manually set up the database usingresources/database.sql
. Run this script in your MySQL instance to create tables and insert default data.
To generate mocks for testing, run:
./generate-mocks.sh
To run unit tests and ensure everything is working as expected, use:
./run-tests.sh