# vusalabdurahmanovx/cryptopayments architecture

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

- Interactive diagram: https://gitdiagram.com/vusalabdurahmanovx/cryptopayments
- Repository: https://github.com/vusalabdurahmanovx/cryptopayments

## Overview

CryptoPayments is a watch-only BSC USDT receiver API. An application submits an idempotent invoice request; the API allocates a unique HD address, the scanner finds and verifies finalized token transfers, and the invoice status and optional signed webhook reflect confirmed totals. The map follows the sampled runtime wiring; unsampled store details and the contract implementation are not inferred beyond README claims.

Main entry points: [`main.go`](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/main.go) (Service Runtime), [`store.go`](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/store.go) (Invoice & Transfer Store), [`http.go`](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/http.go) (HTTP API), [`webhook.go`](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/webhook.go) (Webhook Dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Invoice API"]
  node_http["HTTP API<br/>[http.go]"]
  node_amount["Amount Parsing<br/>[amount.go]"]
  node_config["Runtime Config<br/>[config.go]"]
  node_main["Service Runtime<br/>[main.go]"]
end

subgraph group_wallet["Address Allocation"]
  node_wallet["HD Address Derivation<br/>[wallet.go]"]
end

subgraph group_chain["Chain Scanning"]
  node_rpc["BSC JSON-RPC<br/>[rpc.go]"]
  node_scanner["Transfer Scanner<br/>[scanner.go]"]
end

subgraph group_ledger["Payment Ledger"]
  node_store[("Invoice &amp; Transfer Store<br/>[store.go]")]
end

subgraph group_events["Webhook Delivery"]
  node_dispatcher["Webhook Dispatcher<br/>[webhook.go]"]
end

node_client(("Merchant App"))
node_bsc["BSC RPC Provider"]
node_webhook_target(("Merchant Webhook"))

node_client -->|"submits requests"| node_http
node_main -->|"loads settings"| node_config
node_main -->|"opens database"| node_store
node_main -->|"validates chain"| node_rpc
node_main -->|"starts scanner"| node_scanner
node_main -->|"starts delivery"| node_dispatcher
node_main -->|"serves routes"| node_http
node_http -->|"parses amount"| node_amount
node_http -->|"creates and reads"| node_store
node_http -->|"gets start block"| node_rpc
node_store -->|"derives address"| node_wallet
node_scanner -->|"fetches blocks and logs"| node_rpc
node_scanner -->|"loads and applies scans"| node_store
node_rpc -->|"sends JSON-RPC"| node_bsc
node_dispatcher -->|"reads and updates outbox"| node_store
node_dispatcher -->|"posts signed events"| node_webhook_target
node_store -.->|"persists event outbox"| node_dispatcher

click node_http "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/http.go"
click node_amount "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/amount.go"
click node_config "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/config.go"
click node_main "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/main.go"
click node_wallet "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/wallet.go"
click node_rpc "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/rpc.go"
click node_scanner "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/scanner.go"
click node_store "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/store.go"
click node_dispatcher "https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/webhook.go"

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_http,node_amount,node_config,node_main toneBlue
class node_wallet toneAmber
class node_rpc,node_scanner,node_webhook_target toneMint
class node_store toneRose
class node_dispatcher,node_client,node_bsc toneIndigo
```

## Components

### Invoice API

- [HTTP API](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/http.go): `http.go`
- [Amount Parsing](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/amount.go): `amount.go`
- [Runtime Config](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/config.go): `config.go`
- [Service Runtime](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/main.go): `main.go`

### Address Allocation

- [HD Address Derivation](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/wallet.go): `wallet.go`

### Chain Scanning

- [BSC JSON-RPC](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/rpc.go): `rpc.go`
- [Transfer Scanner](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/scanner.go): `scanner.go`

### Payment Ledger

- [Invoice & Transfer Store](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/store.go): `store.go`

### Webhook Delivery

- [Webhook Dispatcher](https://github.com/vusalabdurahmanovx/cryptopayments/blob/main/webhook.go): `webhook.go`

### Other components

- **Merchant App**
- **BSC RPC Provider**
- **Merchant Webhook**

## Connections

- Merchant App → HTTP API: submits requests (evidence: `README.md`)
- Service Runtime → Runtime Config: loads settings (evidence: `main.go`)
- Service Runtime → Invoice & Transfer Store: opens database (evidence: `main.go`)
- Service Runtime → BSC JSON-RPC: validates chain (evidence: `main.go`)
- Service Runtime → Transfer Scanner: starts scanner (evidence: `main.go`)
- Service Runtime → Webhook Dispatcher: starts delivery (evidence: `main.go`)
- Service Runtime → HTTP API: serves routes (evidence: `main.go`)
- HTTP API → Amount Parsing: parses amount (evidence: `http.go`)
- HTTP API → Invoice & Transfer Store: creates and reads (evidence: `http.go`)
- HTTP API → BSC JSON-RPC: gets start block (evidence: `http.go`)
- Invoice & Transfer Store → HD Address Derivation: derives address (evidence: `store.go`)
- Transfer Scanner → BSC JSON-RPC: fetches blocks and logs (evidence: `scanner.go`)
- Transfer Scanner → Invoice & Transfer Store: loads and applies scans (evidence: `scanner.go`)
- BSC JSON-RPC → BSC RPC Provider: sends JSON-RPC (evidence: `rpc.go`)
- Webhook Dispatcher → Invoice & Transfer Store: reads and updates outbox (evidence: `webhook.go`)
- Webhook Dispatcher → Merchant Webhook: posts signed events (evidence: `webhook.go`)
- Invoice & Transfer Store → Webhook Dispatcher: persists event outbox
