# zahidec0de/mirsad architecture

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

- Interactive diagram: https://gitdiagram.com/zahidec0de/mirsad
- Repository: https://github.com/zahidec0de/mirsad

## Overview

Mirsad is a bank-consulted fraud scoring and recommendation product: a bank submits a proposed payee transfer, Guard gathers consent-scoped telecom evidence, weighs it, and returns a rule-governed verdict with a score, trace, customer messages, and case file. Hunter separately analyzes the shared transaction ledger for mule rings; its intelligence can affect Guard verdicts. The web console exposes Guard, Hunter, dashboard, assessments, scenarios, and compliance views. Some UI and backend relationships are inferred only from the README or import references; those edges are omitted or marked unverified.

Main entry points: [`src/mirsad/guard/agent.py`](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/agent.py) (Guard workflow), [`frontend/src/App.tsx`](https://github.com/zahidec0de/mirsad/blob/main/frontend/src/App.tsx) (Web console), [`src/mirsad/api/service.py`](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/api/service.py) (API service), [`src/mirsad/api/app.py`](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/api/app.py) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Bank and console"]
  node_webapp["Web console<br/>[App.tsx]"]
  node_api["HTTP API<br/>[app.py]"]
  node_service["API service<br/>[service.py]"]
  node_frontend_api["Frontend API client<br/>[api.ts]"]
  node_bank_result["Verdict and evidence"]
end

subgraph group_guard["Guard assessment"]
  node_guard_agent["Guard workflow<br/>[agent.py]"]
  node_evidence["Evidence gathering<br/>[evidence.py]"]
  node_rules["Safety rules<br/>[rules.py]"]
  node_risk["Risk scoring<br/>[risk.py]"]
  node_llm["Model providers"]
end

subgraph group_intel["Network intelligence"]
  node_nac["CAMARA network client<br/>[client.py]"]
  node_hunter["Ring detection<br/>[engine.py]"]
  node_ring_graph["Ring graph<br/>[graph.py]"]
end

subgraph group_records["Ledger and casework"]
  node_ledger[("Assessment ledger<br/>[store.py]")]
  node_case_file["Case file<br/>[case_file.py]"]
  node_messages["Bilingual messages<br/>[copy.py]"]
end

subgraph group_presentation["Product views"]
  node_dashboard["Dashboard views<br/>[app.py]"]
  node_guard_view["Guard view<br/>[GuardView.tsx]"]
  node_hunter_view["Hunter view<br/>[HunterView.tsx]"]
  node_assessments["Assessment log"]
  node_compliance["Compliance view<br/>[CompliancePage.tsx]"]
end

node_bank(("Bank caller"))

node_bank -.->|"submits assessment"| node_api
node_api -->|"dispatches requests"| node_service
node_service -->|"requests verdict"| node_guard_agent
node_guard_agent -->|"gathers evidence"| node_evidence
node_guard_agent -->|"requests proposals"| node_llm
node_evidence -->|"calls network APIs"| node_nac
node_guard_agent -->|"applies final rules"| node_rules
node_guard_agent -->|"computes score"| node_risk
node_service -->|"records verdict"| node_ledger
node_service -->|"assembles case file"| node_case_file
node_case_file -->|"uses message text"| node_messages
node_hunter -->|"reads transactions"| node_ledger
node_hunter -->|"checks candidates"| node_nac
node_guard_agent -->|"uses ring intelligence"| node_hunter
node_webapp -->|"calls API client"| node_frontend_api
node_frontend_api -.->|"sends requests"| node_api
node_api -.->|"returns verdict"| node_bank_result
node_webapp -->|"renders assessment"| node_guard_view
node_webapp -->|"renders ring findings"| node_hunter_view
node_frontend_api -->|"loads assessment log"| node_assessments
node_dashboard -->|"runs assessment"| node_guard_agent
node_dashboard -->|"records verdict"| node_ledger
node_dashboard -.->|"serves ring view"| node_hunter
node_webapp -->|"offers compliance view"| node_compliance

click node_webapp "https://github.com/zahidec0de/mirsad/blob/main/frontend/src/App.tsx"
click node_api "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/api/app.py"
click node_service "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/api/service.py"
click node_guard_agent "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/agent.py"
click node_evidence "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/evidence.py"
click node_rules "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/rules.py"
click node_risk "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/risk.py"
click node_llm "https://github.com/zahidec0de/mirsad/tree/main/src/mirsad/guard/llm"
click node_nac "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/nac_client/client.py"
click node_hunter "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/hunter/engine.py"
click node_ring_graph "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/hunter/graph.py"
click node_ledger "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/ledger/store.py"
click node_case_file "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/case_file.py"
click node_messages "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/copy.py"
click node_frontend_api "https://github.com/zahidec0de/mirsad/blob/main/frontend/src/api.ts"
click node_dashboard "https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/dashboard/app.py"
click node_guard_view "https://github.com/zahidec0de/mirsad/blob/main/frontend/src/views/GuardView.tsx"
click node_hunter_view "https://github.com/zahidec0de/mirsad/blob/main/frontend/src/views/HunterView.tsx"
click node_assessments "https://github.com/zahidec0de/mirsad/blob/main/frontend/src/pages/AssessmentsPage.tsx"
click node_compliance "https://github.com/zahidec0de/mirsad/blob/main/frontend/src/pages/CompliancePage.tsx"

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_webapp,node_api,node_service,node_frontend_api,node_bank_result toneBlue
class node_guard_agent,node_evidence,node_rules,node_risk,node_llm toneAmber
class node_nac,node_hunter,node_ring_graph toneMint
class node_ledger,node_case_file,node_messages toneRose
class node_dashboard,node_guard_view,node_hunter_view,node_assessments,node_compliance,node_bank toneIndigo
```

## Components

### Bank and console

- [Web console](https://github.com/zahidec0de/mirsad/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [HTTP API](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/api/app.py): `src/mirsad/api/app.py`
- [API service](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/api/service.py): `src/mirsad/api/service.py`
- [Frontend API client](https://github.com/zahidec0de/mirsad/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- **Verdict and evidence**

### Guard assessment

- [Guard workflow](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/agent.py): `src/mirsad/guard/agent.py`
- [Evidence gathering](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/evidence.py): `src/mirsad/guard/evidence.py`
- [Safety rules](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/rules.py): `src/mirsad/guard/rules.py`
- [Risk scoring](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/guard/risk.py): `src/mirsad/guard/risk.py`
- [Model providers](https://github.com/zahidec0de/mirsad/tree/main/src/mirsad/guard/llm): `src/mirsad/guard/llm`

### Network intelligence

- [CAMARA network client](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/nac_client/client.py): `src/mirsad/nac_client/client.py`
- [Ring detection](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/hunter/engine.py): `src/mirsad/hunter/engine.py`
- [Ring graph](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/hunter/graph.py): `src/mirsad/hunter/graph.py`

### Ledger and casework

- [Assessment ledger](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/ledger/store.py): `src/mirsad/ledger/store.py`
- [Case file](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/case_file.py): `src/mirsad/case_file.py`
- [Bilingual messages](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/copy.py): `src/mirsad/copy.py`

### Product views

- [Dashboard views](https://github.com/zahidec0de/mirsad/blob/main/src/mirsad/dashboard/app.py): `src/mirsad/dashboard/app.py`
- [Guard view](https://github.com/zahidec0de/mirsad/blob/main/frontend/src/views/GuardView.tsx): `frontend/src/views/GuardView.tsx`
- [Hunter view](https://github.com/zahidec0de/mirsad/blob/main/frontend/src/views/HunterView.tsx): `frontend/src/views/HunterView.tsx`
- [Assessment log](https://github.com/zahidec0de/mirsad/blob/main/frontend/src/pages/AssessmentsPage.tsx): `frontend/src/pages/AssessmentsPage.tsx`
- [Compliance view](https://github.com/zahidec0de/mirsad/blob/main/frontend/src/pages/CompliancePage.tsx): `frontend/src/pages/CompliancePage.tsx`

### Other components

- **Bank caller**

## Connections

- Bank caller → HTTP API: submits assessment
- HTTP API → API service: dispatches requests (evidence: `src/mirsad/api/app.py`)
- API service → Guard workflow: requests verdict (evidence: `src/mirsad/api/service.py`)
- Guard workflow → Evidence gathering: gathers evidence (evidence: `src/mirsad/guard/agent.py`)
- Guard workflow → Model providers: requests proposals (evidence: `src/mirsad/guard/agent.py`)
- Evidence gathering → CAMARA network client: calls network APIs (evidence: `src/mirsad/guard/evidence.py`)
- Guard workflow → Safety rules: applies final rules (evidence: `src/mirsad/guard/agent.py`)
- Guard workflow → Risk scoring: computes score (evidence: `src/mirsad/guard/agent.py`)
- API service → Assessment ledger: records verdict (evidence: `src/mirsad/api/service.py`)
- API service → Case file: assembles case file (evidence: `src/mirsad/api/service.py`)
- Case file → Bilingual messages: uses message text (evidence: `src/mirsad/case_file.py`)
- Ring detection → Assessment ledger: reads transactions (evidence: `src/mirsad/hunter/engine.py`)
- Ring detection → CAMARA network client: checks candidates (evidence: `src/mirsad/hunter/engine.py`)
- Guard workflow → Ring detection: uses ring intelligence (evidence: `src/mirsad/guard/agent.py`)
- Web console → Frontend API client: calls API client (evidence: `frontend/src/App.tsx`)
- Frontend API client → HTTP API: sends requests
- HTTP API → Verdict and evidence: returns verdict
- Web console → Guard view: renders assessment (evidence: `frontend/src/App.tsx`)
- Web console → Hunter view: renders ring findings (evidence: `frontend/src/App.tsx`)
- Frontend API client → Assessment log: loads assessment log (evidence: `frontend/src/pages/AssessmentsPage.tsx`)
- Dashboard views → Guard workflow: runs assessment (evidence: `src/mirsad/dashboard/app.py`)
- Dashboard views → Assessment ledger: records verdict (evidence: `src/mirsad/dashboard/app.py`)
- Dashboard views → Ring detection: serves ring view
- Web console → Compliance view: offers compliance view (evidence: `frontend/src/App.tsx`)
