https://github.com/charlybutar21/wallet
This is a simple REST API application using Spring Boot to manage customer balances and transactions that will be called from a mobile application.
https://github.com/charlybutar21/wallet
rest-api solid-principles spring-boot spring-jpa spring-validation
Last synced: 7 months ago
JSON representation
This is a simple REST API application using Spring Boot to manage customer balances and transactions that will be called from a mobile application.
- Host: GitHub
- URL: https://github.com/charlybutar21/wallet
- Owner: charlybutar21
- Created: 2023-09-13T17:14:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-14T04:04:46.000Z (over 2 years ago)
- Last Synced: 2025-04-05T11:32:37.046Z (about 1 year ago)
- Topics: rest-api, solid-principles, spring-boot, spring-jpa, spring-validation
- Language: Java
- Homepage:
- Size: 181 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Wallet
This is an example simple REST API application using Spring Boot to manage customer balances and transactions(top-up, transfer, and refund) that will be called from a mobile application.
## Technology
Technology / Library / Framework used:
* Java 17
* Spring Boot
* Maven
* Junit
* Mockito
* Spring Data JPA
* Spring MVC
* spring Validation
* H2 (In memory database)
* Lombok
## Entity Relationship Diagram

## Use Cases / API Specification
### Register Account
- Endpoint : POST {{host}}/api/accounts
- Description: This endpoint is used to create a new customer account.
- Request Body :
```json
{
"username": "username",
"password": "password",
"accountHolderName": "Full Name"
}
```
- Response Body (Success):
```json
{
"data": "OK",
"errors": null,
"paging": null
}
```
- Response Body (Failed) to all use cases:
```json
{
"data": null,
"errors": "error message",
"paging": null
}
```
### Search Account
- Endpoint : Get {{host}}/api/accounts/search?keyword=xxx&accountNumber
- Description: This endpoint is used for user to search accounts by keyword account holder name or account number.
- Header :
* X-API-TOKEN : {{TOKEN}}
- Query Param:
* keyword: string optional (keyword account holder name)
* accountNumber: long optional
* currentPage: int optional (default 0)
* pageSize: int optional (default 10)
- Response Body (Success):
```json
{
"data": [
{
"accountNumber": 6570613016,
"accountHolderName": "Main",
"balance": 0.00
}
],
"errors": null,
"paging": {
"currentPage": 0,
"pageSize": 10,
"totalPage": 1
}
}
```
### Login Account
- Endpoint : POST {{host}}/api/auth/login
- Description: This endpoint is used for user authentication and get token. The token can then be used for accessing protected resources and making authenticated requests to the application.
- Request Body :
```json
{
"username": "username",
"password": "password"
}
```
- Response Body (Success):
```json
{
"data": "TOKEN",
"errors": null,
"paging": null
}
```
### Get Current Account Detail
- Endpoint : Get {{host}}/api/accounts/current
- Description: This endpoint is used for user to view their current balance information.
- Header :
* X-API-TOKEN : {{TOKEN}}
- Response Body (Success):
```json
{
"data": {
"accountNumber": 9893876597,
"accountHolderName": "Test User",
"balance": 0.00
},
"errors": null,
"paging": null
}
```
### Post Transaction TopUp
- Endpoint : Post {{host}}/api/transactions/top-up
- Description: This endpoint is used for user to top up the balance.
- Header :
* X-API-TOKEN : {{TOKEN}}
- Request Body :
```json
{
"amount": 100000.00,
"sourceAccountNumber": 1234567890,
"destinationAccountNumber": 1234567890,
"description": "notes"
}
```
- Response Body (Success):
```json
{
"data": "OK",
"errors": null,
"paging": null
}
```
### Post Transaction Transfer
- Endpoint : Post {{host}}/api/transactions/top-up
- Description: This endpoint is used for user to transfer money to other account.
- Header :
* X-API-TOKEN : {{TOKEN}}
- Request Body :
```json
{
"destinationAccountNumber": 5235196612,
"amount": 10000,
"referenceNumber": "REF-002",
"description": "gift"
}
```
- Response Body (Success):
```json
{
"data": "OK",
"errors": null,
"paging": null
}
```
### Post Transaction Refund
- Endpoint : Post {{host}}/api/transactions/top-up
- Description: This endpoint is used for user to refund money.
- Header :
* X-API-TOKEN : {{TOKEN}}
- Request Body :
```json
{
"amount": 10000.00,
"sourceAccountNumber": 5235196612,
"destinationAccountNumber": 1234567890,
"description": "cancel"
}
```
- Response Body (Success):
```json
{
"data": "OK",
"errors": null,
"paging": null
}
```
### Get Account Transactions History
- Endpoint : Get {{host}}/api/customers/current/transactions
- Description: This endpoint is used for user to view all transaction histories in his account.
- Header :
* X-API-TOKEN : {{TOKEN}}
- Query Param:
* startTimeEpoch: long optional (unix epoch time in millisecond)
* endTimeEpoch: long optional (unix epoch time in millisecond)
* currentPage: int optional (default 0)
* pageSize: int optional (default 10)
- Response Body (Success):
```json
{
"data": [
{
"type": "TOP_UP",
"amount": 100000.00,
"transactionTimeEpoch": 1694627293823,
"referenceNumber": "REF-001",
"description": "top up dari transfer Bank"
},
{
"type": "TRANSFER",
"amount": 10000.00,
"transactionTimeEpoch": 1694627459943,
"referenceNumber": "REF-002",
"description": "transfer"
},
{
"type": "REFUND",
"amount": 10000.00,
"transactionTimeEpoch": 1694627561121,
"referenceNumber": "REF-003",
"description": "refund"
}
],
"errors": null,
"paging": {
"currentPage": 0,
"pageSize": 10,
"totalPage": 1
}
}
```
## How to Use
**1. Clone the application**
```bash
git clone https://github.com/charlybutar21/wallet.git
```
**2. Build the application**
```bash
mvn clean install
```
**3. Run the spring boot application**
```bash
java -jar target/wallet-0.0.1-SNAPSHOT.jar
```
**4. Access H2 Database GUI with open http://localhost:8080/h2-console/login.jsp**
**5. Open file manual.http and run test requests**
* After run test request **Search User 2**, replace env value USER2_ACCOUNT_NUMBER on file http-client.env.json with value accountNumber from response API search user.
* After run test request **Login User 1**, replace env value TOKEN on file http-client.env.json with value data token from response API login user.