Last Updated: October 31, 2025
Project: Banking Management System
Course: System Software, IIIT Bangalore
- ← Back to Main README
- Quick Start Guide - Get started in 5 minutes
- Class Diagram - UML architecture
- Workflow - Implementation logic
┌─────────────────────────────────────────────────────────────┐
│ BANK MANAGEMENT SYSTEM │
│ (Client-Server Architecture) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ TCP/IP Socket (Port 8080) │
└─────────────────────────────────────────┘
│
┌─────────────┴─────────────┐
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ Server │ │ Client(s) │
│ (Fork-based │ │ (Multiple) │
│ Concurrent) │ │ │
└──────────────┘ └──────────────┘
│
▼
┌──────────────┐
│ File-based │
│ Database │
│ (w/ Locks) │
└──────────────┘
START
│
├─► Server Initialization
│ ├─► Create Socket (AF_INET, SOCK_STREAM)
│ ├─► Bind to Port 8080
│ ├─► Listen for connections
│ └─► Initialize Database Files
│
├─► Client Connection
│ ├─► Accept Connection
│ ├─► Fork New Process
│ └─► Handle Client in Child Process
│
├─► User Authentication
│ ├─► Display Login Screen
│ ├─► Validate Credentials
│ ├─► Check Session Status (One session per user)
│ └─► Determine User Role
│
├─► Role-Based Menu
│ ├─► Customer Menu
│ ├─► Employee Menu
│ ├─► Manager Menu
│ └─► Administrator Menu
│
├─► Execute Operations
│ ├─► File Locking (fcntl)
│ ├─► Read/Write Data
│ ├─► Update Records
│ └─► Release Locks
│
└─► Logout & Cleanup
├─► Mark Session Inactive
├─► Close Connection
└─► Exit Child Process
Client Connects → Display Login → Enter Credentials
│
▼
Validate User
│
┌────────────────────┼────────────────────┐
│ │ │
INVALID VALID INACTIVE
│ │ │
▼ ▼ ▼
Retry Login Check Session Status Account Disabled
│
┌────────────────────┼────────────────────┐
│ │
SESSION_ACTIVE SESSION_INACTIVE
│ │
▼ ▼
Already Logged In Mark Session Active
(Deny) │
▼
Load Role-Based Menu
- View Account Balance
- Deposit Money
- Withdraw Money
- Transfer Funds
- Apply for Loan
- View Loan Status
- Change Password
- Add Feedback
- View Transaction History
- Logout
- Exit
Request Operation
│
▼
Lock Account File (Write Lock)
│
▼
Read Current Balance
│
▼
Validate Operation (Sufficient funds for withdraw)
│
▼
Update Balance
│
▼
Create Transaction Record
│
▼
Write to Files
│
▼
Release Lock
│
▼
Confirm to User
Request Transfer (From A to B)
│
▼
Lock Account A (Write Lock)
│
▼
Lock Account B (Write Lock)
│
▼
Validate Accounts & Balance
│
▼
Deduct from Account A
│
▼
Add to Account B
│
▼
Create Transaction Record
│
▼
Write All Changes
│
▼
Release Both Locks
│
▼
Confirm Success
- Add New Customer
- Modify Customer Details
- View Assigned Loan Applications
- Approve/Reject Loans
- View Customer Transactions
- Change Password
- Logout
- Exit
Get Customer Details
│
▼
Lock User File (Write Lock)
│
▼
Lock Account File (Write Lock)
│
▼
Create User Record
├─ userId (auto-increment)
├─ role = CUSTOMER_ROLE
├─ session_active = INACTIVE
├─ account_active = ACTIVE
└─ Personal Details
│
▼
Create Account Record
├─ accountId = userId
└─ accountBalance = 0
│
▼
Write Records
│
▼
Release Locks
│
▼
Confirm Success
View Assigned Loans (assignedID = employeeId)
│
▼
Select Loan
│
▼
Lock Loan File (Write Lock)
│
▼
Choose Action: Approve/Reject
│
├─► Approve
│ ├─► Lock Account File
│ ├─► Credit Loan Amount
│ ├─► Update loanStatus = APPROVED
│ └─► Release Locks
│
└─► Reject
├─► Update loanStatus = REJECTED
└─► Release Lock
- Activate Customer Account
- Deactivate Customer Account
- Assign Loan Applications to Employees
- Review Customer Feedback
- Change Password
- Logout
- Exit
View Unassigned Loans (assignedID = -1)
│
▼
Lock Loan File (Write Lock)
│
▼
Select Loan
│
▼
Enter Employee ID
│
▼
Update assignedID = employeeId
│
▼
Write to File
│
▼
Release Lock
│
▼
Confirm Assignment
View Non-Reviewed Feedback
│
▼
Lock Feedback File (Write Lock)
│
▼
Select Feedback
│
▼
Add Action/Response
│
▼
Update reviewStatus = REVIEWED
│
▼
Write to File
│
▼
Release Lock
│
▼
Confirm Review
- Add New Bank Employee
- Modify Customer/Employee Details
- Manage User Roles
- Change Password
- Logout
- Exit
Get Employee Details
│
▼
Lock User File (Write Lock)
│
▼
Create User Record
├─ userId (auto-increment)
├─ role = EMPLOYEE_ROLE or MANAGER_ROLE
├─ session_active = INACTIVE
├─ account_active = ACTIVE
└─ Personal Details
│
▼
Write Record
│
▼
Release Lock
│
▼
Confirm Success
Operation Request
│
▼
Open File (O_RDWR)
│
▼
Determine Lock Type
│
├─► Read Operation → F_RDLCK (Shared Lock)
└─► Write Operation → F_WRLCK (Exclusive Lock)
│
▼
fcntl(fd, F_SETLKW, lock) - Blocking Wait
│
▼
Lock Acquired
│
▼
Perform File Operation
│
▼
fcntl(fd, F_SETLK, F_UNLCK) - Release Lock
│
▼
Close File
- All operations within a transaction complete or none do
- Use file locking to ensure atomic updates
- Validate all inputs before processing
- Check account balances before withdrawals
- Verify user roles before operations
- File locks prevent concurrent modifications
- Read locks for queries, write locks for updates
- Multiple read locks allowed, exclusive write locks
- All changes written to disk immediately
- Binary file format ensures data persistence
- Transaction logs maintain operation history
user.db- User records (User struct)account.db- Account records (Account struct)loan.db- Loan records (Loan struct)transaction.db- Transaction records (Transaction struct)feedback.db- Feedback records (Feedback struct)
typedef struct {
int userId;
int role; // 1=Admin, 2=Employee, 3=Manager, 4=Customer
int session_active; // 1=Active, 0=Inactive
int account_active; // 1=Active, 0=Inactive
char name[50];
char age[5];
char address[100];
char phone[20];
char username[20];
char password[20];
} User;typedef struct {
int accountId;
int accountBalance;
} Account;typedef struct {
int loanId;
int loanAmount;
int accountID;
int assignedID; // -1=Not assigned, else employeeId
int loanStatus; // 0=Processing, 1=Approved, 2=Rejected
} Loan;typedef struct {
int transactionId;
int previousAmount;
int transactionAmount;
int lastAmount;
int from_uid;
int to_uid;
} Transaction;typedef struct {
int feedbackId;
int userId;
char feedback[1000];
char action[1000];
int reviewStatus; // 0=Not Reviewed, 1=Reviewed
} Feedback;- Multiple customers can view balance simultaneously
- Shared read locks (F_RDLCK) allow concurrent access
- No blocking between readers
- Customer A viewing balance (read lock)
- Customer B depositing money (write lock)
- Writer waits for reader to finish
- Exclusive access granted to writer
- Customer A withdrawing (write lock)
- Customer B depositing (write lock)
- Second writer waits for first to complete
- Sequential execution enforced
- Lock both accounts in order
- Prevents deadlock by consistent ordering
- Atomic operation across two accounts
Login Attempt
│
▼
Lock User File (Read)
│
▼
Check session_active
│
├─► ACTIVE → Deny Login
└─► INACTIVE → Continue
│
▼
Upgrade to Write Lock
│
▼
Set session_active = ACTIVE
│
▼
Release Lock
│
▼
Grant Access
Logout
│
▼
Lock User File (Write)
│
▼
Set session_active = INACTIVE
│
▼
Release Lock
- File Open Error: Log error, notify client, return to menu
- Lock Timeout: Retry with timeout, notify if failed
- Insufficient Funds: Release locks, send error message
- Invalid Input: Validate, request re-entry
- User Not Found: Send error message
- Connection Lost: Cleanup resources, release locks, mark session inactive
- Client-Server communication via TCP sockets
send_message(fd, msg)- Send string messagereceive_message(fd, buffer)- Receive string message- Blocking I/O for synchronous operations
Client Server
│ │
├──── Connect ─────────────────►│
│ │
│◄──── Login Prompt ────────────┤
│ │
├──── Credentials ─────────────►│
│ │
│◄──── Menu Options ────────────┤
│ │
├──── Operation Request ───────►│
│ │
│◄──── Result/Confirmation ─────┤
│ │
├──── Logout ──────────────────►│
│ │
│◄──── Disconnect ──────────────┤
Server Start
│
▼
Check Database Files
│
├─► Exist → Load Existing Data
│
└─► Don't Exist
│
▼
Create Database Directory
│
▼
Create Default Admin
├─ userId: 1
├─ role: ADMIN_ROLE
├─ username: "admin"
└─ password: "admin123"
│
▼
Initialize Empty Files
├─ user.dat
├─ account.dat
├─ loan.dat
├─ transaction.dat
└─ feedback.dat
Customer → Select Deposit Option
│
▼
Enter Amount to Deposit
│
▼
Validate Amount (> 0)
│
├─► Invalid → Display Error → Return to Menu
│
▼ Valid
Lock Account File (Write Lock - F_WRLCK)
│
▼
Read Current Account Record
│
▼
Calculate New Balance
oldBalance = account.accountBalance
newBalance = oldBalance + depositAmount
│
▼
Update Account Record
account.accountBalance = newBalance
│
▼
Write Updated Account to File
│
▼
Create Transaction Record
transactionId = generateUniqueTransactionId()
from_uid = -1 (indicates deposit)
to_uid = accountId
previousAmount = oldBalance
transactionAmount = depositAmount
lastAmount = newBalance
│
▼
Write Transaction to File
│
▼
Release Account Lock
│
▼
Display Success Message
"Deposit Successful!"
"New Balance: ₹{newBalance}"
│
▼
Return to Menu
Customer → Select Withdraw Option
│
▼
Enter Amount to Withdraw
│
▼
Validate Amount (> 0)
│
├─► Invalid → Display Error → Return to Menu
│
▼ Valid
Lock Account File (Write Lock - F_WRLCK)
│
▼
Read Current Account Record
│
▼
Check Sufficient Balance
currentBalance >= withdrawAmount ?
│
├─► NO → Release Lock → Display Error → Return to Menu
│
▼ YES
Calculate New Balance
oldBalance = account.accountBalance
newBalance = oldBalance - withdrawAmount
│
▼
Update Account Record
account.accountBalance = newBalance
│
▼
Write Updated Account to File
│
▼
Create Transaction Record
transactionId = generateUniqueTransactionId()
from_uid = accountId
to_uid = -1 (indicates withdrawal)
previousAmount = oldBalance
transactionAmount = withdrawAmount
lastAmount = newBalance
│
▼
Write Transaction to File
│
▼
Release Account Lock
│
▼
Display Success Message
"Withdrawal Successful!"
"New Balance: ₹{newBalance}"
│
▼
Return to Menu
Customer → Select Apply for Loan
│
▼
Enter Loan Amount
│
▼
Validate Amount (> 0)
│
├─► Invalid → Display Error → Return to Menu
│
▼ Valid
Lock Loan File (Write Lock)
│
▼
Create New Loan Record
loanId = generateUniqueLoanId()
loanAmount = requestedAmount
accountID = customer.userId
assignedID = -1 (LOAN_NOTASSIGNED)
loanStatus = 0 (LOAN_PROCESSING)
│
▼
Write Loan Record to File
│
▼
Release Loan Lock
│
▼
Display Success Message
"Loan Application Submitted!"
"Loan ID: {loanId}"
"Status: Processing"
"You will be notified once processed"
│
▼
Return to Menu
Customer → Select View Transactions
│
▼
Lock Transaction File (Read Lock - F_RDLCK)
│
▼
Search All Transactions
WHERE from_uid = userId OR to_uid = userId
│
▼
Read Matching Records into Array
│
▼
Release Transaction Lock
│
▼
Display Transaction Table
┌──────┬──────────┬────────┬──────────┬──────────┐
│ ID │ Type │ Amount │ Before │ After │
├──────┼──────────┼────────┼──────────┼──────────┤
│ 1001 │ Deposit │ 5000 │ 10000 │ 15000 │
│ 1002 │ Withdraw │ 2000 │ 15000 │ 13000 │
│ 1003 │ Transfer │ 1000 │ 13000 │ 12000 │
└──────┴──────────┴────────┴──────────┴──────────┘
│
▼
Wait for User Input (Press Enter)
│
▼
Return to Menu
| Operation | Customer | Employee | Manager | Admin |
|---|---|---|---|---|
| View Own Balance | ✓ | ✗ | ✗ | ✗ |
| Deposit Money | ✓ | ✗ | ✗ | ✗ |
| Withdraw Money | ✓ | ✗ | ✗ | ✗ |
| Transfer Funds | ✓ | ✗ | ✗ | ✗ |
| Apply for Loan | ✓ | ✗ | ✗ | ✗ |
| View Loan Status | ✓ | ✗ | ✗ | ✗ |
| Submit Feedback | ✓ | ✗ | ✗ | ✗ |
| View Own Transactions | ✓ | ✗ | ✗ | ✗ |
| Add Customer | ✗ | ✓ | ✗ | ✗ |
| Modify Customer | ✗ | ✓ | ✗ | ✓ |
| Process Loans | ✗ | ✓ | ✗ | ✗ |
| View Customer Transactions | ✗ | ✓ | ✗ | ✗ |
| Assign Loans | ✗ | ✗ | ✓ | ✗ |
| Activate/Deactivate Account | ✗ | ✗ | ✓ | ✗ |
| Review Feedback | ✗ | ✗ | ✓ | ✗ |
| Add Employee/Manager | ✗ | ✗ | ✗ | ✓ |
| Change User Role | ✗ | ✗ | ✗ | ✓ |
| Modify Any User | ✗ | ✗ | ✗ | ✓ |
| Change Own Password | ✓ | ✓ | ✓ | ✓ |
| Logout | ✓ | ✓ | ✓ | ✓ |
┌─────────────┐
│ LOGGED │
│ OUT │◄──────────────┐
└─────────────┘ │
│ │
│ Login Success │ Logout
│ │
▼ │
┌─────────────┐ │
│ LOGGED │ │
│ IN │───────────────┘
└─────────────┘
│
│ Connection Lost
│
▼
┌─────────────┐
│ FORCE │
│ LOGOUT │
└─────────────┘
┌─────────────┐
│ CREATED │
│ (Customer) │
└─────────────┘
│
│ Submit
│
▼
┌─────────────┐
│ UNASSIGNED │
│ (assignedID │
│ = -1) │
└─────────────┘
│
│ Manager Assigns
│
▼
┌─────────────┐
│ ASSIGNED │
│ (assignedID │
│ = empId) │
└─────────────┘
│
│ Employee Reviews
│
├──────────┬──────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ APPROVED │ │ REJECTED │ │PROCESSING│
│(Status=1)│ │(Status=2)│ │(Status=0)│
└──────────┘ └──────────┘ └──────────┘
│ │
│ │
▼ ▼
┌──────────────────────┐
│ FINAL STATE │
│ (No further changes) │
└──────────────────────┘
┌─────────────┐
│ CREATED │
│ (Active) │
└─────────────┘
│
│ Manager Deactivates
│
▼
┌─────────────┐
│ DEACTIVATED │
│ (Inactive) │
└─────────────┘
│
│ Manager Activates
│
▼
┌─────────────┐
│ ACTIVATED │
│ (Active) │
└─────────────┘
┌─────────────┐
│ SUBMITTED │
│ (Customer) │
└─────────────┘
│
│ Submit
│
▼
┌─────────────┐
│ PENDING │
│ (Status=0) │
└─────────────┘
│
│ Manager Reviews
│
▼
┌─────────────┐
│ REVIEWED │
│ (Status=1) │
│ + Action │
└─────────────┘
┌──────────────┐
│ │
┌──────────►│ Banking │◄──────────┐
│ │ Management │ │
│ │ System │ │
│ │ │ │
│ └──────────────┘ │
│ │ │
│ │ │
┌────────┐ ┌────────┐ ┌────────┐
│Customer│ │Employee│ │Manager │
└────────┘ └────────┘ └────────┘
│ │ │
│ │ │
│ ┌──────────────┐ │
└──────────►│ │◄──────────┘
│ Admin │
│ │
└──────────────┘
Customer ──────► [1.0 Authentication] ──────► User DB
│
▼
[2.0 Account Operations]
│ │
▼ ▼
Account DB Transaction DB
│
▼
[3.0 Loan Management]
│
▼
Loan DB
│
▼
[4.0 Feedback System]
│
▼
Feedback DB
Customer Client Server Account DB Transaction DB
│ │ │ │ │
│──Request──►│ │ │ │
│ │──Send───►│ │ │
│ │ │──Lock A────►│ │
│ │ │◄──Locked────│ │
│ │ │──Lock B────►│ │
│ │ │◄──Locked────│ │
│ │ │──Read A────►│ │
│ │ │◄──Data──────│ │
│ │ │──Read B────►│ │
│ │ │◄──Data──────│ │
│ │ │──Update A──►│ │
│ │ │──Update B──►│ │
│ │ │──Create Txn─┼─────────────►│
│ │ │──Unlock────►│ │
│ │◄─Result─│ │ │
│◄─Display──│ │ │ │
This flowchart document provides comprehensive visualization of:
- System architecture and components
- User authentication and authorization flows
- Role-specific operations and menus
- Database operations with concurrency control
- File locking mechanisms
- ACID property implementation
- Error handling strategies
- Communication protocols
- State transitions
- Data flow patterns
For implementation details, refer to:
- Main README - Complete project documentation and setup
- Quick Start Guide - Get started in 5 minutes
- Class Diagram - UML architecture visualization
- Workflow - System workflow implementation
- Source Code -
code/src/andcode/include/directories
| Document | Description | Link |
|---|---|---|
| README | Main documentation, installation, usage | README.md |
| Quick Start | 5-minute setup guide | QUICK_START.md |
| Class Diagram | UML architecture | class_diagram.puml |
| Workflow | Implementation logic | workflow.c |
| Source Code | Implementation files | ../code/src/ |
| Headers | Function declarations | ../code/include/ |
End of Flowchart Documentation