# kayiwarahim/relworx-node architecture

> Architecture diagram of the GitHub repository kayiwarahim/relworx-node, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kayiwarahim/relworx-node
- Repository: https://github.com/kayiwarahim/relworx-node

## Overview

Relworx is a TypeScript SDK for Relworx mobile-money payments. Applications configure the SDK, then request collections or disbursements, or query wallet balance and transaction status/history; results are provider JSON. Payment services validate input before the shared HTTP client sends requests, while errors preserve response and uncertain-outcome details. A separate exported verifier checks webhook signatures for application-controlled callbacks. Edges reflect shown calls or README-described usage; no webhook receiver or persistence layer is part of this SDK.

Main entry points: [`src/client.ts`](https://github.com/kayiwarahim/relworx-node/blob/main/src/client.ts) (Relworx HTTP client), [`src/index.ts`](https://github.com/kayiwarahim/relworx-node/blob/main/src/index.ts) (Service facade), [`src/services.ts`](https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts) (Collections), [`src/webhooks.ts`](https://github.com/kayiwarahim/relworx-node/blob/main/src/webhooks.ts) (Signature verifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["SDK entry"]
  node_factory["Client factory<br/>[index.ts]"]
  node_service_api["Service facade<br/>[index.ts]"]
  node_types["SDK contracts<br/>[types.ts]"]
end

subgraph group_payments["Payment operations"]
  node_collection["Collections<br/>[services.ts]"]
  node_disbursement["Disbursements<br/>[services.ts]"]
  node_balance["Wallet balance<br/>[services.ts]"]
  node_transactions["Transactions<br/>[services.ts]"]
  node_validation["Payment validation<br/>[validation.ts]"]
end

subgraph group_transport["HTTP transport"]
  node_http_client["Relworx HTTP client<br/>[client.ts]"]
  node_relworx_api{{"Relworx API"}}
  node_errors["SDK errors<br/>[errors.ts]"]
end

subgraph group_webhook["Webhook security"]
  node_webhook_verifier["Signature verifier<br/>[webhooks.ts]"]
end

node_application(("Integrating application"))
node_webhook_sender(("Webhook sender"))

node_application -->|"creates SDK"| node_factory
node_factory -->|"constructs"| node_service_api
node_application -->|"requests collection"| node_collection
node_application -->|"sends payout"| node_disbursement
node_application -->|"checks balance"| node_balance
node_application -->|"checks history"| node_transactions
node_service_api -->|"exposes"| node_collection
node_service_api -->|"exposes"| node_disbursement
node_service_api -->|"exposes"| node_balance
node_service_api -->|"exposes"| node_transactions
node_collection -->|"validates"| node_validation
node_disbursement -->|"validates"| node_validation
node_collection -->|"posts request"| node_http_client
node_disbursement -->|"posts payment"| node_http_client
node_balance -->|"gets balance"| node_http_client
node_transactions -->|"gets records"| node_http_client
node_http_client -->|"sends HTTP"| node_relworx_api
node_http_client -->|"raises errors"| node_errors
node_application -->|"verifies callback"| node_webhook_verifier
node_webhook_sender -.->|"sends callback"| node_application
node_factory -->|"accepts config"| node_types
node_webhook_verifier -->|"uses payload types"| node_types

click node_factory "https://github.com/kayiwarahim/relworx-node/blob/main/src/index.ts"
click node_service_api "https://github.com/kayiwarahim/relworx-node/blob/main/src/index.ts"
click node_collection "https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts"
click node_disbursement "https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts"
click node_balance "https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts"
click node_transactions "https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts"
click node_validation "https://github.com/kayiwarahim/relworx-node/blob/main/src/validation.ts"
click node_http_client "https://github.com/kayiwarahim/relworx-node/blob/main/src/client.ts"
click node_errors "https://github.com/kayiwarahim/relworx-node/blob/main/src/errors.ts"
click node_webhook_verifier "https://github.com/kayiwarahim/relworx-node/blob/main/src/webhooks.ts"
click node_types "https://github.com/kayiwarahim/relworx-node/blob/main/src/types.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_factory,node_service_api,node_types toneBlue
class node_collection,node_disbursement,node_balance,node_transactions,node_validation toneAmber
class node_http_client,node_relworx_api,node_errors,node_webhook_sender toneMint
class node_webhook_verifier toneRose
class node_application toneIndigo
```

## Components

### SDK entry

- [Client factory](https://github.com/kayiwarahim/relworx-node/blob/main/src/index.ts): `src/index.ts`
- [Service facade](https://github.com/kayiwarahim/relworx-node/blob/main/src/index.ts): `src/index.ts`
- [SDK contracts](https://github.com/kayiwarahim/relworx-node/blob/main/src/types.ts): `src/types.ts`

### Payment operations

- [Collections](https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts): `src/services.ts`
- [Disbursements](https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts): `src/services.ts`
- [Wallet balance](https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts): `src/services.ts`
- [Transactions](https://github.com/kayiwarahim/relworx-node/blob/main/src/services.ts): `src/services.ts`
- [Payment validation](https://github.com/kayiwarahim/relworx-node/blob/main/src/validation.ts): `src/validation.ts`

### HTTP transport

- [Relworx HTTP client](https://github.com/kayiwarahim/relworx-node/blob/main/src/client.ts): `src/client.ts`
- **Relworx API**
- [SDK errors](https://github.com/kayiwarahim/relworx-node/blob/main/src/errors.ts): `src/errors.ts`

### Webhook security

- [Signature verifier](https://github.com/kayiwarahim/relworx-node/blob/main/src/webhooks.ts): `src/webhooks.ts`

### Other components

- **Integrating application**
- **Webhook sender**

## Connections

- Integrating application → Client factory: creates SDK (evidence: `README.md`)
- Client factory → Service facade: constructs (evidence: `src/index.ts`)
- Integrating application → Collections: requests collection (evidence: `README.md`)
- Integrating application → Disbursements: sends payout (evidence: `README.md`)
- Integrating application → Wallet balance: checks balance (evidence: `README.md`)
- Integrating application → Transactions: checks history (evidence: `README.md`)
- Service facade → Collections: exposes (evidence: `src/index.ts`)
- Service facade → Disbursements: exposes (evidence: `src/index.ts`)
- Service facade → Wallet balance: exposes (evidence: `src/index.ts`)
- Service facade → Transactions: exposes (evidence: `src/index.ts`)
- Collections → Payment validation: validates (evidence: `src/services.ts`)
- Disbursements → Payment validation: validates (evidence: `src/services.ts`)
- Collections → Relworx HTTP client: posts request (evidence: `src/services.ts`)
- Disbursements → Relworx HTTP client: posts payment (evidence: `src/services.ts`)
- Wallet balance → Relworx HTTP client: gets balance (evidence: `src/services.ts`)
- Transactions → Relworx HTTP client: gets records (evidence: `src/services.ts`)
- Relworx HTTP client → Relworx API: sends HTTP (evidence: `README.md`)
- Relworx HTTP client → SDK errors: raises errors (evidence: `src/client.ts`)
- Integrating application → Signature verifier: verifies callback (evidence: `README.md`)
- Webhook sender → Integrating application: sends callback (evidence: `README.md`)
- Client factory → SDK contracts: accepts config (evidence: `src/index.ts`)
- Signature verifier → SDK contracts: uses payload types (evidence: `src/webhooks.ts`)
