# ybunhong/bakong-intergrate architecture

> Architecture diagram of the GitHub repository ybunhong/bakong-intergrate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ybunhong/bakong-intergrate
- Repository: https://github.com/ybunhong/bakong-intergrate

## Overview

This is a Fastify payment backend offering Bakong KHQR and ABA PayWay payment flows, transaction reporting, and Telegram payment alerts. The main flow is a client request to create a payment, a later payment check or provider callback, transaction recording, and notification. The source shows these route-to-module calls and integrations; no README is provided, and the in-memory transaction and pending-payment state is not durable storage.

Main entry points: [`src/telegram-webhook.ts`](https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-webhook.ts) (Payment routes), [`src/server.ts`](https://github.com/ybunhong/bakong-intergrate/blob/main/src/server.ts) (Fastify server), [`src/khqr.ts`](https://github.com/ybunhong/bakong-intergrate/blob/main/src/khqr.ts) (KHQR payments), [`src/aba.ts`](https://github.com/ybunhong/bakong-intergrate/blob/main/src/aba.ts) (ABA payments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Fastify server<br/>[server.ts]"]
  node_routes["Payment routes"]
  node_pending["Pending payments"]
  node_transactions["Transactions"]
end

subgraph group_payments["Payment Providers"]
  node_khqr["KHQR payments<br/>[khqr.ts]"]
  node_bakong["Bakong API"]
  node_aba["ABA payments<br/>[aba.ts]"]
  node_payway["ABA PayWay"]
end

subgraph group_alerts["Notifications"]
  node_alerts["Payment alerts<br/>[telegram-bot.ts]"]
  node_telegram["Telegram"]
end

node_client(("API client"))

node_client -.->|"sends requests"| node_server
node_server -->|"registers routes"| node_routes
node_routes -->|"generates and checks"| node_khqr
node_routes -->|"records and checks"| node_pending
node_routes -->|"records and reads"| node_transactions
node_routes -->|"creates payment"| node_aba
node_khqr -->|"checks payment"| node_bakong
node_aba -->|"requests payment"| node_payway
node_routes -->|"sends alerts"| node_alerts
node_alerts -->|"sends message"| node_telegram

click node_server "https://github.com/ybunhong/bakong-intergrate/blob/main/src/server.ts"
click node_routes "https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-webhook.ts"
click node_pending "https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-webhook.ts"
click node_transactions "https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-webhook.ts"
click node_khqr "https://github.com/ybunhong/bakong-intergrate/blob/main/src/khqr.ts"
click node_aba "https://github.com/ybunhong/bakong-intergrate/blob/main/src/aba.ts"
click node_alerts "https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-bot.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_server,node_routes,node_pending,node_transactions,node_client toneBlue
class node_khqr,node_bakong,node_aba,node_payway toneAmber
class node_alerts,node_telegram toneMint
```

## Components

### HTTP API

- [Fastify server](https://github.com/ybunhong/bakong-intergrate/blob/main/src/server.ts): `src/server.ts`
- [Payment routes](https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-webhook.ts): `src/telegram-webhook.ts`
- [Pending payments](https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-webhook.ts): `src/telegram-webhook.ts`
- [Transactions](https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-webhook.ts): `src/telegram-webhook.ts`

### Payment Providers

- [KHQR payments](https://github.com/ybunhong/bakong-intergrate/blob/main/src/khqr.ts): `src/khqr.ts`
- **Bakong API**
- [ABA payments](https://github.com/ybunhong/bakong-intergrate/blob/main/src/aba.ts): `src/aba.ts`
- **ABA PayWay**

### Notifications

- [Payment alerts](https://github.com/ybunhong/bakong-intergrate/blob/main/src/telegram-bot.ts): `src/telegram-bot.ts`
- **Telegram**

### Other components

- **API client**

## Connections

- API client → Fastify server: sends requests
- Fastify server → Payment routes: registers routes (evidence: `src/server.ts`)
- Payment routes → KHQR payments: generates and checks (evidence: `src/telegram-webhook.ts`)
- Payment routes → Pending payments: records and checks (evidence: `src/telegram-webhook.ts`)
- Payment routes → Transactions: records and reads (evidence: `src/telegram-webhook.ts`)
- Payment routes → ABA payments: creates payment (evidence: `src/telegram-webhook.ts`)
- KHQR payments → Bakong API: checks payment (evidence: `src/khqr.ts`)
- ABA payments → ABA PayWay: requests payment (evidence: `src/aba.ts`)
- Payment routes → Payment alerts: sends alerts (evidence: `src/telegram-webhook.ts`)
- Payment alerts → Telegram: sends message (evidence: `src/telegram-bot.ts`)
