This project is an implementation of simple bank REST API, which allows to create users,
accounts in different currencies for users and provides money transfer between any two
accounts. Only ADMIN can create users, accounts and access information about all users and accounts.
User has access to his accounts and money transfers. If currency of destination account differs from the source account - amount
will be converted according actual
currency exchange rate, which is obtained from side API.
You can test this app through Swagger UI,
which is available at http://localhost:8080/swagger-ui/
.
All input data is being validated.
These features are realized with:
- MySQL (DB layer)
- Java (Service layer)
- Spring Boot
- Spring Security (Authentication/Authorization) with JWT
- Swagger
- Docker
Steps 1-7 can be skipped.
1. Download and install the
JDK,
Git and Maven .
Clone this project with command git clone https://github.com/semyonich/bank-service.git
2. Download and install MySQL Server.
3. Create payment_portal
schema in your DB and user without password.
4. Download and install IDE with Spring support.
For example IntelliJ IDEA .
5. Open project in your IDE.
6. Setup values in the file "application.properties" :
- spring.datasource.url: jdbc:mysql://"your_DB_URL:port"/payment_portal
- spring.datasource.username: "your_DB_username"
- application.admin.username: ADMIN_PHONE_NUMBER
- application.admin.password: ADMIN_PASSWORD
7. Run a project.
8. Or you can skip steps 1-7 and install Docker .
Enter project dir in terminal and run command: docker-compose up
.
9. Project now is available on http://localhost:8080
. You can send requests using
Postman or
visit http://localhost:8080/swagger-ui/
.
10. As apllication is secured with Spring Security and JWT authentication,
at first you need to get JWT with Postman. Send POST request with body
{ "username": "ADMIN_PHONE_NUMBER", "password": "ADMIN_PASSWORD" }
to URL http://localhost:8080/auth
.
Content-Type
in Headers should be application/json
. You will get response
{"username":"ADMIN_PHONE_NUMBER","token":YOUR_TOKEN}
.
- If you use Postman to test API, on Authorization tab you should choose
OAuth2.0
, insert this token in fieldAccess Token
of every of your requests and add Header PrefixBearer_
. - If you use Swagger to test API, on the Swagger UI page tap button
Authorize
and enter your token with Header Prefix in formatBearer_YOUR_TOKEN
. Now you can send requests and get responses with Swagger.