Skip to content

Commit 82817ab

Browse files
authored
Create code challenge and docker-compose file (#1)
1 parent 7abf60b commit 82817ab

2 files changed

Lines changed: 103 additions & 2 deletions

File tree

README.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,78 @@
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.

docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: "3.7"
2+
services:
3+
postgres:
4+
image: postgres:14
5+
ports:
6+
- "5432:5432"
7+
environment:
8+
- POSTGRES_USER=postgres
9+
- POSTGRES_PASSWORD=postgres
10+
zookeeper:
11+
image: confluentinc/cp-zookeeper:5.5.3
12+
environment:
13+
ZOOKEEPER_CLIENT_PORT: 2181
14+
kafka:
15+
image: confluentinc/cp-enterprise-kafka:5.5.3
16+
depends_on: [zookeeper]
17+
environment:
18+
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
19+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
20+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
21+
KAFKA_BROKER_ID: 1
22+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
23+
KAFKA_JMX_PORT: 9991
24+
ports:
25+
- 9092:9092

0 commit comments

Comments
 (0)