# panhavathgit/bakong_telegram_payment architecture

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

- Interactive diagram: https://gitdiagram.com/panhavathgit/bakong_telegram_payment
- Repository: https://github.com/panhavathgit/bakong_telegram_payment

## Overview

This is a Flask microservice for creating Bakong QR payment strings and reporting payment outcomes to Telegram. The main workflow is a client request to generate a QR, followed by a background polling worker that checks payment status and sends transaction details—or a timeout notification—to Telegram. The API also exposes a payment-status check. The Bakong wrapper includes deeplink, payment-info, and bulk-check operations. Polling and notification behavior are visible in the API excerpt; no unsampled implementation is assumed.

Main entry points: [`services/bakong_service.py`](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/services/bakong_service.py) (Bakong Operations), [`api/endpoints.py`](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/api/endpoints.py) (Flask Endpoints), [`services/telegram_bot_service.py`](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/services/telegram_bot_service.py) (Telegram Sender), [`utils/env.py`](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/utils/env.py) (Bakong Credentials)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api["Flask Endpoints<br/>[endpoints.py]"]
  node_poller["Payment Poller<br/>[endpoints.py]"]
end

subgraph group_payments["Bakong Payments"]
  node_bakong["Bakong Operations<br/>[bakong_service.py]"]
end

subgraph group_notifications["Telegram Notifications"]
  node_telegram["Telegram Sender"]
end

subgraph group_configuration["Configuration"]
  node_bakong_service_config["Bakong Credentials<br/>[env.py]"]
  node_telegram_config["Telegram Credentials<br/>[env.py]"]
end

node_client(("Backend Client"))
node_bakong_network{{"Bakong Service"}}
node_telegram_api{{"Telegram Bot API"}}

node_client -->|"requests QR"| node_api
node_api -->|"creates QR"| node_bakong
node_api -->|"hashes QR"| node_bakong
node_api -->|"starts worker"| node_poller
node_api -->|"checks status"| node_bakong
node_poller -->|"checks payment"| node_bakong
node_poller -->|"gets details"| node_bakong
node_poller -->|"sends outcome"| node_telegram
node_bakong -->|"reads settings"| node_bakong_service_config
node_telegram -->|"reads credentials"| node_telegram_config
node_bakong -.->|"uses SDK"| node_bakong_network
node_telegram -->|"posts message"| node_telegram_api

click node_api "https://github.com/panhavathgit/bakong_telegram_payment/blob/main/api/endpoints.py"
click node_poller "https://github.com/panhavathgit/bakong_telegram_payment/blob/main/api/endpoints.py"
click node_bakong "https://github.com/panhavathgit/bakong_telegram_payment/blob/main/services/bakong_service.py"
click node_bakong_service_config "https://github.com/panhavathgit/bakong_telegram_payment/blob/main/utils/env.py"
click node_telegram "https://github.com/panhavathgit/bakong_telegram_payment/blob/main/services/telegram_bot_service.py"
click node_telegram_config "https://github.com/panhavathgit/bakong_telegram_payment/blob/main/utils/env.py"

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_api,node_poller,node_client toneBlue
class node_bakong toneAmber
class node_telegram,node_telegram_api toneMint
class node_bakong_service_config,node_telegram_config toneRose
class node_bakong_network toneIndigo
```

## Components

### HTTP API

- [Flask Endpoints](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/api/endpoints.py): `api/endpoints.py`
- [Payment Poller](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/api/endpoints.py): `api/endpoints.py`

### Bakong Payments

- [Bakong Operations](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/services/bakong_service.py): `services/bakong_service.py`

### Telegram Notifications

- [Telegram Sender](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/services/telegram_bot_service.py): `services/telegram_bot_service.py`

### Configuration

- [Bakong Credentials](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/utils/env.py): `utils/env.py`
- [Telegram Credentials](https://github.com/panhavathgit/bakong_telegram_payment/blob/main/utils/env.py): `utils/env.py`

### Other components

- **Backend Client**
- **Bakong Service**
- **Telegram Bot API**

## Connections

- Backend Client → Flask Endpoints: requests QR (evidence: `README.md`)
- Flask Endpoints → Bakong Operations: creates QR (evidence: `api/endpoints.py`)
- Flask Endpoints → Bakong Operations: hashes QR (evidence: `api/endpoints.py`)
- Flask Endpoints → Payment Poller: starts worker (evidence: `api/endpoints.py`)
- Flask Endpoints → Bakong Operations: checks status (evidence: `api/endpoints.py`)
- Payment Poller → Bakong Operations: checks payment (evidence: `api/endpoints.py`)
- Payment Poller → Bakong Operations: gets details (evidence: `api/endpoints.py`)
- Payment Poller → Telegram Sender: sends outcome (evidence: `api/endpoints.py`)
- Bakong Operations → Bakong Credentials: reads settings (evidence: `services/bakong_service.py`)
- Telegram Sender → Telegram Credentials: reads credentials (evidence: `services/telegram_bot_service.py`)
- Bakong Operations → Bakong Service: uses SDK
- Telegram Sender → Telegram Bot API: posts message (evidence: `services/telegram_bot_service.py`)
