Skip to content

🐬 Two microservices using bun and elysia to validate financial transactions, built on an event-driven architecture

Notifications You must be signed in to change notification settings

vsantos1711/elysia-transaction-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐬 Building event-driven systems with Kafka and ElysiaJS

⚠️ This repository was created with the idea to practice using Kafka. Frame

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.

Frame

Technologies Used

  • Bun: A fast JavaScript runtime that is used for running the anti-fraud and transaction services.
  • Elysia: A framework used for building the application's web services.
  • Apache Kafka: The event streaming platform used to handle messaging between services.
  • Drizzle: An ORM (Object-Relational Mapping) tool used for interacting with the database.
  • PostgreSQL: The relational database used for storing transaction data.

How to run

Pre-requisites
To be able to start development the application make sure that you have the following pre-requisites installed:
  • Bun
    curl -fsSL https://bun.sh/install | bash
  • Docker and Docker Compose installed
  • K6 (optional)

Running the app
To be able to start development the application make sure that you have the following pre-requisites installed:
  1. Clone repository:
    git clone https://github.com/vsantos1711/elysia-transaction-validate.git && cd elysia-transaction-validate
  2. Start the Kafka using Docker Compose:
    docker compose up
  3. Run the anti-fraud service:
    cd anti-fraud && bun install && bun run dev
  4. Run the transaction service:
    cd transaction && bun install && bun run dev

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

🐬 Two microservices using bun and elysia to validate financial transactions, built on an event-driven architecture

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published