AI revenue-recovery agent with Gemini, deterministic safety controls, live agent visualization, and MCP interoperability.
/— Overview dashboard/agent— Agent Control Center (live pipeline + event timeline)/mcp— MCP Control Center (live activity + tool catalog)/docs— Documentation portal/orders— Order management/simulate— Webhook simulator/api/health— Health check/mcp— MCP Streamable HTTP endpoint
Payment Event (Razorpay)
↓
Webhook Ingestion (idempotent)
↓
SQLite / PostgreSQL State
↓
Reclaim Agent Runtime (10 stages)
↓
Gemini LLM (or mock provider)
↓
Structured Recovery Plan
↓
Policy Gate (hard constraints + ERV)
↓
Safe Executor (idempotent, re-validates)
↓
Payment Action
↓
Outcome / Replan
- Python 3.11+
- Node.js 18+
- PostgreSQL (or SQLite for demo)
cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # edit DATABASE_URL, GEMINI_API_KEY
uvicorn backend.api.main:app --reload --port 8000cd dashboard
npm install
npm run devdocker-compose up -d
# Includes PostgreSQL + Redis + API| Stage | Description |
|---|---|
| RECEIVED | Webhook event validated |
| CONTEXT_LOADING | Order, customer, merchant, payment history |
| DIAGNOSING | Failure classification + severity |
| GENERATING_CANDIDATES | Relevant interventions from allowed actions |
| EVALUATING_COUNTERFACTUALS | ERV per candidate via simulator |
| PLANNING | Bounded recovery plan with stop conditions |
| SAFETY_CHECK | Policy gate: hard constraints + ERV ranking |
| EXECUTING | Idempotent action execution |
| WAITING_FOR_OUTCOME | Monitors for payment outcome |
| COMPLETED | Run complete / replan if needed |
RETRY_NOW— Immediate retryRETRY_DELAYED— Scheduled retry (default 4hr)PAYMENT_LINK— Send payment link to customerWHATSAPP_NUDGE— WhatsApp reminderALTERNATE_METHOD— Switch payment methodNO_ACTION— Safe no-op (terminal orders)HUMAN_REVIEW— Escalate to operator
- Hard constraints: max retries, hard declines, contact budget, terminal states
- ERV scoring: P(recovery)×amount − costs − friction − risk
- Executor re-check: Policy re-validated at execution time
- Idempotency: Every action recorded, duplicates rejected
- Audit trail: Every stage, tool call, decision persisted
Exposes 9 tools over Streamable HTTP at /mcp:
- 6 read-only (context, allowed actions, estimates, runs, events, eval)
- 3 guarded write (start run, execute action, cancel action) All side-effects go through the same policy gate + executor.
Compare reclaim vs always_retry baseline:
- Incremental recovered revenue
- Recovery rate
- Unnecessary interventions
- Customer contact count
- Time to resolution
/docs— Interactive documentation portaldocs/DOCUMENTATION.md— Full system documentationdocs/MCP.md— MCP integration guidedocs/API.md— API referencedocs/reclaim-system-design.md— System designdocs/reclaim-implementation-plan.md— Day-by-day build plan
# Seed demo orders (idempotent)
curl -X POST http://localhost:8000/api/seed
# Or from Python
python scripts/seed_demo.py# Backend tests
make test
# E2E test (requires PostgreSQL)
make test-e2e
# Frontend lint
cd dashboard && npm run lintreclaim/
├── backend/
│ ├── agent_runtime/ # Orchestrator, state, events, LLM provider
│ ├── agents/ # Diagnosis, candidates, planner, replanner
│ ├── api/ # FastAPI routes, webhooks, SSE
│ ├── db/ # SQLAlchemy models, session, schema
│ ├── evaluator/ # Baseline comparison
│ ├── executor/ # Safe execution, idempotency
│ ├── gemini/ # Google GenAI provider
│ ├── mcp_server/ # MCP v2 server, tools, activity
│ ├── policy/ # Constraints, ERV scoring, validator
│ ├── simulator/ # Seeded outcome simulator
│ ├── tools/ # Internal tool registry
│ └── tests/ # Pytest suite
├── dashboard/
│ ├── app/ # Next.js 16 App Router pages
│ ├── components/ # React components (shadcn-style)
│ └── lib/ # API client, SSE, types
├── docs/ # Markdown documentation
└── scripts/ # Seeding, E2E test