Observe → Correlate → Diagnose → Validate → Recover → Measure
RazorTrace is a payment infrastructure intelligence system that correlates payment telemetry, application failures, and network conditions to determine why a payment failed and choose a safe recovery strategy.
Instead of treating every timeout or failure as a reason to retry, RazorTrace distinguishes between network faults, provider degradation, provider latency, and genuine bank declines before taking action.
AI diagnoses. Policy controls. Infrastructure executes.
Payment failures are not always payment problems.
A transaction may fail because of:
- network packet loss or connectivity failure
- provider latency
- provider HTTP errors
- temporary service degradation
- genuine bank rejection
- an unknown outcome where the provider processed the payment but the response was lost
Blindly retrying these failures can cause duplicate transactions or unnecessary payment attempts.
RazorTrace combines infrastructure telemetry with AI-assisted diagnosis and deterministic recovery policy to make safer decisions.
RazorTrace runs inside a controlled Microsoft Azure environment containing two Linux virtual machines.
- Application VM hosts the RazorTrace API, telemetry, AI integration, recovery logic, metrics, and dashboard.
- Gateway VM hosts the Provider and Bank simulators while also acting as the network fault-injection layer.
- Azure AI Foundry / Azure OpenAI provides AI-assisted root-cause diagnosis using
gpt-4.1-mini. - Azure Monitor and Log Analytics provide supporting infrastructure observability.
flowchart LR
A[Payment Request] --> B[Observe]
B --> C[Correlate]
C --> D[AI Diagnose]
D --> E[Policy Validate]
E --> F[Recover]
F --> G[Measure]
G --> H[Dashboard]
A normal synthetic payment follows:
Merchant / Test Client
↓
RazorTrace Gateway API
↓
Provider Simulator
↓
Bank Simulator
When a payment fails or times out, RazorTrace builds a structured incident using payment and network evidence.
Payment Failure
↓
Telemetry Collection
↓
Incident Correlation
↓
AI Root-Cause Diagnosis
↓
Deterministic Policy Validation
↓
Safe Recovery
↓
Revenue & Incident Metrics
The AI returns:
- root cause
- confidence
- supporting evidence
- recommended recovery action
Supported actions include:
RECONCILE · RETRY · WAIT · STOP
The AI does not directly execute financial actions.
| Scenario | Payment State | Diagnosis | Safe Action |
|---|---|---|---|
| Provider latency | TIMEOUT |
PROVIDER_LATENCY |
RECONCILE |
| Provider HTTP 503 | FAILED |
PROVIDER_UNAVAILABLE / DEGRADATION |
WAIT / RETRY |
| Genuine bank decline | DECLINED |
GENUINE_DECLINE |
STOP |
| Network failure | TIMEOUT |
NETWORK_FAILURE |
RECONCILE |
A timeout does not automatically mean retry.
For example, the Provider may have successfully authorized a transaction while the response was delayed beyond the Gateway timeout.
RazorTrace treats this as an unknown outcome and reconciles with the Provider before taking further action.
This prevents unsafe duplicate retries.
During the Provider latency experiment:
Provider Delay
↓
Gateway TIMEOUT
↓
Network HEALTHY
↓
PROVIDER_LATENCY
↓
AI recommends RECONCILE
↓
Policy validates RECONCILE
↓
Provider reports AUTHORIZED
↓
Payment becomes CAPTURED
The transaction was recovered without blindly creating another payment attempt.
RazorTrace tracks the business impact of payment infrastructure failures.
| Metric | Description |
|---|---|
| Total Transactions | Number of synthetic transactions processed |
| Timed Out | Payments entering an unknown timeout state |
| Recovered Transactions | Failed/timed-out payments safely recovered |
| Recovery Rate | Percentage of recoverable failures successfully recovered |
| Revenue At Risk | Value associated with infrastructure failures |
| Revenue Recovered | Value successfully recovered |
| Duplicate Retries Prevented | Potential unsafe retries avoided through reconciliation |
| Metric | Result |
|---|---|
| Transaction Amount | ₹2,499 |
| Original State | TIMEOUT |
| Final State | CAPTURED |
| Recovery Action | RECONCILE |
| Recovery Rate | 100% |
| Revenue Recovered | ₹2,499 |
| Duplicate Retry Prevented | Yes |
These values are from a synthetic validation scenario and are not production payment benchmarks.
The RazorTrace dashboard provides a live view of payment intelligence and recovery metrics.
It displays:
- total transactions
- revenue at risk
- revenue recovered
- recovery rate
- timed-out payments
- duplicate retries prevented
- transaction status
- correlated incident
- AI diagnosis
- recommended action
- recovery result
RazorTrace includes a controlled Azure networking laboratory for reproducing infrastructure failures.
Tested conditions include:
- latency
- packet loss
- jitter
- bandwidth restriction
- TCP rejection
- silent packet drop
- HTTP 500
- HTTP 503
- slow provider response
- provider outage
- genuine bank decline
Example network fault:
sudo iptables -I INPUT 1 \
-s <SERVER_PRIVATE_IP> \
-p tcp \
--dport 8002 \
-j DROPThe fault is removed after testing:
sudo iptables -D INPUT \
-s <SERVER_PRIVATE_IP> \
-p tcp \
--dport 8002 \
-j DROP| Azure Component | Purpose |
|---|---|
| Azure Virtual Machines | Hosts RazorTrace and the network/payment lab |
| Azure Virtual Network | Provides isolated application and gateway networking |
| Azure Route Table | Routes controlled traffic through the gateway |
| Azure AI Foundry / Azure OpenAI | AI-assisted incident diagnosis |
| Azure Monitor | VM and infrastructure monitoring |
| Log Analytics | Supporting observability |
The implementation intentionally avoids unnecessary cloud services to keep the prototype focused on the core payment intelligence workflow.
| Layer | Technology |
|---|---|
| API | Python, FastAPI |
| HTTP Client | HTTPX |
| Runtime | Uvicorn |
| AI | Azure AI Foundry / Azure OpenAI |
| Model | GPT-4.1-mini |
| Networking | Linux routing, iptables, tc/netem |
| Cloud | Microsoft Azure |
| Dashboard | HTML, CSS, JavaScript |
| Service Management | systemd |
| Testing | Python scenario tests |
RazorTrace/
├── config/
│ └── .env.example
│
├── docs/
│ ├── architecture/
│ └── screenshots/
│
├── infrastructure/
│ └── azure/
│ └── README.md
│
├── scripts/
│ └── merchant_client.py
│
├── services/
│ ├── ai/
│ ├── bank/
│ ├── dashboard/
│ ├── gateway/
│ ├── metrics/
│ ├── provider/
│ ├── recovery/
│ └── telemetry/
│
├── tests/
│ ├── test_provider_latency.py
│ ├── test_provider_503.py
│ ├── test_bank_decline.py
│ ├── test_network_failure.py
│ └── videos/
│
├── requirements.txt
├── .gitignore
└── README.md
RazorTrace uses environment variables for deployment-specific configuration.
Copy:
config/.env.exampleand configure values for your environment.
Example:
PROVIDER_URL=http://127.0.0.1:8002
AZURE_OPENAI_ENDPOINT=https://<your-resource>.services.ai.azure.com
AZURE_OPENAI_API_KEY=<your-api-key>
AZURE_OPENAI_DEPLOYMENT=gpt-4.1-miniNever commit real API credentials.
Create a Python environment and install dependencies:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtStart the Bank Simulator:
uvicorn services.bank.main:app --host 0.0.0.0 --port 8003Start the Provider Simulator:
uvicorn services.provider.main:app --host 0.0.0.0 --port 8002Start RazorTrace:
uvicorn services.gateway.main:app --host 0.0.0.0 --port 8001Dashboard:
http://127.0.0.1:8001/dashboard
In the Azure lab environment, the dashboard is accessed through SSH port forwarding rather than intentionally exposing it publicly.
Each major failure condition has an independent scenario test.
python tests/test_provider_latency.py
python tests/test_provider_503.py
python tests/test_bank_decline.py
python tests/test_network_failure.pyRecorded test demonstrations are available under:
tests/videos/
| Scenario | Recording |
|---|---|
| Provider latency & reconciliation | Video |
| Provider HTTP 503 | Video |
| Genuine bank decline | Video |
| Network failure | Video |
Selected implementation screenshots:
Traditional payment monitoring often tells engineers that a payment failed.
RazorTrace attempts to determine:
Why did it fail, what evidence supports that diagnosis, and what is the safest thing to do next?
By combining payment telemetry, network observability, AI-assisted diagnosis, deterministic policy validation, safe reconciliation, and revenue-impact measurement, RazorTrace turns payment failures into actionable infrastructure intelligence.
Sanjay Narayanan V, Electronics and Communication Engineering
This project is licensed under the MIT License. See the LICENSE file for details.
Observe. Correlate. Diagnose. Validate. Recover. Measure.





