|
1 | | -# app-nodejs-codechallenge |
2 | | -Code challenge for potential Yaperos :rocket: |
| 1 | +# Yape Code Challenge :rocket: |
| 2 | + |
| 3 | +- [Problem](#problem) |
| 4 | +- [Tech Stack](#tech_stack) |
| 5 | +- [Send us your challenge](#send_us_your_challenge) |
| 6 | + |
| 7 | +# Problem |
| 8 | + |
| 9 | +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. |
| 10 | +For now, we have only three transaction statuses: |
| 11 | + |
| 12 | +<ol> |
| 13 | + <li>pending</li> |
| 14 | + <li>approved</li> |
| 15 | + <li>rejected</li> |
| 16 | +</ol> |
| 17 | + |
| 18 | +Every transaction with a value greater than 1000 should be rejected. |
| 19 | + |
| 20 | +```mermaid |
| 21 | + flowchart LR |
| 22 | + Transaction -- Save Transaction with pending Status --> transactionDatabase[(Database)] |
| 23 | + Transaction --Send transaction Created event--> Anti-Fraud |
| 24 | + Anti-Fraud -- Send transaction Status Approved event--> Transaction |
| 25 | + Anti-Fraud -- Send transaction Status Rejected event--> Transaction |
| 26 | + Transaction -- Update transaction Status event--> transactionDatabase[(Database)] |
| 27 | +``` |
| 28 | + |
| 29 | +# Tech Stack |
| 30 | + |
| 31 | +<ol> |
| 32 | + <li>Node. You can use any framework you want (i.e. Nestjs with an ORM like TypeOrm or Prisma) </li> |
| 33 | + <li>Any database</li> |
| 34 | + <li>Kafka</li> |
| 35 | +</ol> |
| 36 | + |
| 37 | +We do provide a `Dockerfile` to help you get started with a dev environment. |
| 38 | + |
| 39 | +You must have two resources: |
| 40 | + |
| 41 | +1. Resource to create a transaction that must containt: |
| 42 | + |
| 43 | +```json |
| 44 | +{ |
| 45 | + "accountExternalIdDebit": "Guid", |
| 46 | + "accountExternalIdCredit": "Guid", |
| 47 | + "tranferTypeId": 1, |
| 48 | + "value": 120 |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +2. Resource to retrieve a transaction |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "transactionExternalId": "Guid", |
| 57 | + "transactionType": { |
| 58 | + "name": "" |
| 59 | + }, |
| 60 | + "transactionStatus": { |
| 61 | + "name": "" |
| 62 | + }, |
| 63 | + "value": 120, |
| 64 | + "createdAt": "Date" |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +## Optional |
| 69 | + |
| 70 | +You can use any approach to store transaction data but you should consider that we may deal with high volume scenarios where we have a huge amount of writes and reads for the same data at the same time. How would you tackle this requirement? |
| 71 | + |
| 72 | +You can use Graphql; |
| 73 | + |
| 74 | +# Send us your challenge |
| 75 | + |
| 76 | +When you finish your challenge, after forking a repository, you can open a pull request to our repository. There are no limitations to the implementation, you can follow the programming paradigm, modularization, and style that you feel is the most appropriate solution. |
| 77 | + |
| 78 | +If you have any questions, please let us know. |
0 commit comments