How codie-ds/razorpay-recoverai works
RecoverAI diagnoses failed payments, ranks recovery options, applies deterministic policy, executes approved actions, and measures outcomes. Its React dashboard exposes transaction, incident, command-center, and human-review views. The README describes the end-to-end product flow; sampled backend routes and service excerpts support selected links, while the source index identifies additional substantial modules. In particular, the webhook excerpt shows payment-link outcome updates; the README’s broader event-processing flow is documented but not fully verifiable from sampled source.
Main entry points: recoveryDecisionEngine.js Recovery Ranking · server.js Express API · api.js API Client · models MongoDB Models
Components 24
Payment Intake
- Payment Webhook
backend/src/api/webhooks.js - Incident Detection
backend/src/services/incidentDetector.js
Recovery Decisions
- Root-Cause Inference
backend/src/services/mlInference.js - ML Models
ml/inference.py - Recovery Ranking
backend/src/services/recoveryDecisionEngine.js
Execution & Outcomes
- Policy Engine
backend/src/services/policyEngine.js - Human Approval
backend/src/api/approvals.js - Payment Execution
backend/src/services/razorpayExecutor.js - Outcome Measurement
backend/src/api/webhooks.js - Decision Explanation
backend/src/services/llmExplainability.js - Recovery Simulation
backend/src/services/simulator.js
Persistence & API
- Audit Records
backend/src/api/auditLogs.js - MongoDB Models
backend/src/db/models - Express API
backend/src/server.js - Transaction API
backend/src/api/transactions.js - Incident API
backend/src/api/incidents.js - Recovery Metrics
backend/src/api/metrics.js
Operations Dashboard
- React Dashboard
frontend/src/App.jsx - API Client
frontend/src/services/api.js - Command Center
frontend/src/pages/CommandCenter.jsx - Transaction Stories
frontend/src/pages/TransactionStories.jsx - Incident View
frontend/src/pages/Incidents.jsx - Human Review View
frontend/src/pages/HumanReview.jsx
Other components
- Razorpay
Connections 33
- Razorpay → Payment Webhook: sends events
- Payment Webhook → MongoDB Models: updates outcome
backend/src/api/webhooks.js - Razorpay → Payment Execution: executes payment
- Incident Detection → Recovery Ranking: provides context
- Recovery Ranking → Root-Cause Inference: requests inference
backend/src/services/recoveryDecisionEngine.js - Root-Cause Inference → ML Models: invokes model
backend/src/services/mlInference.js - Recovery Ranking → ML Models: scores candidates
backend/src/services/recoveryDecisionEngine.js - Recovery Ranking → Policy Engine: recommends action
- Policy Engine → Human Approval: routes review
- Policy Engine → Payment Execution: approves action
- Human Approval → Payment Execution: authorizes execution
- Payment Execution → Razorpay: calls payment API
- Payment Webhook → Outcome Measurement: reports payment
backend/src/api/webhooks.js - Outcome Measurement → MongoDB Models: persists results
backend/src/api/webhooks.js - Recovery Ranking → Decision Explanation: supplies decision evidence
- Express API → Transaction API: mounts route
backend/src/server.js - Express API → Incident API: mounts route
backend/src/server.js - Express API → Human Approval: mounts route
backend/src/server.js - Express API → Payment Webhook: mounts route
backend/src/server.js - Incident API → Incident Detection: runs detection
backend/src/api/incidents.js - Transaction API → MongoDB Models: reads transactions
backend/src/api/transactions.js - Incident API → MongoDB Models: reads incidents
backend/src/api/incidents.js - Recovery Metrics → MongoDB Models: reads metrics
backend/src/api/metrics.js - React Dashboard → Command Center: routes to
frontend/src/App.jsx - React Dashboard → Transaction Stories: routes to
frontend/src/App.jsx - React Dashboard → Incident View: routes to
frontend/src/App.jsx - React Dashboard → Human Review View: routes to
frontend/src/App.jsx - Command Center → API Client: requests dashboard data
frontend/src/pages/CommandCenter.jsx - Transaction Stories → API Client: requests transactions
frontend/src/pages/TransactionStories.jsx - Incident View → API Client: requests incidents
frontend/src/pages/Incidents.jsx - Human Review View → API Client: requests approvals
frontend/src/pages/HumanReview.jsx - API Client → Express API: calls REST routes
frontend/src/services/api.js - Recovery Simulation → Recovery Ranking: evaluates scenarios