Skip to content

Kiến trúc

1. System Context (C4 L1)

2. Container View (C4 L2)

3. Triển khai theo Mode

Điều khiển bởi APP_ENV_MQ_PAY_MODE. Nguồn: @nx/mq-pay/src/common/constants.ts:11-14.

ModeControllersQueue producerWorkerMẫu production
FULL (mặc định)Dev / single-instance
APIMột pod, scale REST theo chiều ngang
WORKERN pod, mỗi pod có Snowflake ID duy nhất (91, 92, …)

4. Component View (C4 L3)

5. Kịch bản Runtime

5.1 Boot — wiring MQ-Pay

5.2 IPN → Event → Webhook + WS

5.3 Tra cứu credential theo merchant

6. Mối quan tâm xuyên suốt

Mối quan tâmCách xử lý
Mã hóaCryptoUtility (AES-256-GCM) + secret từ APP_ENV_APPLICATION_SECRET; credential nhà cung cấp thanh toán được mã hóa khi lưu
Triển khai theo ModeAPP_ENV_MQ_PAY_MODE ∈ {FULL, API, WORKER}; ApplicationPaymentComponent bind options tương ứng
AuthNJWT (xác minh cục bộ qua JWKS từ identity); endpoint IPN có xác minh chữ ký nhà cung cấp (trong MQ-Pay)
AuthZCasbin qua PolicyDefinitionService; permission được cache
IdempotencyWebhookEventHandlerHelper bỏ qua dispatch webhook cho sự kiện không actionable (CREATED/SENT); khuyến nghị dedup phía subscriber
LoggingIGNIS structured (key: %s); loại sự kiện + transaction id trên mỗi dòng
Soft-deleteWebhookConfig soft-deletable; Configuration soft-deletable
IDsSnowflake; FULL=4, API=8, WORKER=91+

7. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.