Discover Packages
github.com/barisaskaleli/lightweight-bank
module
Version:
v0.0.0-...-b1d2da9
Opens a new window with list of versions in this module.
Published: Aug 16, 2024
License: MIT
Opens a new window with license information.
README
README
¶
Lightweight Bank API
Lightweight Bank API is a simple banking application built with Go. It provides basic functionalities such as user registration, login, and money transfer between accounts.
Table of Contents
Installation
Clone the repository:
git clone https://github.com/barisaskaleli/lightweight-bank.git
cd lightweight-bank
Install dependencies:
go mod tidy
Set up the environment variables:
Copy the .env.example
file to .env
and adjust the values as needed.
cp .env.example .env
Configuration
The application uses environment variables for configuration. Below is a list of the variables you need to set in the .env
file:
SERVER_PORT
: The port on which the server will run.
JWT_SECRET
: Secret key for JWT token generation.
DB_HOST
: Database host.
DB_PORT
: Database port.
DB_USER
: Database user.
DB_PASSWORD
: Database password.
DB_DATABASE
: Database name.
TRANSFER_FEE
: Fee for money transfers.
TRANSFER_FEE_ENABLED
: Enable or disable transfer fee.
SMS_INFO_ENABLED
: Enable or disable SMS notifications.
Usage
Run the application via docker:
docker compose up -d --build
Or run by the golang:
go run cmd/server.go
The server will start on the port specified in the .env
file.
API Endpoints
Swagger documentation is available at
http://localhost:3000/swagger/index.html
User Registration
URL : /register
Method : POST
Request Body :
{
"name": "John",
"surname": "Doe",
"email": "john.doe@example.com",
"password": "password123"
}
Response :
{
"id": 1,
"account_number": "1234567890",
"name": "John",
"surname": "Doe",
"email": "john.doe@example.com",
"balance": 0.0
}
User Login
Money Transfer
URL : /transfer
Method : POST
Request Body :
{
"sender_account_number": "1234567890",
"receiver_account_number": "0987654321",
"amount": 100.0
}
Response :
{
"status": true,
"message": "Transfer successful",
"sender_balance": 900.0,
"receiver_balance": 1100.0,
"fee": 10.0
}
License
This project is licensed under the MIT License.
Expand ▾
Collapse ▴
Directories
¶
mocks
Package mock_config is a generated GoMock package.
Package mock_config is a generated GoMock package.
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
Package mock_repository is a generated GoMock package.
util/mocks
Package mock_util is a generated GoMock package.
Package mock_util is a generated GoMock package.
Click to show internal directories.
Click to hide internal directories.