Building a Simple Bank App API with Spring Boot and Spring Data JPA



This content originally appeared on DEV Community and was authored by Muha-mmed

When learning backend development, one of the best ways to practice is by building something practical and relatable. For me, that turned out to be a Bank App API — a Spring Boot project where users can create accounts, deposit and withdraw money, check balances, and even close accounts.

This project gave me hands-on experience with Spring Boot, Spring Data JPA, and REST API design, while also teaching me how to think about real-world requirements like account numbers and user authentication.

🛠 Tech Stack

Spring Boot – for building the REST API.

Spring Data JPA – for interacting with the database.

Maven – build and dependency management.

Database – works with relational databases like MySQL (but could also run on H2 for testing).

📌 Features Implemented

The application exposes endpoints under /account. Here’s what you can do:

Create an account
POST /account – Add a new account to the system.

Get account by account number
GET /account/{accountNumber} – Fetch details for a specific account.

Get all accounts
GET /account – Retrieve all stored accounts.

Deposit money
PUT /account/deposit/{accountNumber}/{amount} – Increase the account balance.

Withdraw money
PUT /account/withdraw/{accountNumber}/{amount} – Deduct from the account balance.

Close an account
DELETE /account/delete/{id} – Remove an account from the system.

Here’s a snippet from the controller:

public class AccountController {

    @Autowired
    AccountService service;


    @PostMapping
    public ResponseEntity<Account> createAccount(@RequestBody Account account){
        Account createAccount =service.createAccount(account);
        return ResponseEntity.status(HttpStatus.CREATED).body(createAccount);
    }

    @GetMapping("/{accountNumber}")
    public Account getAccountDetailsByAccountNumber(@PathVariable Long accountNumber) {
        Account getAccountDetail = service.getAccountDetailsByAccountNumber(accountNumber);
        return getAccountDetail;
    }

    @GetMapping
    public List<Account> getAllAccountDetails() {
        List<Account> getAccountDetail = service.getAllAccountDetails();
        return getAccountDetail;
    }

    @PutMapping("/deposit/{accountNumber}/{amount}")
    public Account depositAmount(@PathVariable Long accountNumber,@PathVariable Double amount){
        Account account = service.depositAmount(accountNumber,amount);
        return account;
    }

    @PutMapping("/withdraw/{accountNumber}/{amount}")
    public Account withdrawAmount(@PathVariable Long accountNumber,@PathVariable Double amount){
        Account account = service.withdrawAmount(accountNumber,amount);
        return account;
    }

    @DeleteMapping("/delete/{accountNumber}")
    public ResponseEntity<String> closeAccount(@PathVariable Long accountNumber){
        return ResponseEntity.status(HttpStatus.NO_CONTENT).body(service.closeAccount(accountNumber));
    }
} 

⚡ Challenges & Learning

Building this project gave me valuable practice with:

  • Structuring a Spring Boot project with controllers, services, and repositories.

  • Working with Spring Data JPA to simplify database operations.

  • Designing clean and RESTful API endpoints.

  • Testing endpoints using Postman.

I also realized how important it is to think ahead about real-world requirements. For example, account numbers should be standardized (e.g., 10-digit numbers) and authentication is needed to secure operations like deposit and withdrawal.

🔮 Future Improvements

This project is still growing, and here’s what I plan to add next:

  • Unique 10-digit account numbers (instead of relying on auto-generated IDs).

  • Login and Signup functionality, powered by Spring Security.

  • Improved error handling and validation (e.g., prevent overdrawing).

Transaction history and account statements.

🎯 Conclusion

The Bank App project may be simple, but it demonstrates core backend concepts:

  • Building REST APIs with Spring Boot.

  • Using JPA for database operations.

  • Structuring an application into layered components.

It’s a solid step in my Spring Boot journey, and I plan to keep improving it as I learn more about authentication, security, and production deployment.

🔗 Check it out on GitHub: Bank-App-Spring-Boot


This content originally appeared on DEV Community and was authored by Muha-mmed