How kyareema01/payment-orchestrator works
ZethetaIntern is a payment-orchestration API. A client submits an idempotency-key-protected payment; the API creates a transaction, scores available gateway metrics, selects a gateway, and records the routed state. Gateway webhooks update transactions, while analytics endpoints query gateway volume and success rates. The README also describes a Next.js health dashboard and Stripe, Razorpay, and PayU integrations; their implementation is not present in the supplied tree. Dashed links mark unverified integration points.
Main entry points: index.ts Express API · payment.repository.ts Payment repository · webhook.service.ts Webhook processor · router.service.ts Gateway scorer
Components 15
API ingress
- Express API
apps/backend/src/index.ts - Idempotency
apps/backend/src/middlewares/idempotency.ts
Payment lifecycle
- Payment repository
apps/backend/src/modules/payment/payment.repository.ts - State machine
apps/backend/src/modules/payment/payment.state-machine.ts - MySQL database
migrations/001_initial_schema.sql - Webhook controller
apps/backend/src/modules/webhook/webhook.controller.ts - Webhook processor
apps/backend/src/modules/webhook/webhook.service.ts
Gateway routing
- Gateway scorer
apps/backend/src/modules/router/router.service.ts - Max priority queue
apps/backend/src/dsa/PriorityQueue.ts - Circuit breaker
apps/backend/src/modules/router/circuit-breaker.ts
Analytics
- Analytics controller
apps/backend/src/modules/analytics/analytics.controller.ts - Analytics queries
apps/backend/src/modules/analytics/analytics.service.ts - Dashboard UI
Other components
- API client
- Payment gateways
Connections 20
- API client → Express API: submits payments
apps/backend/src/index.ts - Express API → Idempotency: guards payment route
apps/backend/src/index.ts - Express API → Payment repository: creates transaction
apps/backend/src/index.ts - Express API → Gateway scorer: selects gateway
apps/backend/src/index.ts - Express API → Payment repository: records routing
apps/backend/src/index.ts - Gateway scorer → Max priority queue: ranks candidates
apps/backend/src/modules/router/router.service.ts - Payment repository → MySQL database: writes and locks
apps/backend/src/modules/payment/payment.repository.ts - Payment repository → State machine: validates transitions
apps/backend/src/modules/payment/payment.repository.ts - Payment gateways → Express API: sends webhook
apps/backend/src/index.ts - Express API → Webhook controller: routes webhook
apps/backend/src/index.ts - Webhook controller → Webhook processor: dispatches status
apps/backend/src/modules/webhook/webhook.controller.ts - Webhook processor → MySQL database: checks event
apps/backend/src/modules/webhook/webhook.service.ts - Webhook processor → Payment repository: updates transaction
apps/backend/src/modules/webhook/webhook.service.ts - API client → Express API: requests analytics
apps/backend/src/index.ts - Express API → Analytics controller: routes dashboard query
apps/backend/src/index.ts - Analytics controller → Analytics queries: requests metrics
apps/backend/src/modules/analytics/analytics.controller.ts - Analytics queries → MySQL database: queries aggregates
apps/backend/src/modules/analytics/analytics.service.ts - Dashboard UI → Express API: fetches metrics
README.md - Gateway scorer → Payment gateways: routes payment
README.md - Circuit breaker → Payment gateways: protects calls