Skip to content

πŸ€ golang-kafka microservice for validating financial transactions, built on an event-driven architecture

Notifications You must be signed in to change notification settings

Caixetadev/kafka-transaction-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€ kafka-transaction-validator

⚠️ This repository was created to practice using Kafka and is not code to be used in production.

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:

  • pending
  • approved
  • rejected

Every transaction with a value greater than 1000 should be rejected. image

Adjustments and Improvements

  • balance the load of insert and update in the database

Requirements

  • Go installed and configured
  • Docker and Docker Compose installed
  • k6 (optional)

How to Run

  1. Clone repository:

    git clone https://github.com/Caixetadev/kafka-transaction-validator.git && cd kafka-transaction-validator
  2. Start the services using Docker Compose:

    docker compose up
  3. Run the anti-fraud service:

    cd anti-fraud && go run cmd/main.go
  4. Run the transaction service:

    cd transaction && go run cmd/main.go
  5. Access the application at: http://localhost:8080/transaction.

API Endpoint

Create Transaction

  • URL: /transaction
  • Method: POST
  • Request Body:
    {
      "accountExternalIdDebit": "string",
      "accountExternalIdCredit": "string",
      "tranferTypeId": 1,
      "value": 1
    }
    

Run k6 test

k6 run scripts/k6.js

About

πŸ€ golang-kafka microservice for validating financial transactions, built on an event-driven architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published