Software Requirements Specification

Wallet Module
WALLET
Version1.0
SystemHR Management System
ModuleWALLET - Electronic Wallet
Databasewallet_db
Date2026-08-05
AuthorNam Nguyen
StatusDraft

Table of Contents

1. Introduction

1.1 Purpose

This document defines the software requirements for the Wallet module of the HR Management System. The Wallet module provides electronic wallet functionality for managing payments, deposits, withdrawals, and financial transactions within the recruitment platform.

1.2 Scope

The Wallet module manages electronic wallet operations including:

1.3 Module Dependencies

ModuleDependency TypeDescription
AUTHHardUser authentication and JWT token validation
RECRSoftJob posting payments and recruitment services
LOGSoftEvent logging for financial audit trail

1.4 Definitions

TermDefinition
SRSSoftware Requirements Specification
FRFunctional Requirement
NFRNon-Functional Requirement
UCUse Case
DRData Requirement
IRIntegration Requirement
PGPayment Gateway

1.5 User Roles

RoleDescriptionKey Permissions
UserAll registered users (Candidate, HR, Employer)View balance, deposit, withdraw, make payments, view transactions
AdminSystem administratorsApprove withdrawals, freeze wallets, view all wallets, process payouts
Payment GatewayExternal payment processorsProcess payments, send webhooks, verify transactions

2. Module Overview

2.1 Module Description

AspectValue
Module CodeWALLET
Module NameElectronic Wallet
DescriptionElectronic wallet for payments, deposits, withdrawals, and financial transactions
Databasewallet_db
Tableswallet_wallets, wallet_transactions, wallet_payment_methods, wallet_payment_orders, wallet_payout_requests
Tech StackNestJS, Drizzle ORM, PostgreSQL, RabbitMQ

2.2 Use Case Diagram

Use Case Diagram
Figure 1: Wallet Use Case Diagram

3. Detailed Use Case Specifications

3.1 UC-01: View Wallet Balance

FieldDescription
Use Case IDUC-01
NameView Wallet Balance
ActorUser (all roles)
PreconditionUser is logged in
PostconditionUser views wallet balance and status
TriggerUser accesses wallet page

Main Flow:

  1. User navigates to wallet page
  2. System validates JWT token
  3. System retrieves user_id from token
  4. System queries wallet_wallets table
  5. System returns wallet data (balance, currency, status)
  6. User views wallet balance

Alternative Flows:

UC-01 Activity Diagram
Figure 2: UC-01 View Wallet Balance - Activity Diagram
UC-01 Sequence Diagram
Figure 3: UC-01 View Wallet Balance - Sequence Diagram

3.2 UC-02: Deposit Funds

FieldDescription
Use Case IDUC-02
NameDeposit Funds
ActorUser
PreconditionUser is logged in, wallet exists
PostconditionFunds added to wallet balance
TriggerUser clicks "Deposit" button

Main Flow:

  1. User selects deposit method (bank transfer, credit card, e-wallet)
  2. User enters deposit amount
  3. System validates amount (min/max limits)
  4. System creates wallet_transactions record (status: pending)
  5. System redirects to Payment Gateway
  6. User completes payment on Payment Gateway
  7. Payment Gateway sends webhook callback
  8. System updates transaction status (completed)
  9. System updates wallet balance
  10. User sees updated balance

Alternative Flows:

UC-02 Activity Diagram
Figure 4: UC-02 Deposit Funds - Activity Diagram
UC-02 Sequence Diagram
Figure 5: UC-02 Deposit Funds - Sequence Diagram

3.3 UC-03: View Transaction History

FieldDescription
Use Case IDUC-03
NameView Transaction History
ActorUser
PreconditionUser is logged in, wallet has transactions
PostconditionUser views transaction history
TriggerUser accesses transaction history page

Main Flow:

  1. User navigates to transaction history
  2. System retrieves transactions with filters (type, date range, status)
  3. System returns paginated transaction list
  4. User views transaction details

3.4 UC-04: Set Wallet PIN

FieldDescription
Use Case IDUC-04
NameSet Wallet PIN
ActorUser
PreconditionUser is logged in, wallet exists
PostconditionWallet PIN set for transaction authorization
TriggerUser clicks "Set PIN" or "Change PIN"

Main Flow:

  1. User enters new PIN (6 digits)
  2. System validates PIN format
  3. System hashes PIN and stores in wallet_wallets
  4. System confirms PIN set successfully

3.5 UC-05: Add Payment Method

FieldDescription
Use Case IDUC-05
NameAdd Payment Method
ActorUser
PreconditionUser is logged in, wallet exists
PostconditionPayment method added to wallet
TriggerUser clicks "Add Payment Method"

Main Flow:

  1. User selects payment method type (bank account, credit card, debit card, e-wallet)
  2. User enters account details
  3. System validates account details
  4. System saves payment method (is_verified: false)
  5. System initiates verification process
  6. Payment method verified and activated

3.6 UC-06: Request Withdrawal

FieldDescription
Use Case IDUC-06
NameRequest Withdrawal
ActorUser
PreconditionUser is logged in, wallet has sufficient balance
PostconditionWithdrawal request submitted for approval
TriggerUser clicks "Withdraw"

Main Flow:

  1. User selects payment method for withdrawal
  2. User enters withdrawal amount
  3. System validates amount and checks limits
  4. System creates wallet_payout_requests record (status: pending)
  5. System freezes withdrawal amount in wallet
  6. System notifies admin for approval
  7. Admin reviews and approves request
  8. System processes payment to bank account
  9. System updates wallet balance

Alternative Flows:

UC-06 Activity Diagram
Figure 6: UC-06 Request Withdrawal - Activity Diagram
UC-06 Sequence Diagram
Figure 7: UC-06 Request Withdrawal - Sequence Diagram

3.7 UC-07: Transfer to Another Wallet

FieldDescription
Use Case IDUC-07
NameTransfer to Another Wallet
ActorUser
PreconditionUser is logged in, sufficient balance
PostconditionFunds transferred to recipient wallet
TriggerUser clicks "Transfer"

Main Flow:

  1. User enters recipient email or wallet ID
  2. System validates recipient exists
  3. User enters transfer amount
  4. System validates amount and balance
  5. User confirms with wallet PIN
  6. System deducts from sender wallet
  7. System credits to recipient wallet
  8. System creates transaction records for both wallets

3.8 UC-08: Pay for Job Posting

FieldDescription
Use Case IDUC-08
NamePay for Job Posting
ActorEmployer
PreconditionEmployer is logged in, job created
PostconditionPayment completed, job posting activated
TriggerEmployer submits job for payment

Main Flow:

  1. Employer creates job posting
  2. System creates wallet_payment_orders record
  3. System checks wallet balance
  4. System prompts for wallet PIN
  5. Employer enters PIN
  6. System verifies PIN and deducts amount
  7. System updates payment order status (paid)
  8. System notifies RECR module to activate job
  9. Employer sees job posted successfully
UC-08 Activity Diagram
Figure 8: UC-08 Pay for Job Posting - Activity Diagram
UC-08 Sequence Diagram
Figure 9: UC-08 Pay for Job Posting - Sequence Diagram

3.9 UC-09: Pay for Featured Job

FieldDescription
Use Case IDUC-09
NamePay for Featured Job
ActorEmployer
PreconditionJob is active
PostconditionJob marked as featured
TriggerEmployer clicks "Feature Job"

Main Flow:

  1. Employer selects job to feature
  2. System displays featured job pricing
  3. Employer confirms payment
  4. System processes payment from wallet
  5. System updates job status to featured

3.10 UC-10: Manage Payment Methods

FieldDescription
Use Case IDUC-10
NameManage Payment Methods
ActorUser
PreconditionUser has payment methods
PostconditionPayment methods updated
TriggerUser accesses payment methods page

Main Flow:

  1. User views list of payment methods
  2. User can add new payment method
  3. User can set default payment method
  4. User can remove payment method

4. Functional Requirements

4.1 Wallet Management Requirements

Req ID Module Requirement Use Case Priority Description
FR-001 WALLET Create Wallet UC-01 High System automatically creates a wallet when user registers
FR-002 WALLET View Wallet Balance UC-01 High Users can view their wallet balance and status
FR-003 WALLET Set Wallet PIN UC-04 High Users can set a 6-digit PIN for transaction authorization
FR-004 WALLET View Transaction History UC-03 High Users can view complete transaction history with filters
FR-005 WALLET Manage Payment Methods UC-05, UC-10 Medium Users can add, remove, and set default payment methods

4.2 Transaction Requirements

Req ID Module Requirement Use Case Priority Description
FR-006 WALLET Deposit Funds UC-02 High Users can deposit funds via bank transfer, credit card, or e-wallet
FR-007 WALLET Request Withdrawal UC-06 High Users can request withdrawals to bank accounts (admin approval required)
FR-008 WALLET Transfer Funds UC-07 Medium Users can transfer funds to other user wallets
FR-009 WALLET Transaction Audit Trail UC-03 High All transactions are logged with before/after balance
FR-010 WALLET Transaction Limits UC-02, UC-06 Medium System enforces daily and monthly transaction limits

4.3 Payment Requirements

Req ID Module Requirement Use Case Priority Description
FR-011 WALLET Pay for Job Posting UC-08 High Employers can pay for job postings using wallet balance
FR-012 WALLET Pay for Featured Job UC-09 Medium Employers can pay to feature their job listings
FR-013 WALLET Payment Orders UC-08, UC-09 High System creates payment orders for all financial transactions
FR-014 WALLET Refund Processing UC-06 Medium System can process refunds for cancelled services
FR-015 WALLET Admin Approval UC-06 High Admins can approve or reject withdrawal requests

5. Data Model

5.1 Entity Relationship Diagram

ERD Diagram
Figure 10: Wallet ERD

5.2 Data Requirements

Req ID Entity Description Related FR
DR-001wallet_walletsUser wallet accounts with balance and limitsFR-001, FR-002
DR-002wallet_transactionsComplete transaction history with audit trailFR-004, FR-009
DR-003wallet_payment_methodsLinked bank accounts and payment cardsFR-005
DR-004wallet_payment_ordersPayment orders for servicesFR-011, FR-012, FR-013
DR-005wallet_payout_requestsWithdrawal requests for admin approvalFR-007, FR-015

6. API Specification

6.1 Endpoint Summary

Wallet Endpoints (All Users)

Method Path Description Requirement IDs
GET/wallet/balanceView wallet balanceFR-002
POST/wallet/pinSet or change wallet PINFR-003
GET/wallet/transactionsView transaction historyFR-004
POST/wallet/depositDeposit fundsFR-006
POST/wallet/withdrawRequest withdrawalFR-007
POST/wallet/transferTransfer to another walletFR-008
POST/wallet/payPay for serviceFR-011, FR-012

Payment Methods Endpoints

Method Path Description Requirement IDs
GET/wallet/payment-methodsList payment methodsFR-005
POST/wallet/payment-methodsAdd payment methodFR-005
PATCH/wallet/payment-methods/:idUpdate payment methodFR-005
DELETE/wallet/payment-methods/:idRemove payment methodFR-005

Admin Endpoints

Method Path Description Requirement IDs
GET/admin/wallet/payoutsList payout requestsFR-015
PATCH/admin/wallet/payouts/:idApprove/reject payoutFR-015
PATCH/admin/wallet/wallets/:id/freezeFreeze/unfreeze walletFR-015
GET/admin/wallet/walletsList all walletsFR-015

Webhook Endpoints

Method Path Description Requirement IDs
POST/webhooks/payment/callbackPayment Gateway callbackFR-006

7. Integration

7.1 Sequence Diagram

Sequence Diagram
Figure 11: Wallet Integration Flow

7.2 Webhook Events

EventDirectionProtocolDescription
wallet.deposit.completedOutboundRabbitMQTriggered when deposit is completed
wallet.payment.completedOutboundRabbitMQTriggered when payment for service is completed
wallet.withdrawal.completedOutboundRabbitMQTriggered when withdrawal is processed
wallet.transfer.completedOutboundRabbitMQTriggered when transfer is completed
payment.callback.receivedInboundWebhookPayment Gateway sends payment status

7.3 Integration with Recruitment Module

IntegrationDirectionProtocolDescription
Job Posting PaymentWALLET -> RECRRabbitMQNotify RECR when job posting is paid
Featured Job PaymentWALLET -> RECRRabbitMQNotify RECR when job is featured
Refund RequestRECR -> WALLETRabbitMQRequest refund for cancelled job

8. Non-Functional Requirements

Req ID Category Requirement Target
NFR-001PerformanceAPI response time for balance queries< 200ms (p95)
NFR-002PerformanceTransaction processing time< 1s
NFR-003ScalabilitySupport concurrent transactions1000+ concurrent users
NFR-004AvailabilitySystem uptime99.99%
NFR-005SecurityTransaction authorizationPIN-based authentication
NFR-006SecurityData encryptionAES-256 for sensitive data
NFR-007ComplianceFinancial audit trailComplete transaction history with timestamps
NFR-008DataTransaction retentionMinimum 7 years

9. Requirements Traceability Matrix

Req ID Requirement Role TDS Section DB Table API Endpoint
FR-001Create WalletSystem3.1wallet_walletsPOST /wallet (auto)
FR-002View Wallet BalanceUser3.1wallet_walletsGET /wallet/balance
FR-003Set Wallet PINUser3.1wallet_walletsPOST /wallet/pin
FR-004View Transaction HistoryUser3.2wallet_transactionsGET /wallet/transactions
FR-005Manage Payment MethodsUser3.3wallet_payment_methodsGET/POST/PATCH/DELETE /wallet/payment-methods
FR-006Deposit FundsUser3.4wallet_transactionsPOST /wallet/deposit
FR-007Request WithdrawalUser3.5wallet_payout_requestsPOST /wallet/withdraw
FR-008Transfer FundsUser3.6wallet_transactionsPOST /wallet/transfer
FR-009Transaction Audit TrailSystem3.2wallet_transactions-
FR-010Transaction LimitsSystem3.4, 3.5wallet_wallets-
FR-011Pay for Job PostingEmployer3.7wallet_payment_ordersPOST /wallet/pay
FR-012Pay for Featured JobEmployer3.7wallet_payment_ordersPOST /wallet/pay
FR-013Payment OrdersSystem3.7wallet_payment_orders-
FR-014Refund ProcessingSystem3.2wallet_transactionsPOST /wallet/refund
FR-015Admin ApprovalAdmin3.5wallet_payout_requestsPATCH /admin/wallet/payouts/:id