Skip to content

Conversation

@paulccuno
Copy link

📝 Description

This PR implements a based on microservices solution using NestJS, Kafka, Docker, GraphQL, and Prisma to manage transactions in a secure and scalable way.

📌 Objective

Develop a distributed system to process transactions efficiently and with anti-fraud validations.

🛠 Solution Architecture

Three microservices were implemented:

  1. Client-Gateway (GraphQL API):

    • Acts as the entry point for clients.
    • Exposes GraphQL endpoints to interact with the microservices.
    • Publishes events to Kafka.
  2. ExternalTransaction (Transaction Management):

    • Responsible for receiving transactions from Kafka and storing them in PostgreSQL with Prisma.
    • Exposes its own events for other microservices to consume.
  3. AntiFraud (Transaction Validation):

    • Listens to Kafka events to analyze suspicious transactions.
    • Returns a validation response approving or rejecting the transactions.

🔍 How to Test

1️⃣ Clone the Repository

git clone https://github.com/yaperos/app-nodejs-codechallenge.git
cd app-nodejs-codechallenge

2️⃣ Start Services with Docker

docker-compose up --build

This will start Kafka, PostgreSQL, and the three microservices.

Note: Environment variables are already set.

3️⃣ Access GraphQL Playground

Once the services are running, you can access http://localhost:3000/graphql to test the Client-Gateway endpoints.

4️⃣ Test with GraphQL

Example mutation to initiate a transaction:

mutation CreateTransaction {
  createTransaction(
    createTransactionInput: {
      accountExternalIdCredit: "a0608cb6-27b2-4fd7-a203-f941e95fad6d"
      accountExternalIdDebit: "ab6836c5-63c7-4160-a023-b6078d0d9b23"
      tranferTypeId: 13
      value: 1500
    }
  ) {
    id
    externalDebitAccount {
      id
    }
    externalCreditAccount {
      id
    }
    type {
      id
      name
    }
    status {
      id
      name
    }
    transferType {
      id
      name
    }
    value
    createdAt
    updatedAt
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants