# gmwalletapp/epusdt architecture

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

- Interactive diagram: https://gitdiagram.com/gmwalletapp/epusdt
- Repository: https://github.com/gmwalletapp/epusdt

## Overview

Epusdt is a self-hosted, multi-chain crypto payment gateway. A merchant submits a signed order through the HTTP API; the gateway reserves a wallet-and-amount combination and returns checkout details. Cashier actions can select a network or submit a transaction hash, while chain listeners detect transfers and match them to orders. Successful payments trigger notifications and asynchronous merchant callbacks. The graph also includes admin operations and chain configuration. Listener-to-processing links reflect the documented matching workflow; unsampled implementation details are not inferred.

Main entry points: [`src/model/data`](https://github.com/gmwalletapp/epusdt/tree/master/src/model/data) (Data access), [`src/route/router.go`](https://github.com/gmwalletapp/epusdt/blob/master/src/route/router.go) (HTTP routes), [`src/controller/comm/pay_controller.go`](https://github.com/gmwalletapp/epusdt/blob/master/src/controller/comm/pay_controller.go) (Cashier endpoints), [`src/task/listen_chain_common.go`](https://github.com/gmwalletapp/epusdt/blob/master/src/task/listen_chain_common.go) (Network scanners)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_router["HTTP routes<br/>[router.go]"]
  node_commorders["Order endpoints"]
  node_commpay["Cashier endpoints<br/>[pay_controller.go]"]
  node_assets["Supported assets"]
end

subgraph group_payments["Payment lifecycle"]
  node_ordersvc["Order service<br/>[order_service.go]"]
  node_paysvc["Payment service<br/>[pay_service.go]"]
  node_manualverify["Manual verification"]
end

subgraph group_chains["Chain monitoring"]
  node_listener["Chain listeners<br/>[listen.go]"]
  node_chainworkers["Network scanners"]
  node_tasksvc["Transfer matching<br/>[task_service.go]"]
end

subgraph group_operations["Administration"]
  node_admin["Admin controllers"]
  node_telegram["Telegram bot<br/>[telegram.go]"]
end

subgraph group_persistence["Persistence and delivery"]
  node_notify["Notifications<br/>[dispatcher.go]"]
  node_queue["Callback worker<br/>[worker.go]"]
  node_data["Data access"]
  node_models["Database models"]
  node_db[("Configured database")]
end

node_merchant(("Merchant app"))
node_customer(("Payer"))
node_merchantcallback(("Merchant callback URL"))
node_chainrpc(("Chain RPC/API"))

node_merchant -->|"submits API request"| node_router
node_customer -->|"uses cashier"| node_router
node_router -->|"dispatches order routes"| node_commorders
node_router -->|"dispatches payment routes"| node_commpay
node_router -->|"dispatches config route"| node_assets
node_commorders -->|"creates transaction"| node_ordersvc
node_commpay -->|"loads checkout"| node_paysvc
node_commpay -->|"submits transaction hash"| node_manualverify
node_ordersvc -->|"reads and writes orders"| node_data
node_paysvc -->|"reads and updates orders"| node_data
node_manualverify -->|"checks payment records"| node_data
node_assets -->|"reads enabled assets"| node_data
node_listener -->|"starts scanners"| node_chainworkers
node_chainworkers -->|"reads chain transfers"| node_chainrpc
node_chainworkers -->|"processes transfer events"| node_tasksvc
node_tasksvc -->|"matches and updates orders"| node_data
node_tasksvc -->|"dispatches payment notice"| node_notify
node_notify -->|"sends Telegram notice"| node_telegram
node_admin -->|"manages gateway records"| node_data
node_data -->|"uses persistence models"| node_models
node_models -->|"queries configured store"| node_db
node_queue -->|"loads and updates callbacks"| node_data
node_queue -->|"delivers payment callback"| node_merchantcallback
node_admin -->|"reopens callback delivery"| node_queue

click node_router "https://github.com/gmwalletapp/epusdt/blob/master/src/route/router.go"
click node_commorders "https://github.com/gmwalletapp/epusdt/blob/master/src/controller/comm/order_controller.go"
click node_commpay "https://github.com/gmwalletapp/epusdt/blob/master/src/controller/comm/pay_controller.go"
click node_assets "https://github.com/gmwalletapp/epusdt/blob/master/src/controller/comm/supported_asset_controller.go"
click node_ordersvc "https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/order_service.go"
click node_paysvc "https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/pay_service.go"
click node_manualverify "https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/manual_payment_verify.go"
click node_listener "https://github.com/gmwalletapp/epusdt/blob/master/src/task/listen.go"
click node_chainworkers "https://github.com/gmwalletapp/epusdt/blob/master/src/task/listen_chain_common.go"
click node_tasksvc "https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/task_service.go"
click node_admin "https://github.com/gmwalletapp/epusdt/tree/master/src/controller/admin"
click node_telegram "https://github.com/gmwalletapp/epusdt/blob/master/src/telegram/telegram.go"
click node_notify "https://github.com/gmwalletapp/epusdt/blob/master/src/notify/dispatcher.go"
click node_queue "https://github.com/gmwalletapp/epusdt/blob/master/src/mq/worker.go"
click node_data "https://github.com/gmwalletapp/epusdt/tree/master/src/model/data"
click node_models "https://github.com/gmwalletapp/epusdt/tree/master/src/model/mdb"
click node_db "https://github.com/gmwalletapp/epusdt/tree/master/src/model/dao"

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_router,node_commorders,node_commpay,node_assets toneBlue
class node_ordersvc,node_paysvc,node_manualverify toneAmber
class node_listener,node_chainworkers,node_tasksvc,node_chainrpc toneMint
class node_admin,node_telegram toneRose
class node_notify,node_queue,node_data,node_models,node_db,node_merchant,node_customer,node_merchantcallback toneIndigo
```

## Components

### HTTP API

- [HTTP routes](https://github.com/gmwalletapp/epusdt/blob/master/src/route/router.go): `src/route/router.go`
- [Order endpoints](https://github.com/gmwalletapp/epusdt/blob/master/src/controller/comm/order_controller.go): `src/controller/comm/order_controller.go`
- [Cashier endpoints](https://github.com/gmwalletapp/epusdt/blob/master/src/controller/comm/pay_controller.go): `src/controller/comm/pay_controller.go`
- [Supported assets](https://github.com/gmwalletapp/epusdt/blob/master/src/controller/comm/supported_asset_controller.go): `src/controller/comm/supported_asset_controller.go`

### Payment lifecycle

- [Order service](https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/order_service.go): `src/model/service/order_service.go`
- [Payment service](https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/pay_service.go): `src/model/service/pay_service.go`
- [Manual verification](https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/manual_payment_verify.go): `src/model/service/manual_payment_verify.go`

### Chain monitoring

- [Chain listeners](https://github.com/gmwalletapp/epusdt/blob/master/src/task/listen.go): `src/task/listen.go`
- [Network scanners](https://github.com/gmwalletapp/epusdt/blob/master/src/task/listen_chain_common.go): `src/task/listen_chain_common.go`
- [Transfer matching](https://github.com/gmwalletapp/epusdt/blob/master/src/model/service/task_service.go): `src/model/service/task_service.go`

### Administration

- [Admin controllers](https://github.com/gmwalletapp/epusdt/tree/master/src/controller/admin): `src/controller/admin`
- [Telegram bot](https://github.com/gmwalletapp/epusdt/blob/master/src/telegram/telegram.go): `src/telegram/telegram.go`

### Persistence and delivery

- [Notifications](https://github.com/gmwalletapp/epusdt/blob/master/src/notify/dispatcher.go): `src/notify/dispatcher.go`
- [Callback worker](https://github.com/gmwalletapp/epusdt/blob/master/src/mq/worker.go): `src/mq/worker.go`
- [Data access](https://github.com/gmwalletapp/epusdt/tree/master/src/model/data): `src/model/data`
- [Database models](https://github.com/gmwalletapp/epusdt/tree/master/src/model/mdb): `src/model/mdb`
- [Configured database](https://github.com/gmwalletapp/epusdt/tree/master/src/model/dao): `src/model/dao`

### Other components

- **Merchant app**
- **Payer**
- **Merchant callback URL**
- **Chain RPC/API**

## Connections

- Merchant app → HTTP routes: submits API request
- Payer → HTTP routes: uses cashier
- HTTP routes → Order endpoints: dispatches order routes
- HTTP routes → Cashier endpoints: dispatches payment routes
- HTTP routes → Supported assets: dispatches config route
- Order endpoints → Order service: creates transaction
- Cashier endpoints → Payment service: loads checkout
- Cashier endpoints → Manual verification: submits transaction hash
- Order service → Data access: reads and writes orders
- Payment service → Data access: reads and updates orders
- Manual verification → Data access: checks payment records
- Supported assets → Data access: reads enabled assets
- Chain listeners → Network scanners: starts scanners
- Network scanners → Chain RPC/API: reads chain transfers
- Network scanners → Transfer matching: processes transfer events
- Transfer matching → Data access: matches and updates orders
- Transfer matching → Notifications: dispatches payment notice
- Notifications → Telegram bot: sends Telegram notice
- Admin controllers → Data access: manages gateway records
- Data access → Database models: uses persistence models
- Database models → Configured database: queries configured store
- Callback worker → Data access: loads and updates callbacks
- Callback worker → Merchant callback URL: delivers payment callback
- Admin controllers → Callback worker: reopens callback delivery
