This project is a simple bank API built using Go, Echo framework, and PostgreSQL. The API supports user authentication, account management, and transaction operations, including deposits, withdrawals, transfers, and fetching account history with pagination.
Clone the repository:
git clone https://github.com/yourusername/bank-api.git
cd bank-api
Create a .env
file with the following environment variables:
DB_HOST=db
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=bank
JWT_SECRET=your_jwt_secret
Run Docker Compose to start PostgreSQL:
docker-compose up -d
Run the application:
go run main.go
Signup:
/signup
POST
{
"username": "testuser",
"password": "testpassword"
}
Login:
/login
POST
{
"username": "testuser",
"password": "testpassword"
}
Deposit:
/deposit
POST
Authorization: Bearer <jwt_token>
{
"account_id": 1,
"amount": 100.0
}
Withdraw:
/withdraw
POST
Authorization: Bearer <jwt_token>
{
"account_id": 1,
"amount": 50.0
}
Transfer:
/transfer
POST
Authorization: Bearer <jwt_token>
{
"from_account_id": 1,
"to_account_id": 2,
"amount": 25.0
}
Get Account History:
/account/:account_id/history
GET
Authorization: Bearer <jwt_token>
page
: Page number (default: 1)limit
: Number of transactions per page (default: 10)Get Transfer History:
/account/:account_id/transfer-history
GET
Authorization: Bearer <jwt_token>
page
: Page number (default: 1)limit
: Number of transactions per page (default: 10)You can import the Postman collection provided in the postman_collection.json
file to test the API endpoints.
This project is licensed under the MIT License. See the LICENSE file for details..