Gateway Architecture
This document covers the internal architecture of the Gateway service, including the middleware stack, handler organization, and request lifecycle.Component Overview
Middleware Stack
Middleware is applied in order, each adding functionality:| Order | Middleware | Purpose |
|---|---|---|
| 1 | CORS | Cross-origin request handling |
| 2 | Request Logger | Log incoming requests |
| 3 | Recovery | Panic recovery with logging |
| 4 | Rate Limiter | Per-client request throttling |
| 5 | Auth | Authentication verification |
| 6 | Audit Logger | Operation audit trail |
Middleware Files
Handler Organization
Handlers are organized by domain, each handling a specific resource type:Handler Files
| File | Endpoints | Count |
|---|---|---|
subscriber_handler.go | Register, lookup, update, block | 6 |
card_handler.go | Link, block, unblock, upload | 6 |
wallet_handler.go | Balance, payments, transfers | 5 |
agent_handler.go | Lookup, cashin, transfer | 5 |
pos_handler.go | Payment, verify-card | 3 |
compliance_handler.go | Check, alerts, rules | 8 |
admin_handler.go | Login, users, settings | 10+ |
api_key_handler.go | Create, list, revoke keys | 4 |
audit_handler.go | List, query audit logs | 3 |
processor_handler.go | Merchant/processor ops | 6 |
webhook_handler.go | VULT cashin webhook | 2 |
pep_access_handler.go | PEP access flows | 2 |
fee_settings_handler.go | Fee configuration | 4 |
notifications.go | Push notifications | 2 |
suspicious_transactions_handler.go | Fraud monitoring | 4 |
Request Lifecycle
Standard Request Flow
Authentication Flow
gRPC Client
The wallet client wraps gRPC calls to wallet-core:Route Registration
Routes are registered incmd/server/main.go:
Error Handling
Standard Error Response
gRPC Error Mapping
Configuration Loading
Next Steps
Authentication
Detailed auth configuration
Configuration
config.yaml reference