How stack-ajit/ai_risk_manager works
Risk Manager is an authorisation-time chargeback detector paired with a dispute evidence responder. Its main workflow constructs a transaction event log, derives point-in-time features, trains and calibrates a fraud-risk model, and serves scores and decision guidance; disputes the detector cannot prevent can be assessed for representment. Evaluation prices thresholds in rupees and reports held-out performance. The graph also includes the operator console and synthetic-data capability. Some API internals and the evidence responder’s full dispatch flow were not sampled, so uncertain links are omitted.
Main entry points: api.py Scoring and dispute API · train.py Training workflow · pipeline.py Dataset pipeline · features.py Point-in-time features
Components 15
Data and features
- Synthetic event generator
src/riskmgr/datagen.py - Dispute labeling
src/riskmgr/labeling.py - Dataset pipeline
src/riskmgr/pipeline.py - Point-in-time features
src/riskmgr/features.py - Transaction schema
src/riskmgr/schema.py
Risk modeling
- Risk and cost settings
src/riskmgr/config.py - Calibrated risk model
src/riskmgr/model.py - Training workflow
scripts/train.py - Cost-based evaluation
src/riskmgr/evaluate.py
Decisions and response
- Risk explanations
src/riskmgr/explain.py - Dispute evidence responder
src/riskmgr/evidence.py
Serving and evaluation
- Scoring and dispute API
src/riskmgr/api.py - Operator console
web/index.html - Evaluation metrics
reports/metrics.json
Other components
- Merchant operator
Connections 20
- Dataset pipeline → Synthetic event generator: generates events
src/riskmgr/pipeline.py - Dataset pipeline → Dispute labeling: assigns outcomes
src/riskmgr/pipeline.py - Dataset pipeline → Point-in-time features: builds features
- Training workflow → Dataset pipeline: loads and splits
scripts/train.py - Training workflow → Point-in-time features: uses features
- Training workflow → Calibrated risk model: fits model
scripts/train.py - Training workflow → Cost-based evaluation: evaluates thresholds
scripts/train.py - Calibrated risk model → Point-in-time features: uses feature set
src/riskmgr/model.py - Training workflow → Risk and cost settings: uses settings
scripts/train.py - Scoring and dispute API → Point-in-time features: scores with state
src/riskmgr/api.py - Scoring and dispute API → Calibrated risk model: loads and scores
src/riskmgr/api.py - Scoring and dispute API → Transaction schema: validates requests
src/riskmgr/api.py - Scoring and dispute API → Risk and cost settings: uses thresholds
src/riskmgr/api.py - Scoring and dispute API → Risk explanations: returns explanations
src/riskmgr/api.py - Scoring and dispute API → Dispute evidence responder: serves evidence
src/riskmgr/api.py - Merchant operator → Scoring and dispute API: submits requests
- Scoring and dispute API → Operator console: serves console
src/riskmgr/api.py - Operator console → Scoring and dispute API: calls endpoints
src/riskmgr/api.py - Training workflow → Evaluation metrics: writes metrics
- Cost-based evaluation → Risk and cost settings: prices decisions
src/riskmgr/evaluate.py