How abhinav-phi/reflex works
Reflex is a bounded AI revenue-recovery agent for failed subscription payments. Its principal workflow ingests Razorpay webhooks or simulated replay events, diagnoses the decline, ranks recovery actions by expected value, applies deterministic guardrails, then executes or routes actions for approval while recording outcomes and an auditable ledger. The React command center exposes operational controls, approvals, audit, and evaluation results; the evaluation pipeline is a separate product capability. Several subsystem links follow the README architecture because their implementation files were not excerpted.
Main entry points: App.tsx Web Application · api.ts API Client · ev.py EV Policy · main.py FastAPI Service
Components 27
Pulse Intake
- Webhook Intake
apps/api/ingest_service.py - Root-Cause Diagnosis
apps/workers/diagnosis.py - LLM Judgment
apps/workers/llm_client.py
Decisioning
- EV Policy
packages/brain/ev.py - Policy Training
packages/brain/trainer.py - Guardrails
packages/shield/guardrails.py
Execution & Proof
- Approval Queue
apps/api/routes/approvals.py - Action Dispatcher
apps/workers/dispatcher.py - Razorpay Actions
packages/connectors/razorpay.py - Channel Executors
packages/connectors/channels.py - Outcome Attribution
apps/workers/outcomes.py - Hash-Chained Ledger
packages/ledger/chain.py - Evaluation Proof
apps/eval/pipeline.py
API & State
- FastAPI Service
apps/api/main.py - PostgreSQL
apps/api/db.py - Redis Events
Operator Console
- Web Application
apps/web/src/App.tsx - Recovery Dashboard
apps/web/src/pages/Dashboard.tsx - Approvals View
apps/web/src/pages/Approvals.tsx - Audit View
apps/web/src/pages/Audit.tsx - Operations Console
apps/web/src/pages/Ops.tsx - Evaluation Results
apps/web/src/pages/Results.tsx - API Client
apps/web/src/lib/api.ts - Live Event Stream
apps/web/src/hooks/useStream.ts - UI State
apps/web/src/store.ts
Other components
- Razorpay Webhooks
- Replay Engine
Connections 31
- Razorpay Webhooks → Webhook Intake: sends webhooks
README.md - Replay Engine → Webhook Intake: replays events
README.md - Webhook Intake → Root-Cause Diagnosis: queues diagnosis
README.md - Root-Cause Diagnosis → LLM Judgment: judges ambiguous cases
README.md - Root-Cause Diagnosis → EV Policy: provides diagnosis
README.md - EV Policy → Guardrails: proposes actions
README.md - Guardrails → Approval Queue: requests approval
README.md - Guardrails → Action Dispatcher: permits actions
README.md - Action Dispatcher → Razorpay Actions: executes payments
README.md - Action Dispatcher → Channel Executors: sends messages
README.md - Razorpay Actions → Hash-Chained Ledger: records actions
README.md - Channel Executors → Hash-Chained Ledger: records actions
README.md - Razorpay Actions → Outcome Attribution: reports outcomes
README.md - Channel Executors → Outcome Attribution: reports outcomes
README.md - Outcome Attribution → EV Policy: updates policy
README.md - EV Policy → Policy Training: tunes policy
- Evaluation Proof → Evaluation Results: supplies results
- FastAPI Service → PostgreSQL: persists records
README.md - FastAPI Service → Redis Events: publishes live events
README.md - Web Application → Recovery Dashboard: routes to
apps/web/src/App.tsx - Web Application → Approvals View: routes to
apps/web/src/App.tsx - Web Application → Audit View: routes to
apps/web/src/App.tsx - Web Application → Operations Console: routes to
apps/web/src/App.tsx - Web Application → Evaluation Results: routes to
apps/web/src/App.tsx - Recovery Dashboard → API Client: requests metrics
apps/web/src/pages/Dashboard.tsx - Approvals View → API Client: requests approvals
apps/web/src/pages/Approvals.tsx - Audit View → API Client: requests audit data
apps/web/src/pages/Audit.tsx - Operations Console → API Client: controls operation
apps/web/src/pages/Ops.tsx - API Client → FastAPI Service: calls REST API
README.md - Live Event Stream → FastAPI Service: subscribes via SSE
README.md - Live Event Stream → UI State: updates live state
apps/web/src/hooks/useStream.ts