# ganymedenil/cryptopay architecture

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

- Interactive diagram: https://gitdiagram.com/ganymedenil/cryptopay
- Repository: https://github.com/ganymedenil/cryptopay

## Overview

CryptoPay is a self-hosted, non-custodial crypto payment gateway. A merchant creates an invoice through the Go API; the customer selects an asset and pays from their own wallet, while chain scanners observe transfers and invoice state changes lead to signed webhook notifications. The web app provides customer checkout and a substantial admin console for merchants, invoices, chains, wallets, transfers, security, and operations. The README documents the principal workflow and capabilities; several backend and UI subsystem links below reflect those documented relationships because their implementation files were not sampled.

Main entry points: [`backend/internal/invoice/service.go`](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/invoice/service.go) (Invoice lifecycle), [`backend/cmd/gateway/serve.go`](https://github.com/ganymedenil/cryptopay/blob/main/backend/cmd/gateway/serve.go) (HTTP gateway), [`web/src/components/checkout/checkout-page.tsx`](https://github.com/ganymedenil/cryptopay/blob/main/web/src/components/checkout/checkout-page.tsx) (Customer checkout), [`web/src/components/admin`](https://github.com/ganymedenil/cryptopay/tree/main/web/src/components/admin) (Admin console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_checkout["Customer checkout<br/>[checkout-page.tsx]"]
  node_webapi["Typed API client<br/>[client.ts]"]
  node_adminui["Admin console"]
  node_i18n["Localization"]
end

subgraph group_payments["Payment processing"]
  node_gateway["HTTP gateway<br/>[serve.go]"]
  node_invoice["Invoice lifecycle<br/>[service.go]"]
  node_wallets["Receiving wallets<br/>[hdwallet.go]"]
  node_rates["Exchange rates<br/>[rates.go]"]
end

subgraph group_chain["Chain monitoring"]
  node_scanner["Block scanner<br/>[scanner.go]"]
  node_chainadapters["Chain adapters"]
  node_catalog["Assets and networks<br/>[catalog.go]"]
  node_rpc["Blockchain RPC"]
end

subgraph group_operations["Operations and persistence"]
  node_webhooks["Webhook delivery<br/>[dispatcher.go]"]
  node_mailer["Email delivery<br/>[dispatcher.go]"]
  node_store["Persistence layer"]
  node_database[("PostgreSQL")]
end

node_merchant(("Merchant backend"))
node_customer(("Customer"))
node_admin(("Admin user"))

node_merchant -->|"creates invoice"| node_gateway
node_gateway -.->|"handles invoice"| node_invoice
node_gateway -->|"returns checkout URL"| node_merchant
node_merchant -->|"redirects checkout"| node_customer
node_customer -->|"opens invoice"| node_checkout
node_checkout -.->|"requests invoice"| node_webapi
node_webapi -.->|"sends API requests"| node_gateway
node_customer -->|"pays from wallet"| node_rpc
node_scanner -.->|"scans transfers"| node_chainadapters
node_chainadapters -->|"reads chain"| node_rpc
node_invoice -->|"persists state"| node_store
node_store -.->|"reads and writes"| node_database
node_scanner -.->|"updates payments"| node_invoice
node_invoice -->|"records events"| node_webhooks
node_webhooks -->|"delivers signed events"| node_merchant
node_gateway -.->|"sends email alerts"| node_mailer
node_admin -->|"manages gateway"| node_adminui
node_adminui -.->|"calls admin API"| node_webapi
node_adminui -->|"renders translations"| node_i18n
node_checkout -.->|"renders translations"| node_i18n
node_invoice -->|"assigns receiving address"| node_wallets
node_invoice -.->|"selects supported asset"| node_catalog
node_invoice -.->|"obtains quote"| node_rates

click node_gateway "https://github.com/ganymedenil/cryptopay/blob/main/backend/cmd/gateway/serve.go"
click node_invoice "https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/invoice/service.go"
click node_checkout "https://github.com/ganymedenil/cryptopay/blob/main/web/src/components/checkout/checkout-page.tsx"
click node_webapi "https://github.com/ganymedenil/cryptopay/blob/main/web/src/lib/api/client.ts"
click node_adminui "https://github.com/ganymedenil/cryptopay/tree/main/web/src/components/admin"
click node_i18n "https://github.com/ganymedenil/cryptopay/tree/main/web/src/lib/i18n"
click node_scanner "https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/scanner/scanner.go"
click node_chainadapters "https://github.com/ganymedenil/cryptopay/tree/main/backend/internal/chain"
click node_catalog "https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/catalog/catalog.go"
click node_wallets "https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/hdwallet/hdwallet.go"
click node_webhooks "https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/webhook/dispatcher.go"
click node_mailer "https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/mailer/dispatcher.go"
click node_store "https://github.com/ganymedenil/cryptopay/tree/main/backend/internal/store"
click node_rates "https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/rates/rates.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_checkout,node_webapi,node_adminui,node_i18n,node_admin toneBlue
class node_gateway,node_invoice,node_wallets,node_rates toneAmber
class node_scanner,node_chainadapters,node_catalog,node_rpc toneMint
class node_webhooks,node_mailer,node_store,node_database toneRose
class node_merchant,node_customer toneIndigo
```

## Components

### Web experience

- [Customer checkout](https://github.com/ganymedenil/cryptopay/blob/main/web/src/components/checkout/checkout-page.tsx): `web/src/components/checkout/checkout-page.tsx`
- [Typed API client](https://github.com/ganymedenil/cryptopay/blob/main/web/src/lib/api/client.ts): `web/src/lib/api/client.ts`
- [Admin console](https://github.com/ganymedenil/cryptopay/tree/main/web/src/components/admin): `web/src/components/admin`
- [Localization](https://github.com/ganymedenil/cryptopay/tree/main/web/src/lib/i18n): `web/src/lib/i18n`

### Payment processing

- [HTTP gateway](https://github.com/ganymedenil/cryptopay/blob/main/backend/cmd/gateway/serve.go): `backend/cmd/gateway/serve.go`
- [Invoice lifecycle](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/invoice/service.go): `backend/internal/invoice/service.go`
- [Receiving wallets](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/hdwallet/hdwallet.go): `backend/internal/hdwallet/hdwallet.go`
- [Exchange rates](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/rates/rates.go): `backend/internal/rates/rates.go`

### Chain monitoring

- [Block scanner](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/scanner/scanner.go): `backend/internal/scanner/scanner.go`
- [Chain adapters](https://github.com/ganymedenil/cryptopay/tree/main/backend/internal/chain): `backend/internal/chain`
- [Assets and networks](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/catalog/catalog.go): `backend/internal/catalog/catalog.go`
- **Blockchain RPC**

### Operations and persistence

- [Webhook delivery](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/webhook/dispatcher.go): `backend/internal/webhook/dispatcher.go`
- [Email delivery](https://github.com/ganymedenil/cryptopay/blob/main/backend/internal/mailer/dispatcher.go): `backend/internal/mailer/dispatcher.go`
- [Persistence layer](https://github.com/ganymedenil/cryptopay/tree/main/backend/internal/store): `backend/internal/store`
- **PostgreSQL**

### Other components

- **Merchant backend**
- **Customer**
- **Admin user**

## Connections

- Merchant backend → HTTP gateway: creates invoice (evidence: `README.md`)
- HTTP gateway → Invoice lifecycle: handles invoice
- HTTP gateway → Merchant backend: returns checkout URL (evidence: `README.md`)
- Merchant backend → Customer: redirects checkout (evidence: `README.md`)
- Customer → Customer checkout: opens invoice (evidence: `README.md`)
- Customer checkout → Typed API client: requests invoice
- Typed API client → HTTP gateway: sends API requests
- Customer → Blockchain RPC: pays from wallet (evidence: `README.md`)
- Block scanner → Chain adapters: scans transfers
- Chain adapters → Blockchain RPC: reads chain (evidence: `README.md`)
- Invoice lifecycle → Persistence layer: persists state (evidence: `README.md`)
- Persistence layer → PostgreSQL: reads and writes
- Block scanner → Invoice lifecycle: updates payments
- Invoice lifecycle → Webhook delivery: records events (evidence: `README.md`)
- Webhook delivery → Merchant backend: delivers signed events (evidence: `README.md`)
- HTTP gateway → Email delivery: sends email alerts
- Admin user → Admin console: manages gateway (evidence: `README.md`)
- Admin console → Typed API client: calls admin API
- Admin console → Localization: renders translations (evidence: `web/src/lib/i18n/translate.ts`)
- Customer checkout → Localization: renders translations
- Invoice lifecycle → Receiving wallets: assigns receiving address (evidence: `README.md`)
- Invoice lifecycle → Assets and networks: selects supported asset
- Invoice lifecycle → Exchange rates: obtains quote
