asyncapi: 3.0.0
info:
  title: Remittance Service Event Bus Example
  version: 1.0.0
  description: |
    Example AsyncAPI 2.6.0 model for a Remittance Service.
    A user makes a cross-border transaction request.
    Events are published to AWS SNS, which pushes them to an SQS queue.
    Downstream services consume the event from SQS.
servers:
  aws:
    host: '{service}.{region}.amazonaws.com'
    protocol: https
    description: AWS endpoints for SNS and SQS.
    variables:
      service:
        enum:
          - sns
          - sqs
        default: sns
      region:
        default: us-east-1
        description: AWS region used for the SNS/SQS resources.
channels:
  remittance-transactions-topic:
    address: sns/remittance-transactions-topic
    messages:
      publishRemittanceTransactionToSNS:
        $ref: '#/components/messages/RemittanceTransactionRequested'
    description: SNS topic for remittance transaction events.
  remittance-transactions-queue:
    address: sqs/remittance-transactions-queue
    messages:
      consumeRemittanceTransactionFromSQS:
        $ref: '#/components/messages/RemittanceTransactionRequested'
    description: SQS queue that receives messages forwarded from SNS topic via
      subscription.
operations:
  publishRemittanceTransactionToSNS:
    action: receive
    channel:
      $ref: '#/channels/remittance-transactions-topic'
    summary: Publish RemittanceTransactionRequested event to SNS topic
    messages:
      - $ref: '#/channels/remittance-transactions-topic/messages/publishRemittanceTransactionToSNS'
  consumeRemittanceTransactionFromSQS:
    action: send
    channel:
      $ref: '#/channels/remittance-transactions-queue'
    summary: >-
      Consumer service polls SQS to consume RemittanceTransactionRequested
      events.
    messages:
      - $ref: '#/channels/remittance-transactions-queue/messages/consumeRemittanceTransactionFromSQS'
components:
  messages:
    RemittanceTransactionRequested:
      name: RemittanceTransactionRequested
      title: Remittance Transaction Requested
      summary: Event emitted when a user requests to send money cross-border.
      contentType: application/json
      payload:
        type: object
        required:
          - transactionId
          - transactionType
          - createdAt
          - sender
          - receiver
          - amount
          - currency
          - paymentMethod
        properties:
          transactionId:
            type: string
            format: uuid
            description: Unique transaction identifier.
          transactionType:
            type: string
            description: Type of transaction.
          createdAt:
            type: string
            format: date-time
            description: ISO8601 timestamp for when the request was made.
          sender:
            type: object
            required:
              - name
              - email
              - country
            properties:
              name:
                type: string
              email:
                type: string
                format: email
              country:
                type: string
                description: ISO 3166-1 alpha-2 country code
          receiver:
            type: object
            required:
              - name
              - email
              - country
            properties:
              name:
                type: string
              email:
                type: string
                format: email
              country:
                type: string
                description: ISO 3166-1 alpha-2 country code
          amount:
            type: number
            format: double
            description: Amount requested to transfer.
          currency:
            type: string
            description: ISO 4217 currency code.
          paymentMethod:
            type: string
            description: Payment method used to fund the transaction.
            enum:
              - card
              - wire_transfer
              - bank_account
      examples:
        - name: remittance.transaction.requested.example
          summary: Example remittance transaction request
          payload:
            transactionId: 33333333-3333-3333-3333-333333333333
            transactionType: remittance.requested
            createdAt: '2025-09-16T10:15:00Z'
            sender:
              name: Jonas Petrauskas
              email: jonas.petrauskas@example.lt
              country: LT
            receiver:
              name: Olena Shevchenko
              email: olena.shevchenko@example.ua
              country: UA
            amount: 750
            currency: EUR
            paymentMethod: wire_transfer
