This Spring Boot application serves as a REST API for a banking system. It allows users to manage accounts, transactions, users, perform financial operations such as depositing and withdrawing money , and also delete account.
MIT License
This Spring Boot application serves as a REST API for a banking system. It allows users to manage accounts, transactions, users, perform financial operations such as depositing and withdrawing money , and also delete account.
Visit this link to see the video explanation https://www.linkedin.com/posts/ayushmajumdar_restapi-springboot-java-activity-7165247588311425024-P9Iy?utm_source=share&utm_medium=member_desktop
Clone the repository:
git clone https://github.com/your_username/banking-system.git
Navigate to the project directory:
cd banking-system
Update the application.properties
file in src/main/resources
with your MySQL database configurations:
spring.datasource.url=jdbc:mysql://localhost:3306/your_database_name
spring.datasource.username=your_mysql_username
spring.datasource.password=your_mysql_password
Build the project using Maven:
mvn clean package
Run the application:
java -jar target/banking-system.jar
The API exposes the following endpoints:
Accounts:
GET /accounts
: Retrieve all accounts.GET /accounts/{accountId}
: Retrieve a specific account by ID.POST /accounts
: Create a new account.PUT /accounts/{accountId}
: Update an existing account.DELETE /accounts/{accountId}
: Delete an account.Transactions:
GET /accounts/{accountId}/transactions
: Retrieve all transactions for a specific account.GET /accounts/{accountId}/transactions/{transactionId}
: Retrieve a specific transaction by ID for an account.POST /accounts/{accountId}/transactions
: Create a new transaction for an account.PUT /accounts/{accountId}/transactions/{transactionId}
: Update an existing transaction for an account.DELETE /accounts/{accountId}/transactions/{transactionId}
: Delete a transaction for an account.Users:
GET /users
: Retrieve all users.GET /users/{userId}
: Retrieve a specific user by ID.POST /users
: Create a new user.PUT /users/{userId}
: Update an existing user.DELETE /users/{userId}
: Delete a user.Financial Operations:
POST /operations/withdraw
: Withdraw money from an account.The API requires authentication for certain endpoints. To authenticate, obtain a JWT token by sending a POST request to /auth/login
with valid credentials. Include the token in the Authorization header of subsequent requests with the format: Bearer {token}
.
Example:
POST /auth/login
Content-Type: application/json
{
"username": "example_user",
"password": "example_password"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Include the obtained token in subsequent requests:
GET /accounts
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Postman is a popular API client that allows you to test API endpoints quickly and efficiently. You can use Postman to send requests to your REST API endpoints and verify their functionality.
Download and Install Postman:
Import Your API Collection:
Send Requests:
Inspect Responses:
To help you get started, here's an example Postman collection that includes requests for the endpoints in your project:
You can also use Postman to create and run automated tests for your API endpoints. Postman provides a testing framework that allows you to write scripts to validate responses and ensure that your API behaves as expected.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License.
Replace `link_to_your_postman_collection` with the actual link to your Postman collection if you have one. Otherwise, you can leave it as is or remove the placeholder.