Architecture Decisions (ADRs)
ADR-008: Asynchronous Webhook & State Machine Processing
Architectural separation of HTTP webhook reception from subscriber matching and ledger mutations.
ADR-008: Asynchronous Webhook & State Machine Processing
- Status:
ACCEPTED - Deciders: Lead Architect
- Date: September 2026
Context
Mobile financial service gateways (bKash, Nagad) impose tight timeout requirements (often under 3 seconds) on incoming webhook responses. Synchronously parsing regex, matching subscribers, querying routers, and posting ledger entries can exceed gateway timeouts during network spikes.
Decision
Decouple webhook reception from transaction execution:
SmsWebhookViewverifies the HMAC signature, inserts anInboundPaymentEventin statePENDING, and returnsHTTP 200 {status: 'ACCEPTED'}immediately (under 50ms).- The view dispatches
process_payment_event.delay(event_id). - Celery worker executes parsing, customer matching, ledger creation, and router un-isolation.
Consequences
- Positive: Zero webhook timeouts; resilient retries on network failures; immune to gateway DDoS.
- Negative: Subscriber activation is asynchronous (takes 1-2 seconds rather than immediate HTTP response).
ADR-007: Immutable Financial Ledger as Single Source of Truth
Architectural elimination of mutable balance columns in favor of append-only ledger entries.
ADR-009: Hybrid SSR / Client Next.js Architecture
Architectural design of the Next.js 16 App Router frontend with TailwindCSS v4 and mock resilience.