Starting: 100000 Users/day
50000 transactions per day
10GB of transactions daily
1 server can do 1000 conections
1 server can hold 1000GB of data
Having those numbers we can estimate the resources we need:
1) RPS = 50000 RPD / 24 * 60 * 60 = 0.57 RPS
2) Connections per second = 10000 / 24 * 60 * 60 = 1.15
3) Data to store per year = 10GB * 365 = 3650GB
4) Servers to serve connections = 10000 users/day / 1000 = 10 servers
5) Servers to hold data = 3650 / 1000 = 4 servers (round up)
GET /v1/account
POST /v1/account
PATCH /v1/account
POST /v1/transfer
GET /v1/payLink
GET /v1/history
GET /v1/audit/logs
User <|-- UserWallet
User : +int UserId INDEX
User : +String UserName
User : +String HashedPassword
User : +String Email INDEX
User : +DateTime CreatedAt
UserWallet <|-- User
UserWallet : +int WalletId INDEX
UserWallet : +int UserId INDEX
UserWallet : +int Balance
UserWallet : +int CurrencyCode
Transaction <|-- User
Transaction <|-- PaymentType
Transaction <|-- TransactionType
Transaction : +int TransactionId INDEX
Transaction : +int UserIdFrom INDEX
Transaction : +int UserIdTo INDEX
Transaction : +int TransactionType
Transaction : +int PaymentType
Transaction : +int Amount
Transaction : +int CurrencyCode
Transaction : +DateTime Date
Transaction : +String Message
CurrencyConversionRate <|-- Currency
CurrencyConversionRate : +int ID
CurrencyConversionRate : +int FromId
CurrencyConversionRate : +int ToId
CurrencyConversionRate : +float Multiplier
CurrencyConversionRate : +DateTime timestamp INDEX
FraudLog <|-- Transaction
FraudLog : +int ID INDEX
FraudLog : +int TransactionId INDEX
FraudLog : +DateTime TimeStamp INDEX
Paymentbackend : +int ID
Paymentbackend : +String Name
PaymentbackendDetails <|-- Paymentbackend
PaymentbackendDetails : +int ID
PaymentbackendDetails : +int PaymentBackendId
PaymentbackendDetails : +int SupportedPaymentType
PaymentType : +int ID
PaymentType : +String Name
Currency : +int ID
Currency : +String Name
TransactionType : +int ID
TransactionType : +String Name
1) Api gateway/load balancer
2) User service
3) Payment service
4) Log infra and audti services
5) Payment backend
6) Transaction processor
1) User issues an HTTP request to transfer funds
2) Request goes through api gateway/load balancer
3) Request goes into payment service
4) Payment service calls payemnt backedn and stores transaction in db
5) Payment service issues notification to a client
1) Payment service: accepts payment requests from client and coordinates payment processros to execute payment backends. Performs risk checks for transations using FraudService and records transactions in durable manner into Transaction DB. ALso notifies client about success using Notification Service
2) User service. Manages user accounts. Stores relevant user info in database and provides API to manage an account
3) Log service. Samples health logs from all system components (except self) and stores them in a log database. Also allows to perform a fulltext search on the logs and sends notification when a new log is encountered
4) Audit infra. Monitors the health of underlying services and sends notifications using Notification Service if health parameters drop with limit
5) Transaction read replica. Responsible for serving transaction writes to the user. Used to optimize read-heavy path of retrieving transaction info.
GET /v1/accountGET /v1/historyGET /v1/payLinkGET /v1/currency/rates.POST /v1/account and PATCH /v1/accountPOST /v1/transferLog InfrastructureTransactionFraudLogHandling failed transactions in a payment system is crucial for ensuring reliability and fault tolerance. Here's how we can tackle these challenges based on the provided information:
Tracking Payment State:
1) Transaction log is a read heavy system that prioritize availability thus we choose some no-sql solution for easy scaling like cassandra or amazon dynamo db
2) Logging system is write heavy with strong avaialbilty a thus we prioritize sharding our log database based on service (user service, payment service, etc) For reading when the amount of logs is too big we use pagination to retrieve only latest logs. For DB with use some NoSQL solution optimized for high writes
3) User management system is not read or write heavy and case use classic SQL solution and be sharded by user ID when the amount of users get too big
4) To insure durability of our transaction log we maintain a write ahead log that records all action applications before flushing them to db.
5) To scala the payment processros we use queu technology like apache kafka.
Retry Queue and Dead Letter Queue:
Retry Strategies:
Example of Retry:
Use ML for fraud detection