A cloud-native banking application that detects potentially fraudulent transactions in real-time and notifies customers through an event-driven architecture built on AWS.
- Event-Driven Architecture: Decoupled services using SQS for reliability
- Microservices Pattern: Separate concerns between transaction processing and notifications
- Cloud-Native Design: Serverless and containerized components for scalability
- Security-First Approach: Financial-grade security with zero-trust principles
- ECS Fargate over Lambda: Better for long-running API processes and complex fraud detection logic
- DynamoDB over RDS: NoSQL for flexible fraud log schema and better performance for time-series data
- SQS for Decoupling: Ensures notification reliability even if Lambda fails
- ALB for API Gateway: Better control over routing and security policies
βββββββββββββββ βββββββββββββββ βββββββββββββββββββ
β Client βββββΆβ ALB βββββΆβ ECS Fargate β
β β β β β Transaction β
βββββββββββββββ βββββββββββββββ β API β
βββββββββββ¬ββββββββ
β
ββββββββββββΌβββββββββββ
β Fraud Detection β
β Engine β
ββββββββββββ¬βββββββββββ
β
ββββββββββββΌβββββββββββ
β SQS Queue β
β (Flagged Txns) β
ββββββββββββ¬βββββββββββ
β
ββββββββββββΌβββββββββββ
β Lambda Function β
β (Notifications) β
ββββββββββββ¬βββββββββββ
β
ββββββββββββΌβββββββββββ
β DynamoDB + SNS β
β (Storage + Alerts) β
βββββββββββββββββββββββ
ALB URL: http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com
API Base: http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com/api/v1
# β
LIVE DEPLOYMENT - Real ALB DNS from AWS
SQS Queue: flagged-transactions-dev
DynamoDB Table: fraud-logs-dev
SNS Topic: fraud-notifications-dev
Kinesis Stream: fraud-data-stream-dev
S3 Bucket: fraud-data-lake-dev-123456789
CloudWatch Dashboard: fraud-detection-dashboard-dev
# 1. Login and get JWT token
TOKEN=$(curl -s -X POST http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "password": "password123"}' \
| jq -r '.data.tokens.accessToken')
# 2. Send normal transaction (should be approved)
curl -X POST http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com/api/v1/transactions \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"transaction_id": "test-normal-001",
"amount": "100.00",
"transaction_type": "deposit",
"location": {"lat": 40.7128, "lng": -74.0060, "city": "New York"},
"timestamp": "2024-01-15T10:30:00Z"
}'
# 3. Send suspicious transaction (should be flagged)
curl -X POST http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com/api/v1/transactions \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"transaction_id": "test-suspicious-002",
"amount": "15000.00",
"transaction_type": "withdrawal",
"location": {"lat": 51.5074, "lng": -0.1278, "city": "London"},
"timestamp": "2024-01-15T10:35:00Z"
}'# JWT Configuration
JWKS_URL="https://cognito-idp.us-east-1.amazonaws.com/us-east-1_123456789/.well-known/jwks.json"
JWT_AUDIENCE="fraud-detection-api"
JWT_ISSUER="https://cognito-idp.us-east-1.amazonaws.com/us-east-1_123456789"
# Test 1: No token β 401
curl -X POST http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com/api/v1/transactions \
-H "Content-Type: application/json" \
-d '{"amount": "100"}'
# Expected: 401 Unauthorized
# Test 2: Invalid token β 401
curl -X POST http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com/api/v1/transactions \
-H "Authorization: Bearer invalid-token" \
-H "Content-Type: application/json" \
-d '{"amount": "100"}'
# Expected: 401 Unauthorized
# Test 3: Wrong tenant β 403
curl -X POST http://FraudD-Fraud-VnUQ1cAEgQiB-904840766.us-east-1.elb.amazonaws.com/api/v1/transactions \
-H "Authorization: Bearer valid-token-for-tenant-a" \
-H "X-Tenant-ID: tenant-b" \
-H "Content-Type: application/json" \
-d '{"amount": "100"}'
# Expected: 403 Forbidden- AWS CLI configured
- Node.js 18+
- AWS CDK installed
- Docker (for local testing)
# 1. Install dependencies
npm install
# 2. Bootstrap CDK (first time only)
cdk bootstrap
# 3. Deploy infrastructure
cdk deploy --all
# 4. Run integration tests
npm run test:integration# Valid transaction
curl -X POST https://api.fraud-detection.com/transactions \
-H "Authorization: Bearer <jwt-token>" \
-H "Content-Type: application/json" \
-d '{
"account_id": "acc_123",
"amount": 100.00,
"transaction_type": "withdrawal",
"location": {"lat": 37.7749, "lng": -122.4194},
"timestamp": "2024-01-15T10:30:00Z"
}'# Large withdrawal from unusual location
curl -X POST https://api.fraud-detection.com/transactions \
-H "Authorization: Bearer <jwt-token>" \
-H "Content-Type: application/json" \
-d '{
"account_id": "acc_123",
"amount": 50000.00,
"transaction_type": "withdrawal",
"location": {"lat": 40.7128, "lng": -74.0060},
"timestamp": "2024-01-15T10:30:00Z"
}'- Large Withdrawal Detection: Configurable thresholds per account type
- Geographic Anomaly: Rapid location changes within time windows
- Velocity Checks: Multiple transactions in short timeframes
- Failed Login Patterns: Suspicious authentication attempts
- Time-based Anomalies: Unusual transaction timing patterns
interface FraudRules {
maxWithdrawalAmount: number;
locationChangeThreshold: number; // miles
timeWindowMinutes: number;
maxTransactionsPerWindow: number;
suspiciousHours: number[]; // 24-hour format
}- Transaction processing latency
- Fraud detection accuracy
- Notification delivery success rate
- System error rates
- Cost per transaction processed
- Real-time transaction volume
- Fraud detection patterns
- System health indicators
- Cost optimization metrics
- JWT-based authentication with RS256
- Role-based access control (RBAC)
- API rate limiting and throttling
- Request/response encryption
- Encryption at rest (DynamoDB, S3)
- Encryption in transit (TLS 1.3)
- PII data masking in logs
- Audit trail for all transactions
- Unit tests: >90% coverage
- Integration tests: API endpoints
- End-to-end tests: Complete fraud detection flow
- Load tests: Performance under scale
- Security tests: Penetration testing
npm run test # Unit tests
npm run test:integration # Integration tests
npm run test:e2e # End-to-end tests
npm run test:load # Load testingA: ECS Fargate provides better control over long-running processes, more predictable performance for complex fraud detection algorithms, and easier debugging. Lambda has cold start issues and timeout limitations that could impact real-time fraud detection.
A: We implement a multi-layered approach: 1) Configurable thresholds per customer segment, 2) Machine learning models for pattern recognition, 3) Human review workflows for high-value transactions, 4) Customer feedback loops to improve accuracy.
A: We use SQS with Dead Letter Queues (DLQ) for retry logic, CloudWatch alarms for monitoring failures, and manual intervention workflows. Critical transactions can also trigger immediate alerts to fraud analysts.
A: Horizontal scaling through ECS auto-scaling, DynamoDB on-demand capacity, SQS batch processing optimization, and implementing caching layers. We'd also consider regional deployment for global customers.
- β JWT Authentication with refresh tokens
- β Multi-tenant architecture support
- β Kinesis Firehose for ML pipeline
- β CloudWatch Alarms for anomaly detection
- β Cost optimization with auto-scaling
- β Comprehensive monitoring dashboards
fraud-detection-system/
βββ infrastructure/ # CDK infrastructure code
β βββ lib/
β β βββ vpc-stack.ts
β β βββ ecs-stack.ts
β β βββ lambda-stack.ts
β β βββ monitoring-stack.ts
β βββ bin/app.ts
βββ backend/ # ECS API service
β βββ src/
β β βββ controllers/
β β βββ services/
β β βββ middleware/
β β βββ utils/
β βββ tests/
β βββ Dockerfile
βββ lambda/ # Notification Lambda
β βββ src/
β βββ tests/
β βββ package.json
βββ shared/ # Shared utilities
β βββ types/
β βββ utils/
β βββ constants/
βββ docs/ # Documentation
β βββ architecture.md
β βββ api-spec.md
β βββ deployment.md
βββ scripts/ # Deployment scripts
βββ deploy.sh
βββ test.sh
- Live Demo: Show real-time fraud detection
- Code Walkthrough: Explain key algorithms and patterns
- Architecture Discussion: Trade-offs and design decisions
- Scaling Scenarios: How to handle growth
- Security Deep Dive: Financial compliance and protection
Built with β€οΈ for Senior Software Engineer interviews