MiniBankGo is a robust banking API service built with Go (Golang) that provides secure and efficient banking operations including user management, transactions, and KYC verification.
- User Registration and Authentication
- KYC (Know Your Customer) Management
- Transaction Processing (Deposit, Withdraw, Transfer)
- Admin Dashboard and User Management
- Audit Logging
- Rate Limiting and Security Features
- Real-time Balance Updates
- Transaction History
- AML (Anti-Money Laundering) Compliance
- Go 1.21 or higher
- SQLite (for database)
- Environment variables setup
- Clone the repository:
git clone https://github.com/shariaralphabyte/minibank-go.git
cd minibank-go
- Install dependencies:
go mod download
- Create a
.env
file with the following variables:
DATABASE_URL=minibank.db
JWT_SECRET=your-secret-key-change-in-production
ENCRYPTION_KEY=MiniBankGo2025SecureKey123456789
ADMIN_CODE=MINIBANK_ADMIN_2025
PORT=8080
ENVIRONMENT=development
- Run the application:
go run main.go
POST /api/register
- Register a new userPOST /api/login
- Authenticate userGET /api/health
- Health check endpoint
POST /api/transactions/deposit
- Deposit moneyPOST /api/transactions/withdraw
- Withdraw moneyPOST /api/transactions/transfer
- Transfer money between usersGET /api/transactions
- View transaction history
POST /api/kyc/submit
- Submit KYC documentsPOST /api/admin/kyc/verify
- Verify KYC (Admin only)
GET /api/admin/users
- List all users (Admin only)GET /api/admin/audit-logs
- View audit logs (Admin only)
- JWT-based Authentication
- Rate limiting
- Input validation
- Secure password hashing
- AML compliance checks
- Daily transaction limits
- IP address tracking
- Audit logging
The application can be configured using environment variables:
DATABASE_URL
: Database connection stringJWT_SECRET
: JWT signing secretENCRYPTION_KEY
: Key for sensitive data encryptionADMIN_CODE
: Code for admin registrationPORT
: Server portENVIRONMENT
: Application environment (development/production)MAX_TRANSFER_AMOUNT
: Maximum transfer amountDAILY_TRANSFER_LIMIT
: Daily transfer limit
The API returns standardized error responses with appropriate HTTP status codes:
400 Bad Request
: Invalid input or validation errors401 Unauthorized
: Authentication required403 Forbidden
: Permission denied404 Not Found
: Resource not found500 Internal Server Error
: Server errors
The project includes comprehensive test cases for all major functionality. Here are the detailed test cases:
-
Health Check
- Status code is 200
- Response has status "healthy"
-
User Registration
- Status code is 201
- User created successfully message
- Stores user ID in collection variables
-
Admin Registration
- Status code is 201
- Admin user created successfully message
- Verifies admin status and admin privileges
-
User Login
- Status code is 200
- Verifies token received
- Stores JWT token in collection variables
-
Admin Login
- Status code is 200
- Verifies admin token received
- Stores admin token in collection variables
- Get Profile
- Status code is 200
- Verifies profile data received
- Checks for required fields (email, first_name)
-
Deposit Money
- Status code is 201
- Verifies deposit successful message
- Checks new balance
- Validates transaction record
-
Withdraw Money
- Status code is 201
- Verifies withdrawal successful message
- Checks new balance
- Validates transaction record
-
Transfer Money
- Status code is 201
- Verifies transfer successful message
- Checks sender's new balance
- Validates both sender and recipient transactions
- Verifies reference uniqueness
-
View Transaction History
- Status code is 200
- Verifies transaction list returned
- Checks pagination
- Validates transaction details
-
Submit KYC
- Status code is 201
- Verifies KYC submitted message
- Checks KYC ID returned
- Validates KYC status
-
Verify KYC (Admin)
- Status code is 200
- Verifies KYC verification updated
- Checks status change
- Validates audit log entry
-
Invalid Credentials
- Status code is 401
- Verifies error message
- Checks unauthorized access
-
Insufficient Balance
- Status code is 400
- Verifies error message
- Checks balance validation
-
Invalid Amount
- Status code is 400
- Verifies validation errors
- Checks amount constraints
-
Duplicate Registration
- Status code is 400
- Verifies error message
- Checks unique constraints
-
Unauthorized Access
- Status code is 403
- Verifies permission denied
- Checks admin access requirements
-
JWT Validation
- Verifies token validation
- Checks token expiration
- Validates token claims
-
Rate Limiting
- Tests request limits
- Verifies rate limit responses
- Checks window reset
-
Input Validation
- Tests required fields
- Validates field formats
- Checks length constraints
-
Transaction Limits
- Tests daily limits
- Verifies AML rules
- Checks maximum amounts
-
Audit Logging
- Verifies log creation
- Checks log details
- Validates log format
The following environment variables are used for testing:
base_url=http://localhost:8080
jwt_token= # Stores user JWT token
user_id= # Stores registered user ID
admin_token= # Stores admin JWT token
The test scripts use Postman's test framework to:
- Verify HTTP status codes
- Validate response JSON structure
- Check error messages
- Store and reuse variables
- Test edge cases
- Validate security constraints
- Check database consistency
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details
For support, please open an issue in the GitHub repository or contact the development team.