Yape challenge implementation in Java by Marcelo Sucre Chavez #573
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Yape Code Challenge 🚀
Problem
Every time a financial transaction is created it must be validated by our anti-fraud microservice and then the same service sends a message back to update the transaction status.
For now, we have only three transaction statuses:
Every transaction with a value greater than 1000 should be rejected.
flowchart LR Transaction -- Save Transaction with pending Status --> transactionDatabase[(Database)] Transaction --Send transaction Created event--> Anti-Fraud Anti-Fraud -- Send transaction Status Approved event--> Transaction Anti-Fraud -- Send transaction Status Rejected event--> Transaction Transaction -- Update transaction Status event--> transactionDatabase[(Database)]Solution
Tech stack
Main dependencies
Microservices
TransactionManager
Endpoints
[POST] /transaction
[GET] /transaction/{transactionId}
[GET] /transaction/account/{transactionId}
Flow
Create a Transaction
[POST] /transactionPENDINGstatus, is persisted into thetransactiontable in the PostgreSQL databasetransaction_by_accounttable in the Cassandra databasesourceAccountIdas the partition key and the fieldscreatedAtandidfor the clustering columnstransaction eventis sent to Kafka topiceventtransaction eventhave the following fields:Consume response events
event-responsetransaction event responsehave the following fields:transaction event responseis consumed,thetransactionwill be updated according to theisValidvalue:APPROVEDiftrueREJECTEDiffalsetransactiontable in PostgreSQL databasetransaction_by_accounttable in the Cassandra databaseGet transaction details
[POST] /transaction/{transactionId}Get transaction details by account
[POST] /transaction/account/{accountId}accountIdvalue from the Cassandra database.transaction_by_accountwas build specifically for this query.AntiFraud
Flow
Consume events
eventamountfield will be validated to set the response fieldisValid.trueotherwise it will befalsetransaction event responseis sent to Kafka topicevent-responsetransaction event responsehave the following fields:Build and run
Requirements
Build Steps
yape-challengedirectory/yape-challenge/Dockerfile.transactionfile update the following values:docker compose up -dUsage
localhost:8082hostFuture improvements