Skip to content

RowLee79/Digital_Banking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Digital_Banking

πŸ’³ Digital Banking API (.NET 6)

A simple banking API built with ASP.NET Core 6 and Entity Framework Core. It supports operations like deposits, withdrawals, transfers, balance history tracking, daily transaction limits, and transaction fee calculations.


πŸš€ How to Run the API

βœ… Prerequisites

πŸ’  Setup Steps

  1. Clone the repository

    git clone https://github.com/your-repo/digital-banking-api.git
    cd digital-banking-api
  2. Configure the Database Connection Edit appsettings.json:

    "ConnectionStrings": {
      "DefaultConnection": "Server=localhost;Database=BankingDb;Trusted_Connection=True;"
    }
  3. Apply EF Core Migrations

    dotnet ef migrations add InitialCreate
    dotnet ef database update
  4. Run the API

    dotnet run
  5. Visit Swagger UI at:

    https://localhost:7044/swagger
    

πŸ– Sample API Calls

πŸ‘€ Customer Endpoints

βž• Create Customer

curl -X POST https://localhost:7044/api/Customers \
  -H "Content-Type: application/json" \
  -d '{"firstName":"Juan","lastName":"Dela Cruz","email":"juan@example.com","phone":"09123456789"}'

πŸ“‹ Get All Customers

curl https://localhost:7044/api/Customers

πŸ“„ Get Customer by ID

curl https://localhost:7044/api/Customers/1

πŸ’Ό Account Endpoints

βž• Create Account

curl -X POST https://localhost:7044/api/Accounts \
  -H "Content-Type: application/json" \
  -d '{"customerId":1,"accountType":"Savings"}'

πŸ“‹ Get All Accounts

curl https://localhost:7044/api/Accounts

πŸ“„ Get Account by ID

curl https://localhost:7044/api/Accounts/1

βœ… Update Account Status

curl -X PUT https://localhost:7044/api/Accounts/status \
  -H "Content-Type: application/json" \
  -d '{"accountNumber":"10000001", "isActive": false}'

πŸ’³ Transaction Endpoints

πŸ“… Deposit

curl -X POST https://localhost:7044/api/Transactions/deposit \
  -H "Content-Type: application/json" \
  -d '{"accountNumber":"10000001","amount":1000,"description":"Initial deposit"}'

πŸ“„ Withdraw

curl -X POST https://localhost:7044/api/Transactions/withdraw \
  -H "Content-Type: application/json" \
  -d '{"accountNumber":"10000001","amount":500,"description":"ATM withdraw"}'

πŸ”„ Transfer

curl -X POST https://localhost:7044/api/Transactions/transfer \
  -H "Content-Type: application/json" \
  -d '{"fromAccount":"10000001","toAccount":"10000002","amount":200,"description":"Send money"}'

πŸ“œ Transaction History

curl https://localhost:7044/api/Transactions/history/10000001

πŸ” Search Transactions (by amount or description)

curl "https://localhost:7044/api/Transactions/search?accountNumber=10000001&amount=500"
curl "https://localhost:7044/api/Transactions/search?accountNumber=10000001&description=deposit"

πŸ“ˆ Balance History Endpoints

πŸ“Š Get Balance History

curl https://localhost:7044/api/Transactions/balance-history/10000001

πŸ“€ Export Balance History (CSV / PDF)

curl https://localhost:7044/api/Transactions/balance-history/export/10000001?format=csv
curl https://localhost:7044/api/Transactions/balance-history/export/10000001?format=pdf

πŸ“ƒ Database Schema Overview

🧝 Customer

Field Type
Id int (PK)
FirstName string
LastName string
Email string
Phone string
CreatedDate datetime

πŸ’Ό Account

Field Type
Id int (PK)
AccountNumber string (unique)
CustomerId int (FK)
AccountType string
Balance decimal(18,2)
DailyLimit decimal(18,2)
IsActive bool
CreatedDate datetime

πŸ’Έ Transaction

Field Type
Id int (PK)
FromAccountId int (FK)
ToAccountId int? (FK)
Amount decimal(18,2)
TransactionType string
Description string
Timestamp datetime
Status string

πŸ“ˆ BalanceHistory

Field Type
Id int (PK)
AccountId int (FK)
Balance decimal(18,2)
Timestamp datetime
TransactionId int? (FK)

πŸ“Œ Business Assumptions

  1. Daily Transaction Limit

    • Each account has a DailyLimit to restrict total outgoing transactions per day.
    • Transactions exceeding this amount return a 400 error.
  2. Transaction Fees

    • A flat or tiered transaction fee is applied (e.g., transfer fees).
  3. Balance History Tracking

    • Balance snapshots are recorded after every transaction and can be exported.
  4. Inactive Accounts

    • Accounts marked as IsActive = false are blocked from transactions.
  5. Unique Account Numbers

    • AccountNumber field is unique and indexed.
  6. Currency

    • All currency is represented in Philippine Peso (β‚±) using decimal(18,2) format.

⚠️ Error Response Samples

🚫 400 Bad Request – Daily Transaction Limit Exceeded

{
  "message": "Daily transaction limit exceeded. You can still transact β‚±2000.00 today."
}

πŸ”’ 403 Forbidden – Inactive Account

{
  "message": "Account 10000001 is inactive and cannot perform transactions."
}

🧾 404 Not Found – Account Not Found

{
  "message": "Account with ID 99999 not found."
}

πŸ“‰ 400 Bad Request – Insufficient Balance

{
  "message": "Insufficient balance to complete the transaction."
}

πŸ“„ 500 Internal Server Error – Unexpected Exception

{
  "message": "An unexpected error occurred. Please contact support."
}

πŸ“‚ Postman Collection

You can import the DigitalBankingAPI.postman_collection.json file into Postman for easy testing.


βœ… License

This project is open-source and free to use for educational or non-commercial projects.

About

Digital Banking API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages