A Spring Boot REST API for managing banking entities: Accounts, Cards, and Transactions. Supports two currencies (USD, LBP) and enforces business rules such as card-account binding and balance checks.
- CRUD operations for accounts, cards, and transactions.
- Process transactions with currency validation (assuming that a card is associated to a max of two accounts, one in each currency, as per the usual in Lebanon.)
- Prevent overdrafts based on available balance (for debit transactions.)
- Exception handling for missing resources and invalid input.
- Java 17
- Spring Boot
- Spring Data JPA
- Hibernate
- PostgreSQL (or other JPA-compatible DB)
- Maven
- Java 17
- Maven 3.8+
- PostgreSQL installed and running,
Update src/main/resources/application.properties
spring.datasource.url=jdbc:postgresql://localhost:[port number]/[your database name]
spring.datasource.username=yourusername
spring.datasource.password=yourpassword
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
POST /accounts/newcreate a new accountGET /accounts/allretrieve all saved accountsGET /accounts/{id}retrieve account details by IDPUT /accounts/{id}updates an account's fields.
POST /cards/newcreates a new cardGET /cards/allretrieves all saved cardsGET /cards/{id}retrieves card details by IDPUT /cards/{id}updates a card's fields.
POST /transactions/newcreates a new transactionGET /transactions/allretrieves all saved transactionsGET /transactions/{id}retrieves transaction details by IDPUT /transactions/{id}updates a transaction's fields.
POST /accounts/new
{
"balance": 1000.00,
"currency": "USD"
}
For more details on formatting, refer to the DTO fields in the classes in com.example.cms.dto