# 404avinash/sampati_v2 architecture

> Architecture diagram of the GitHub repository 404avinash/sampati_v2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/404avinash/sampati_v2
- Repository: https://github.com/404avinash/sampati_v2

## Overview

SAMPATI V2 and Fox Guard form isolated core and edge fraud-defense planes. A phone-side workflow detects scam context, assesses device risk, and warns or blocks before payment; the core workflow evaluates UPI transactions, enriches risk with institutional and network intelligence, issues a verdict, and supports investigation and statutory reporting. The README documents their REST/FCM bridge. Relationships below use README or SOURCE INDEX evidence; unsampled subsystems are represented only where documented or indexed.

Main entry points: [`app/services/upi_cases.py`](https://github.com/404avinash/sampati_v2/blob/main/app/services/upi_cases.py) (Evaluation and Cases), [`lomdi-guard/app/src/main/java/com/lomdi/dsih/LomdiAccessibilityService.kt`](https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/LomdiAccessibilityService.kt) (Payment Intercept), [`app/main.py`](https://github.com/404avinash/sampati_v2/blob/main/app/main.py) (FastAPI Application), [`lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/RiskManager.kt`](https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/RiskManager.kt) (Context Risk)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Fox Guard Edge"]
  node_android_events["Device Signals<br/>[CallReceiver.kt]"]
  node_sms_analysis["SMS Analysis<br/>[SmsAnalyzer.kt]"]
  node_risk_manager["Context Risk<br/>[RiskManager.kt]"]
  node_edge_block["Payment Intercept"]
end

subgraph group_core["SAMPATI Core"]
  node_telemetry_api["Edge Telemetry API<br/>[telemetry.py]"]
  node_upi_api["UPI Gate API<br/>[upi.py]"]
  node_case_service["Evaluation and Cases<br/>[upi_cases.py]"]
  node_scoring["Risk Scoring<br/>[upi_scorer.py]"]
  node_institutional_adapters["Institutional Adapters<br/>[service.py]"]
  node_app_entry["FastAPI Application<br/>[main.py]"]
end

subgraph group_intel["Intelligence Mesh"]
  node_fraud_graph["Fraud Graph<br/>[graph_service.py]"]
  node_federation["Federation<br/>[coordinator.py]"]
  node_threat_intel["Threat Intelligence"]
  node_intel_api["Intel API<br/>[intel.py]"]
end

subgraph group_cases["Cases and Forensics"]
  node_case_store[("Case Persistence<br/>[upi_persistence.py]")]
  node_sar_pdf["SAR Reporting<br/>[sar_pdf.py]"]
  node_gemini["Forensic Copilot<br/>[gemini_service.py]"]
end

subgraph group_soc["Analyst Console"]
  node_dashboard["Analyst Dashboard<br/>[App.jsx]"]
  node_app_state["Live App State"]
  node_web_api["Dashboard API Client<br/>[api.js]"]
end

node_phone_user(("Phone User"))
node_analyst(("Analyst"))
node_bank_switch(("UPI Switch"))
node_gemini_service["Google Gemini"]
node_fcm["FCM"]

node_phone_user -->|"generates signals"| node_android_events
node_android_events -.->|"contributes context"| node_risk_manager
node_sms_analysis -.->|"contributes context"| node_risk_manager
node_risk_manager -->|"drives interception"| node_edge_block
node_edge_block -->|"posts events"| node_telemetry_api
node_edge_block -->|"posts signals"| node_intel_api
node_bank_switch -->|"submits transaction"| node_upi_api
node_upi_api -->|"delegates evaluation"| node_case_service
node_case_service -->|"scores transaction"| node_scoring
node_case_service -->|"queries signals"| node_institutional_adapters
node_case_service -->|"coordinates consensus"| node_federation
node_case_service -.->|"updates graph"| node_fraud_graph
node_case_service -->|"persists cases"| node_case_store
node_threat_intel -->|"updates graph"| node_fraud_graph
node_intel_api -->|"ingests signals"| node_threat_intel
node_case_service -->|"generates reports"| node_sar_pdf
node_case_service -->|"requests assistance"| node_gemini
node_gemini -.->|"calls model"| node_gemini_service
node_app_entry -->|"registers routes"| node_upi_api
node_analyst -->|"uses console"| node_dashboard
node_dashboard -->|"provides state"| node_app_state
node_app_state -->|"fetches data"| node_web_api
node_web_api -.->|"calls REST API"| node_app_entry
node_app_entry -->|"sends alerts"| node_fcm

click node_android_events "https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/CallReceiver.kt"
click node_sms_analysis "https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/SmsAnalyzer.kt"
click node_risk_manager "https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/RiskManager.kt"
click node_edge_block "https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/LomdiAccessibilityService.kt"
click node_telemetry_api "https://github.com/404avinash/sampati_v2/blob/main/app/api/telemetry.py"
click node_upi_api "https://github.com/404avinash/sampati_v2/blob/main/app/api/upi.py"
click node_case_service "https://github.com/404avinash/sampati_v2/blob/main/app/services/upi_cases.py"
click node_scoring "https://github.com/404avinash/sampati_v2/blob/main/app/engine/upi_scorer.py"
click node_institutional_adapters "https://github.com/404avinash/sampati_v2/blob/main/app/adapters/service.py"
click node_fraud_graph "https://github.com/404avinash/sampati_v2/blob/main/app/services/graph_service.py"
click node_federation "https://github.com/404avinash/sampati_v2/blob/main/app/federation/coordinator.py"
click node_threat_intel "https://github.com/404avinash/sampati_v2/blob/main/app/services/threat_intel_service.py"
click node_intel_api "https://github.com/404avinash/sampati_v2/blob/main/app/api/intel.py"
click node_case_store "https://github.com/404avinash/sampati_v2/blob/main/app/models/upi_persistence.py"
click node_sar_pdf "https://github.com/404avinash/sampati_v2/blob/main/app/forensics/sar_pdf.py"
click node_gemini "https://github.com/404avinash/sampati_v2/blob/main/app/services/gemini_service.py"
click node_app_entry "https://github.com/404avinash/sampati_v2/blob/main/app/main.py"
click node_dashboard "https://github.com/404avinash/sampati_v2/blob/main/frontend/src/App.jsx"
click node_app_state "https://github.com/404avinash/sampati_v2/blob/main/frontend/src/context/AppStateContext.jsx"
click node_web_api "https://github.com/404avinash/sampati_v2/blob/main/frontend/src/services/api.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_android_events,node_sms_analysis,node_risk_manager,node_edge_block,node_phone_user toneBlue
class node_telemetry_api,node_upi_api,node_case_service,node_scoring,node_institutional_adapters,node_app_entry toneAmber
class node_fraud_graph,node_federation,node_threat_intel,node_intel_api toneMint
class node_case_store,node_sar_pdf,node_gemini toneRose
class node_dashboard,node_app_state,node_web_api,node_analyst,node_bank_switch,node_gemini_service,node_fcm toneIndigo
```

## Components

### Fox Guard Edge

- [Device Signals](https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/CallReceiver.kt): `lomdi-guard/app/src/main/java/com/lomdi/dsih/CallReceiver.kt`
- [SMS Analysis](https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/SmsAnalyzer.kt): `lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/SmsAnalyzer.kt`
- [Context Risk](https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/RiskManager.kt): `lomdi-guard/app/src/main/java/com/lomdi/dsih/domain/usecase/RiskManager.kt`
- [Payment Intercept](https://github.com/404avinash/sampati_v2/blob/main/lomdi-guard/app/src/main/java/com/lomdi/dsih/LomdiAccessibilityService.kt): `lomdi-guard/app/src/main/java/com/lomdi/dsih/LomdiAccessibilityService.kt`

### SAMPATI Core

- [Edge Telemetry API](https://github.com/404avinash/sampati_v2/blob/main/app/api/telemetry.py): `app/api/telemetry.py`
- [UPI Gate API](https://github.com/404avinash/sampati_v2/blob/main/app/api/upi.py): `app/api/upi.py`
- [Evaluation and Cases](https://github.com/404avinash/sampati_v2/blob/main/app/services/upi_cases.py): `app/services/upi_cases.py`
- [Risk Scoring](https://github.com/404avinash/sampati_v2/blob/main/app/engine/upi_scorer.py): `app/engine/upi_scorer.py`
- [Institutional Adapters](https://github.com/404avinash/sampati_v2/blob/main/app/adapters/service.py): `app/adapters/service.py`
- [FastAPI Application](https://github.com/404avinash/sampati_v2/blob/main/app/main.py): `app/main.py`

### Intelligence Mesh

- [Fraud Graph](https://github.com/404avinash/sampati_v2/blob/main/app/services/graph_service.py): `app/services/graph_service.py`
- [Federation](https://github.com/404avinash/sampati_v2/blob/main/app/federation/coordinator.py): `app/federation/coordinator.py`
- [Threat Intelligence](https://github.com/404avinash/sampati_v2/blob/main/app/services/threat_intel_service.py): `app/services/threat_intel_service.py`
- [Intel API](https://github.com/404avinash/sampati_v2/blob/main/app/api/intel.py): `app/api/intel.py`

### Cases and Forensics

- [Case Persistence](https://github.com/404avinash/sampati_v2/blob/main/app/models/upi_persistence.py): `app/models/upi_persistence.py`
- [SAR Reporting](https://github.com/404avinash/sampati_v2/blob/main/app/forensics/sar_pdf.py): `app/forensics/sar_pdf.py`
- [Forensic Copilot](https://github.com/404avinash/sampati_v2/blob/main/app/services/gemini_service.py): `app/services/gemini_service.py`

### Analyst Console

- [Analyst Dashboard](https://github.com/404avinash/sampati_v2/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Live App State](https://github.com/404avinash/sampati_v2/blob/main/frontend/src/context/AppStateContext.jsx): `frontend/src/context/AppStateContext.jsx`
- [Dashboard API Client](https://github.com/404avinash/sampati_v2/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Other components

- **Phone User**
- **Analyst**
- **UPI Switch**
- **Google Gemini**
- **FCM**

## Connections

- Phone User → Device Signals: generates signals
- Device Signals → Context Risk: contributes context
- SMS Analysis → Context Risk: contributes context
- Context Risk → Payment Intercept: drives interception (evidence: `lomdi-guard/app/src/main/java/com/lomdi/dsih/LomdiAccessibilityService.kt`)
- Payment Intercept → Edge Telemetry API: posts events
- Payment Intercept → Intel API: posts signals
- UPI Switch → UPI Gate API: submits transaction
- UPI Gate API → Evaluation and Cases: delegates evaluation (evidence: `app/api/upi.py`)
- Evaluation and Cases → Risk Scoring: scores transaction (evidence: `app/services/upi_cases.py`)
- Evaluation and Cases → Institutional Adapters: queries signals (evidence: `app/services/upi_cases.py`)
- Evaluation and Cases → Federation: coordinates consensus (evidence: `app/services/upi_cases.py`)
- Evaluation and Cases → Fraud Graph: updates graph
- Evaluation and Cases → Case Persistence: persists cases (evidence: `app/services/upi_cases.py`)
- Threat Intelligence → Fraud Graph: updates graph (evidence: `app/services/threat_intel_service.py`)
- Intel API → Threat Intelligence: ingests signals (evidence: `app/api/intel.py`)
- Evaluation and Cases → SAR Reporting: generates reports (evidence: `app/services/upi_cases.py`)
- Evaluation and Cases → Forensic Copilot: requests assistance (evidence: `app/services/upi_cases.py`)
- Forensic Copilot → Google Gemini: calls model
- FastAPI Application → UPI Gate API: registers routes (evidence: `app/main.py`)
- Analyst → Analyst Dashboard: uses console
- Analyst Dashboard → Live App State: provides state (evidence: `frontend/src/App.jsx`)
- Live App State → Dashboard API Client: fetches data (evidence: `frontend/src/context/AppStateContext.jsx`)
- Dashboard API Client → FastAPI Application: calls REST API
- FastAPI Application → FCM: sends alerts
