# captain-rage-rgb/raw_bank_sentients architecture

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

- Interactive diagram: https://gitdiagram.com/captain-rage-rgb/raw_bank_sentients
- Repository: https://github.com/captain-rage-rgb/raw_bank_sentients

## Overview

Rawbank Sentient is a fraud-intelligence platform with a command-centre dashboard and an investigation copilot. Analysts review operational KPIs and alerts, select a transaction for forensic drill-down, and can use the copilot to combine deterministic customer, device and beneficiary context with similar historical incidents. The backend exposes these capabilities through FastAPI; DuckDB analytics, retrieval and rule metadata form the principal internal layers. The source excerpts establish the backend calls and frontend fetches, but do not show all UI wiring or the full retrieval/cache lifecycle.

Main entry points: [`backend/copilot.py`](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/copilot.py) (Investigation context), [`backend/database.py`](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/database.py) (Command analytics), [`backend/main.py`](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/main.py) (HTTP endpoints), [`generate_data.py`](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/generate_data.py) (Synthetic data generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Analyst interface"]
  node_command_ui["Command centre<br/>[page.tsx]"]
  node_alert_view["Alert table<br/>[AlertsTable.tsx]"]
  node_kpi_view["KPI ribbon<br/>[KpiRibbon.tsx]"]
  node_chart_view["Analytics charts<br/>[ChartsGrid.tsx]"]
  node_investigation_view["Investigation drawer"]
  node_copilot_view["Copilot panel<br/>[CopilotPanel.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["Service API"]
  node_fastapi["HTTP endpoints<br/>[main.py]"]
end

subgraph group_analysis["Fraud analysis"]
  node_analytics["Command analytics<br/>[database.py]"]
  node_investigation["Investigation context<br/>[copilot.py]"]
  node_retrieval["Dual retrieval<br/>[retrieval.py]"]
  node_rule_catalog["Fraud rule catalog<br/>[rules_meta.py]"]
end

subgraph group_data["Canonical data"]
  node_knowledge_base["Canonical transactions"]
  node_ground_truth["Evaluation ground truth"]
  node_vector_cache[("Semantic index cache")]
  node_data_generator["Synthetic data generator<br/>[generate_data.py]"]
end

node_analyst(("Fraud analyst"))
node_external_llm{{"Groq LLM"}}

node_analyst -->|"uses"| node_command_ui
node_command_ui -->|"fetches data"| node_api_client
node_fastapi -->|"calls analytics"| node_analytics
node_fastapi -->|"routes copilot"| node_investigation
node_investigation -->|"queries context"| node_retrieval
node_investigation -->|"reads rules"| node_rule_catalog
node_analytics -->|"uses catalog"| node_rule_catalog
node_analytics -->|"queries data"| node_knowledge_base
node_investigation -.->|"reasons with"| node_external_llm
node_data_generator -->|"generates"| node_knowledge_base
node_data_generator -->|"generates"| node_ground_truth
node_retrieval -->|"caches index"| node_vector_cache

click node_command_ui "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/app/page.tsx"
click node_alert_view "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/AlertsTable.tsx"
click node_kpi_view "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/KpiRibbon.tsx"
click node_chart_view "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/ChartsGrid.tsx"
click node_investigation_view "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/InvestigationDrawer.tsx"
click node_copilot_view "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/CopilotPanel.tsx"
click node_api_client "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/lib/api.ts"
click node_fastapi "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/main.py"
click node_analytics "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/database.py"
click node_investigation "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/copilot.py"
click node_retrieval "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/retrieval.py"
click node_rule_catalog "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/rules_meta.py"
click node_knowledge_base "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/RAWBANK_SENTIENT_KB.csv"
click node_ground_truth "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/RAWBANK_SENTIENT_GROUND_TRUTH.csv"
click node_vector_cache "https://github.com/captain-rage-rgb/raw_bank_sentients/tree/main/backend/cache"
click node_data_generator "https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/generate_data.py"

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_command_ui,node_alert_view,node_kpi_view,node_chart_view,node_investigation_view,node_copilot_view,node_api_client toneBlue
class node_fastapi toneAmber
class node_analytics,node_investigation,node_retrieval,node_rule_catalog toneMint
class node_knowledge_base,node_ground_truth,node_vector_cache,node_data_generator toneRose
class node_analyst,node_external_llm toneIndigo
```

## Components

### Analyst interface

- [Command centre](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Alert table](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/AlertsTable.tsx): `frontend/src/components/AlertsTable.tsx`
- [KPI ribbon](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/KpiRibbon.tsx): `frontend/src/components/KpiRibbon.tsx`
- [Analytics charts](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/ChartsGrid.tsx): `frontend/src/components/ChartsGrid.tsx`
- [Investigation drawer](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/InvestigationDrawer.tsx): `frontend/src/components/InvestigationDrawer.tsx`
- [Copilot panel](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/components/CopilotPanel.tsx): `frontend/src/components/CopilotPanel.tsx`
- [API client](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Service API

- [HTTP endpoints](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/main.py): `backend/main.py`

### Fraud analysis

- [Command analytics](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/database.py): `backend/database.py`
- [Investigation context](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/copilot.py): `backend/copilot.py`
- [Dual retrieval](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/retrieval.py): `backend/retrieval.py`
- [Fraud rule catalog](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/backend/rules_meta.py): `backend/rules_meta.py`

### Canonical data

- [Canonical transactions](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/RAWBANK_SENTIENT_KB.csv): `RAWBANK_SENTIENT_KB.csv`
- [Evaluation ground truth](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/RAWBANK_SENTIENT_GROUND_TRUTH.csv): `RAWBANK_SENTIENT_GROUND_TRUTH.csv`
- [Semantic index cache](https://github.com/captain-rage-rgb/raw_bank_sentients/tree/main/backend/cache): `backend/cache`
- [Synthetic data generator](https://github.com/captain-rage-rgb/raw_bank_sentients/blob/main/generate_data.py): `generate_data.py`

### Other components

- **Fraud analyst**
- **Groq LLM**

## Connections

- Fraud analyst → Command centre: uses (evidence: `frontend/src/app/page.tsx`)
- Command centre → API client: fetches data (evidence: `frontend/src/app/page.tsx`)
- HTTP endpoints → Command analytics: calls analytics (evidence: `backend/main.py`)
- HTTP endpoints → Investigation context: routes copilot (evidence: `backend/main.py`)
- Investigation context → Dual retrieval: queries context (evidence: `backend/copilot.py`)
- Investigation context → Fraud rule catalog: reads rules (evidence: `backend/copilot.py`)
- Command analytics → Fraud rule catalog: uses catalog (evidence: `backend/database.py`)
- Command analytics → Canonical transactions: queries data (evidence: `backend/database.py`)
- Investigation context → Groq LLM: reasons with
- Synthetic data generator → Canonical transactions: generates (evidence: `generate_data.py`)
- Synthetic data generator → Evaluation ground truth: generates (evidence: `generate_data.py`)
- Dual retrieval → Semantic index cache: caches index (evidence: `backend/retrieval.py`)
