# mageg-x/gopay architecture

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

- Interactive diagram: https://gitdiagram.com/mageg-x/gopay
- Repository: https://github.com/mageg-x/gopay

## Overview

GoPay is an aggregate payment gateway with a Vue merchant/admin interface and a Go HTTP backend. The primary workflow is a payer selecting a payment method in the cashier, submitting an order, and completing payment through a configured provider; merchants then track orders and manage funds, while administrators configure channels and operations. The graph also preserves documented risk, settlement, transfer, plugin, and management capabilities. Several backend implementation links are based on documented responsibilities and module paths; the sampled backend excerpts do not show all call sites.

Main entry points: [`server/src/handler/api/pay.go`](https://github.com/mageg-x/gopay/blob/main/server/src/handler/api/pay.go) (Payment endpoints), [`server/src/handler/admin/admin.go`](https://github.com/mageg-x/gopay/blob/main/server/src/handler/admin/admin.go) (Admin endpoints), [`server/src/model`](https://github.com/mageg-x/gopay/tree/main/server/src/model) (Domain models), [`server/src/router/router.go`](https://github.com/mageg-x/gopay/blob/main/server/src/router/router.go) (HTTP router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web experience"]
  node_cashier["Cashier UI<br/>[index.vue]"]
  node_merchant_ui["Merchant portal"]
  node_admin_ui["Admin console"]
  node_web_api["Web API clients"]
  node_web_router["Web router<br/>[index.ts]"]
end

subgraph group_http["HTTP application"]
  node_http_router["HTTP router<br/>[router.go]"]
  node_pay_handler["Payment endpoints<br/>[pay.go]"]
  node_user_handler["Merchant endpoints<br/>[user.go]"]
  node_admin_handler["Admin endpoints<br/>[admin.go]"]
end

subgraph group_payments["Payment processing"]
  node_orders["Order service<br/>[order.go]"]
  node_payment["Payment service<br/>[payment.go]"]
  node_plugin_api["Plugin interface<br/>[interface.go]"]
  node_channel_plugins["Alipay and WeChat"]
  node_risk["Risk controls<br/>[risk.go]"]
end

subgraph group_operations["Merchant operations"]
  node_auth["Authentication<br/>[auth.go]"]
  node_settle["Settlement service<br/>[settle.go]"]
  node_transfer["Transfer service<br/>[transfer.go]"]
  node_profitsharing["Profit sharing<br/>[profitsharing.go]"]
  node_models["Domain models"]
  node_database[("SQLite database<br/>[config.go]")]
end

node_payer(("Payer"))
node_merchant(("Merchant"))
node_admin(("Administrator"))
node_external_pay(("Payment providers"))

node_payer -->|"opens cashier"| node_cashier
node_cashier -->|"requests payment"| node_web_api
node_merchant -->|"uses portal"| node_merchant_ui
node_admin -->|"uses console"| node_admin_ui
node_merchant_ui -->|"requests data"| node_web_api
node_admin_ui -->|"requests management"| node_web_api
node_web_router -->|"routes to"| node_cashier
node_web_router -->|"routes to"| node_merchant_ui
node_web_router -->|"routes to"| node_admin_ui
node_web_api -->|"calls API"| node_http_router
node_http_router -->|"dispatches payment"| node_pay_handler
node_http_router -->|"dispatches merchant"| node_user_handler
node_http_router -->|"dispatches admin"| node_admin_handler
node_pay_handler -->|"validates signatures"| node_auth
node_pay_handler -->|"checks risk"| node_risk
node_pay_handler -->|"manages orders"| node_orders
node_pay_handler -->|"processes payment"| node_payment
node_payment -->|"uses interface"| node_plugin_api
node_channel_plugins -->|"implements"| node_plugin_api
node_channel_plugins -->|"requests payment"| node_external_pay
node_user_handler -->|"authenticates"| node_auth
node_admin_handler -->|"authenticates"| node_auth
node_admin_handler -->|"manages settlements"| node_settle
node_admin_handler -->|"manages transfers"| node_transfer
node_admin_handler -->|"manages sharing"| node_profitsharing
node_orders -->|"uses order data"| node_models
node_settle -->|"uses settlement data"| node_models
node_transfer -->|"uses transfer data"| node_models
node_profitsharing -->|"uses sharing data"| node_models
node_models -->|"persists records"| node_database

click node_cashier "https://github.com/mageg-x/gopay/blob/main/web/src/views/cashier/index.vue"
click node_merchant_ui "https://github.com/mageg-x/gopay/tree/main/web/src/views/user"
click node_admin_ui "https://github.com/mageg-x/gopay/tree/main/web/src/views/admin"
click node_web_api "https://github.com/mageg-x/gopay/tree/main/web/src/api"
click node_web_router "https://github.com/mageg-x/gopay/blob/main/web/src/router/index.ts"
click node_http_router "https://github.com/mageg-x/gopay/blob/main/server/src/router/router.go"
click node_pay_handler "https://github.com/mageg-x/gopay/blob/main/server/src/handler/api/pay.go"
click node_user_handler "https://github.com/mageg-x/gopay/blob/main/server/src/handler/user/user.go"
click node_admin_handler "https://github.com/mageg-x/gopay/blob/main/server/src/handler/admin/admin.go"
click node_auth "https://github.com/mageg-x/gopay/blob/main/server/src/service/auth.go"
click node_orders "https://github.com/mageg-x/gopay/blob/main/server/src/service/order.go"
click node_payment "https://github.com/mageg-x/gopay/blob/main/server/src/service/payment.go"
click node_plugin_api "https://github.com/mageg-x/gopay/blob/main/server/src/plugin/interface.go"
click node_channel_plugins "https://github.com/mageg-x/gopay/tree/main/server/src/plugin/channels"
click node_risk "https://github.com/mageg-x/gopay/blob/main/server/src/service/risk.go"
click node_settle "https://github.com/mageg-x/gopay/blob/main/server/src/service/settle.go"
click node_transfer "https://github.com/mageg-x/gopay/blob/main/server/src/service/transfer.go"
click node_profitsharing "https://github.com/mageg-x/gopay/blob/main/server/src/service/profitsharing.go"
click node_models "https://github.com/mageg-x/gopay/tree/main/server/src/model"
click node_database "https://github.com/mageg-x/gopay/blob/main/server/src/config/config.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_cashier,node_merchant_ui,node_admin_ui,node_web_api,node_web_router toneBlue
class node_http_router,node_pay_handler,node_user_handler,node_admin_handler toneAmber
class node_orders,node_payment,node_plugin_api,node_channel_plugins,node_risk toneMint
class node_auth,node_settle,node_transfer,node_profitsharing,node_models,node_database toneRose
class node_payer,node_merchant,node_admin,node_external_pay toneIndigo
```

## Components

### Web experience

- [Cashier UI](https://github.com/mageg-x/gopay/blob/main/web/src/views/cashier/index.vue): `web/src/views/cashier/index.vue`
- [Merchant portal](https://github.com/mageg-x/gopay/tree/main/web/src/views/user): `web/src/views/user`
- [Admin console](https://github.com/mageg-x/gopay/tree/main/web/src/views/admin): `web/src/views/admin`
- [Web API clients](https://github.com/mageg-x/gopay/tree/main/web/src/api): `web/src/api`
- [Web router](https://github.com/mageg-x/gopay/blob/main/web/src/router/index.ts): `web/src/router/index.ts`

### HTTP application

- [HTTP router](https://github.com/mageg-x/gopay/blob/main/server/src/router/router.go): `server/src/router/router.go`
- [Payment endpoints](https://github.com/mageg-x/gopay/blob/main/server/src/handler/api/pay.go): `server/src/handler/api/pay.go`
- [Merchant endpoints](https://github.com/mageg-x/gopay/blob/main/server/src/handler/user/user.go): `server/src/handler/user/user.go`
- [Admin endpoints](https://github.com/mageg-x/gopay/blob/main/server/src/handler/admin/admin.go): `server/src/handler/admin/admin.go`

### Payment processing

- [Order service](https://github.com/mageg-x/gopay/blob/main/server/src/service/order.go): `server/src/service/order.go`
- [Payment service](https://github.com/mageg-x/gopay/blob/main/server/src/service/payment.go): `server/src/service/payment.go`
- [Plugin interface](https://github.com/mageg-x/gopay/blob/main/server/src/plugin/interface.go): `server/src/plugin/interface.go`
- [Alipay and WeChat](https://github.com/mageg-x/gopay/tree/main/server/src/plugin/channels): `server/src/plugin/channels`
- [Risk controls](https://github.com/mageg-x/gopay/blob/main/server/src/service/risk.go): `server/src/service/risk.go`

### Merchant operations

- [Authentication](https://github.com/mageg-x/gopay/blob/main/server/src/service/auth.go): `server/src/service/auth.go`
- [Settlement service](https://github.com/mageg-x/gopay/blob/main/server/src/service/settle.go): `server/src/service/settle.go`
- [Transfer service](https://github.com/mageg-x/gopay/blob/main/server/src/service/transfer.go): `server/src/service/transfer.go`
- [Profit sharing](https://github.com/mageg-x/gopay/blob/main/server/src/service/profitsharing.go): `server/src/service/profitsharing.go`
- [Domain models](https://github.com/mageg-x/gopay/tree/main/server/src/model): `server/src/model`
- [SQLite database](https://github.com/mageg-x/gopay/blob/main/server/src/config/config.go): `server/src/config/config.go`

### Other components

- **Payer**
- **Merchant**
- **Administrator**
- **Payment providers**

## Connections

- Payer → Cashier UI: opens cashier
- Cashier UI → Web API clients: requests payment
- Merchant → Merchant portal: uses portal
- Administrator → Admin console: uses console
- Merchant portal → Web API clients: requests data
- Admin console → Web API clients: requests management
- Web router → Cashier UI: routes to
- Web router → Merchant portal: routes to
- Web router → Admin console: routes to
- Web API clients → HTTP router: calls API
- HTTP router → Payment endpoints: dispatches payment
- HTTP router → Merchant endpoints: dispatches merchant
- HTTP router → Admin endpoints: dispatches admin
- Payment endpoints → Authentication: validates signatures
- Payment endpoints → Risk controls: checks risk
- Payment endpoints → Order service: manages orders
- Payment endpoints → Payment service: processes payment
- Payment service → Plugin interface: uses interface
- Alipay and WeChat → Plugin interface: implements
- Alipay and WeChat → Payment providers: requests payment
- Merchant endpoints → Authentication: authenticates
- Admin endpoints → Authentication: authenticates
- Admin endpoints → Settlement service: manages settlements
- Admin endpoints → Transfer service: manages transfers
- Admin endpoints → Profit sharing: manages sharing
- Order service → Domain models: uses order data
- Settlement service → Domain models: uses settlement data
- Transfer service → Domain models: uses transfer data
- Profit sharing → Domain models: uses sharing data
- Domain models → SQLite database: persists records
