|
1 | | -# Yape Code Challenge :rocket: |
| 1 | +## 🚀 Instrucciones para levantar el entorno |
2 | 2 |
|
3 | | -Our code challenge will let you marvel us with your Jedi coding skills :smile:. |
| 3 | +### 1. Crear archivo .env en la raiz |
4 | 4 |
|
5 | | -Don't forget that the proper way to submit your work is to fork the repo and create a PR :wink: ... have fun !! |
| 5 | +POSTGRES_HOST=localhost |
| 6 | +POSTGRES_PORT=5432 |
| 7 | +POSTGRES_USER=postgres |
| 8 | +POSTGRES_PASSWORD=postgres |
| 9 | +POSTGRES_DB=postgres |
6 | 10 |
|
7 | | -- [Problem](#problem) |
8 | | -- [Tech Stack](#tech_stack) |
9 | | -- [Send us your challenge](#send_us_your_challenge) |
| 11 | +### 2. Instalar las dependencias |
10 | 12 |
|
11 | | -# Problem |
| 13 | +npm install |
12 | 14 |
|
13 | | -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. |
14 | | -For now, we have only three transaction statuses: |
| 15 | +# o |
15 | 16 |
|
16 | | -<ol> |
17 | | - <li>pending</li> |
18 | | - <li>approved</li> |
19 | | - <li>rejected</li> |
20 | | -</ol> |
| 17 | +yarn install |
21 | 18 |
|
22 | | -Every transaction with a value greater than 1000 should be rejected. |
| 19 | +### 3. Levantar los servicios de base de datos, zookeeper y kafka |
23 | 20 |
|
24 | | -```mermaid |
25 | | - flowchart LR |
26 | | - Transaction -- Save Transaction with pending Status --> transactionDatabase[(Database)] |
27 | | - Transaction --Send transaction Created event--> Anti-Fraud |
28 | | - Anti-Fraud -- Send transaction Status Approved event--> Transaction |
29 | | - Anti-Fraud -- Send transaction Status Rejected event--> Transaction |
30 | | - Transaction -- Update transaction Status event--> transactionDatabase[(Database)] |
31 | | -``` |
| 21 | +docker-compose up -d |
32 | 22 |
|
33 | | -# Tech Stack |
| 23 | +### 4. Correr la aplicacion |
34 | 24 |
|
35 | | -<ol> |
36 | | - <li>Node. You can use any framework you want (i.e. Nestjs with an ORM like TypeOrm or Prisma) </li> |
37 | | - <li>Any database</li> |
38 | | - <li>Kafka</li> |
39 | | -</ol> |
| 25 | +npm run local |
40 | 26 |
|
41 | | -We do provide a `Dockerfile` to help you get started with a dev environment. |
| 27 | +# o |
42 | 28 |
|
43 | | -You must have two resources: |
| 29 | +yarn local |
44 | 30 |
|
45 | | -1. Resource to create a transaction that must containt: |
| 31 | +### 5. Probar los servicios usando los siguientes curl |
46 | 32 |
|
47 | | -```json |
48 | | -{ |
49 | | - "accountExternalIdDebit": "Guid", |
50 | | - "accountExternalIdCredit": "Guid", |
| 33 | +curl --location 'localhost:3000/transaction' \ |
| 34 | +--header 'Content-Type: application/json' \ |
| 35 | +--data '{ |
| 36 | + "accountExternalIdDebit": "5429d629-c239-45fa-8235-1a386258c536", |
| 37 | + "accountExternalIdCredit": "d6cd54da-8ce3-4f79-abda-bd5be9b19e68", |
51 | 38 | "tranferTypeId": 1, |
52 | 39 | "value": 120 |
53 | | -} |
54 | | -``` |
| 40 | +}' |
55 | 41 |
|
56 | | -2. Resource to retrieve a transaction |
57 | | - |
58 | | -```json |
59 | | -{ |
60 | | - "transactionExternalId": "Guid", |
61 | | - "transactionType": { |
62 | | - "name": "" |
63 | | - }, |
64 | | - "transactionStatus": { |
65 | | - "name": "" |
66 | | - }, |
67 | | - "value": 120, |
68 | | - "createdAt": "Date" |
69 | | -} |
70 | | -``` |
71 | | - |
72 | | -## Optional |
73 | | - |
74 | | -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? |
75 | | - |
76 | | -You can use Graphql; |
77 | | - |
78 | | -# Send us your challenge |
79 | | - |
80 | | -When you finish your challenge, after forking a repository, you **must** 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. |
81 | | - |
82 | | -If you have any questions, please let us know. |
| 42 | +curl --location 'localhost:3000/transaction/5429d629-c239-45fa-8235-1a386258c536' |
0 commit comments