# its-varun-2/trust-flow architecture

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

- Interactive diagram: https://gitdiagram.com/its-varun-2/trust-flow
- Repository: https://github.com/its-varun-2/trust-flow

## Overview

TrustFlow is an adaptive fraud-protection experience for safer beneficiary setup and transfers. A user signs in, manages trusted contacts and payees, then starts a transfer that is risk-evaluated and routed into low-, medium-, or high-risk handling; high-risk handling can require security answers or nominee approval and dispatch an alert. The frontend also provides account/security views, onboarding, simulation, and English/Hindi/Tamil translations. The README documents SMS/social-engineering analysis and caller-ID guidance, but the supplied tree does not identify their implementation. Backend and unsampled UI links are included only where the index or README supports them.

Main entry points: [`src/App.tsx`](https://github.com/its-varun-2/trust-flow/blob/main/src/App.tsx) (Application shell), [`src/components/transfer/TransferModal.tsx`](https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/TransferModal.tsx) (Transfer entry), [`server/src/app.ts`](https://github.com/its-varun-2/trust-flow/blob/main/server/src/app.ts) (API router), [`src/context/TrustFlowContext.tsx`](https://github.com/its-varun-2/trust-flow/blob/main/src/context/TrustFlowContext.tsx) (Application state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_app["Application shell<br/>[App.tsx]"]
  node_login["Sign-in<br/>[LoginPage.tsx]"]
  node_dashboard["Dashboard"]
  node_account["Account overview"]
  node_beneficiaries["Beneficiary list"]
  node_payee_form["Add beneficiary<br/>[AddPayeeModal.tsx]"]
  node_onboarding["Trusted contact setup"]
  node_simulator["Risk simulator<br/>[SimulatorBar.tsx]"]
  node_debug["API activity panel<br/>[DebugPanel.tsx]"]
end

subgraph group_protection["Transfer protection"]
  node_transfer["Transfer entry<br/>[TransferModal.tsx]"]
  node_risk_flow["Risk evaluation hook<br/>[useRiskEvaluate.ts]"]
  node_risk_api["Risk API client<br/>[riskApi.ts]"]
  node_risk_engine["Risk scoring<br/>[riskEngine.ts]"]
  node_low_flow["Low-risk handling<br/>[LowRiskFlow.tsx]"]
  node_medium_flow["Medium-risk handling<br/>[MediumRiskFlow.tsx]"]
  node_high_flow["High-risk verification"]
  node_alert_client["Alert dispatch client<br/>[alertService.ts]"]
  node_payee_verify["Payee verification hook<br/>[usePayeeVerify.ts]"]
  node_payee_api["Payee API client<br/>[payeeApi.ts]"]
  node_safety_guidance["Scam-safety guidance"]
end

subgraph group_backend["API services"]
  node_risk_routes["Risk endpoint<br/>[risk.ts]"]
  node_alert_routes["Alert endpoint<br/>[alerts.ts]"]
  node_alert_service["Alert service<br/>[alertService.ts]"]
  node_payee_routes["Payee endpoint<br/>[payee.ts]"]
  node_payee_service["Payee verification<br/>[payeeService.ts]"]
  node_auth_routes["Authentication endpoint<br/>[auth.ts]"]
  node_auth_service["Authentication service<br/>[authService.ts]"]
  node_auth_middleware["Token middleware<br/>[auth.ts]"]
  node_api_app["API router<br/>[app.ts]"]
  node_api_client["HTTP client<br/>[client.ts]"]
end

subgraph group_shared["Shared state and language"]
  node_state[("Application state")]
  node_translations["Translations<br/>[index.ts]"]
end

node_user(("Banking user"))

node_user -->|"uses"| node_app
node_app -->|"reads state"| node_state
node_app -->|"shows when signed out"| node_login
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_account
node_app -->|"renders"| node_beneficiaries
node_app -->|"opens"| node_transfer
node_app -->|"renders"| node_onboarding
node_app -->|"renders"| node_simulator
node_app -->|"renders"| node_debug
node_beneficiaries -->|"opens"| node_payee_form
node_payee_form -->|"uses"| node_payee_verify
node_payee_verify -->|"calls"| node_payee_api
node_payee_api -->|"sends requests"| node_api_client
node_transfer -->|"evaluates risk"| node_risk_flow
node_risk_flow -->|"calls"| node_risk_api
node_risk_api -->|"sends requests"| node_api_client
node_risk_flow -->|"updates result and step"| node_state
node_transfer -->|"renders"| node_low_flow
node_transfer -->|"renders"| node_medium_flow
node_transfer -->|"renders"| node_high_flow
node_high_flow -->|"dispatches alert"| node_alert_client
node_alert_client -->|"sends requests"| node_api_client
node_api_client -.->|"calls API"| node_api_app
node_api_app -->|"applies"| node_auth_middleware
node_api_app -->|"mounts"| node_auth_routes
node_api_app -->|"mounts"| node_risk_routes
node_api_app -->|"mounts"| node_payee_routes
node_api_app -->|"mounts"| node_alert_routes
node_auth_routes -->|"calls"| node_auth_service
node_auth_service -->|"signs token"| node_auth_middleware
node_risk_routes -->|"calls"| node_risk_engine
node_payee_routes -->|"calls"| node_payee_service
node_alert_routes -->|"calls"| node_alert_service
node_login -->|"updates session"| node_state
node_onboarding -->|"updates preferences"| node_state
node_simulator -->|"sets test risk"| node_state
node_debug -->|"reads API activity"| node_state
node_dashboard -->|"uses text"| node_translations
node_transfer -->|"uses text"| node_translations
node_safety_guidance -->|"guides against scams"| node_user

click node_app "https://github.com/its-varun-2/trust-flow/blob/main/src/App.tsx"
click node_login "https://github.com/its-varun-2/trust-flow/blob/main/src/components/auth/LoginPage.tsx"
click node_dashboard "https://github.com/its-varun-2/trust-flow/blob/main/src/components/desktop/DashboardLayout.tsx"
click node_account "https://github.com/its-varun-2/trust-flow/blob/main/src/components/shell/AccountOverview.tsx"
click node_beneficiaries "https://github.com/its-varun-2/trust-flow/blob/main/src/components/payee/BeneficiaryList.tsx"
click node_payee_form "https://github.com/its-varun-2/trust-flow/blob/main/src/components/payee/AddPayeeModal.tsx"
click node_onboarding "https://github.com/its-varun-2/trust-flow/blob/main/src/components/onboarding/OnboardingModal.tsx"
click node_simulator "https://github.com/its-varun-2/trust-flow/blob/main/src/components/simulator/SimulatorBar.tsx"
click node_debug "https://github.com/its-varun-2/trust-flow/blob/main/src/components/debug/DebugPanel.tsx"
click node_transfer "https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/TransferModal.tsx"
click node_risk_flow "https://github.com/its-varun-2/trust-flow/blob/main/src/hooks/useRiskEvaluate.ts"
click node_risk_api "https://github.com/its-varun-2/trust-flow/blob/main/src/api/riskApi.ts"
click node_risk_engine "https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/riskEngine.ts"
click node_risk_routes "https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/risk.ts"
click node_low_flow "https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/LowRiskFlow.tsx"
click node_medium_flow "https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/MediumRiskFlow.tsx"
click node_high_flow "https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/HighRiskVerificationModal.tsx"
click node_alert_client "https://github.com/its-varun-2/trust-flow/blob/main/src/api/alertService.ts"
click node_alert_routes "https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/alerts.ts"
click node_alert_service "https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/alertService.ts"
click node_payee_verify "https://github.com/its-varun-2/trust-flow/blob/main/src/hooks/usePayeeVerify.ts"
click node_payee_api "https://github.com/its-varun-2/trust-flow/blob/main/src/api/payeeApi.ts"
click node_payee_routes "https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/payee.ts"
click node_payee_service "https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/payeeService.ts"
click node_auth_routes "https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/auth.ts"
click node_auth_service "https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/authService.ts"
click node_auth_middleware "https://github.com/its-varun-2/trust-flow/blob/main/server/src/middleware/auth.ts"
click node_api_app "https://github.com/its-varun-2/trust-flow/blob/main/server/src/app.ts"
click node_api_client "https://github.com/its-varun-2/trust-flow/blob/main/src/api/client.ts"
click node_state "https://github.com/its-varun-2/trust-flow/blob/main/src/context/TrustFlowContext.tsx"
click node_translations "https://github.com/its-varun-2/trust-flow/blob/main/src/i18n/index.ts"

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_app,node_login,node_dashboard,node_account,node_beneficiaries,node_payee_form,node_onboarding,node_simulator,node_debug,node_user toneBlue
class node_transfer,node_risk_flow,node_risk_api,node_risk_engine,node_low_flow,node_medium_flow,node_high_flow,node_alert_client,node_payee_verify,node_payee_api,node_safety_guidance toneAmber
class node_risk_routes,node_alert_routes,node_alert_service,node_payee_routes,node_payee_service,node_auth_routes,node_auth_service,node_auth_middleware,node_api_app,node_api_client toneMint
class node_state,node_translations toneRose
```

## Components

### User experience

- [Application shell](https://github.com/its-varun-2/trust-flow/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in](https://github.com/its-varun-2/trust-flow/blob/main/src/components/auth/LoginPage.tsx): `src/components/auth/LoginPage.tsx`
- [Dashboard](https://github.com/its-varun-2/trust-flow/blob/main/src/components/desktop/DashboardLayout.tsx): `src/components/desktop/DashboardLayout.tsx`
- [Account overview](https://github.com/its-varun-2/trust-flow/blob/main/src/components/shell/AccountOverview.tsx): `src/components/shell/AccountOverview.tsx`
- [Beneficiary list](https://github.com/its-varun-2/trust-flow/blob/main/src/components/payee/BeneficiaryList.tsx): `src/components/payee/BeneficiaryList.tsx`
- [Add beneficiary](https://github.com/its-varun-2/trust-flow/blob/main/src/components/payee/AddPayeeModal.tsx): `src/components/payee/AddPayeeModal.tsx`
- [Trusted contact setup](https://github.com/its-varun-2/trust-flow/blob/main/src/components/onboarding/OnboardingModal.tsx): `src/components/onboarding/OnboardingModal.tsx`
- [Risk simulator](https://github.com/its-varun-2/trust-flow/blob/main/src/components/simulator/SimulatorBar.tsx): `src/components/simulator/SimulatorBar.tsx`
- [API activity panel](https://github.com/its-varun-2/trust-flow/blob/main/src/components/debug/DebugPanel.tsx): `src/components/debug/DebugPanel.tsx`

### Transfer protection

- [Transfer entry](https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/TransferModal.tsx): `src/components/transfer/TransferModal.tsx`
- [Risk evaluation hook](https://github.com/its-varun-2/trust-flow/blob/main/src/hooks/useRiskEvaluate.ts): `src/hooks/useRiskEvaluate.ts`
- [Risk API client](https://github.com/its-varun-2/trust-flow/blob/main/src/api/riskApi.ts): `src/api/riskApi.ts`
- [Risk scoring](https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/riskEngine.ts): `server/src/services/riskEngine.ts`
- [Low-risk handling](https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/LowRiskFlow.tsx): `src/components/transfer/LowRiskFlow.tsx`
- [Medium-risk handling](https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/MediumRiskFlow.tsx): `src/components/transfer/MediumRiskFlow.tsx`
- [High-risk verification](https://github.com/its-varun-2/trust-flow/blob/main/src/components/transfer/HighRiskVerificationModal.tsx): `src/components/transfer/HighRiskVerificationModal.tsx`
- [Alert dispatch client](https://github.com/its-varun-2/trust-flow/blob/main/src/api/alertService.ts): `src/api/alertService.ts`
- [Payee verification hook](https://github.com/its-varun-2/trust-flow/blob/main/src/hooks/usePayeeVerify.ts): `src/hooks/usePayeeVerify.ts`
- [Payee API client](https://github.com/its-varun-2/trust-flow/blob/main/src/api/payeeApi.ts): `src/api/payeeApi.ts`
- **Scam-safety guidance**

### API services

- [Risk endpoint](https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/risk.ts): `server/src/routes/risk.ts`
- [Alert endpoint](https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/alerts.ts): `server/src/routes/alerts.ts`
- [Alert service](https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/alertService.ts): `server/src/services/alertService.ts`
- [Payee endpoint](https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/payee.ts): `server/src/routes/payee.ts`
- [Payee verification](https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/payeeService.ts): `server/src/services/payeeService.ts`
- [Authentication endpoint](https://github.com/its-varun-2/trust-flow/blob/main/server/src/routes/auth.ts): `server/src/routes/auth.ts`
- [Authentication service](https://github.com/its-varun-2/trust-flow/blob/main/server/src/services/authService.ts): `server/src/services/authService.ts`
- [Token middleware](https://github.com/its-varun-2/trust-flow/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`
- [API router](https://github.com/its-varun-2/trust-flow/blob/main/server/src/app.ts): `server/src/app.ts`
- [HTTP client](https://github.com/its-varun-2/trust-flow/blob/main/src/api/client.ts): `src/api/client.ts`

### Shared state and language

- [Application state](https://github.com/its-varun-2/trust-flow/blob/main/src/context/TrustFlowContext.tsx): `src/context/TrustFlowContext.tsx`
- [Translations](https://github.com/its-varun-2/trust-flow/blob/main/src/i18n/index.ts): `src/i18n/index.ts`

### Other components

- **Banking user**

## Connections

- Banking user → Application shell: uses (evidence: `src/App.tsx`)
- Application shell → Application state: reads state (evidence: `src/App.tsx`)
- Application shell → Sign-in: shows when signed out (evidence: `src/App.tsx`)
- Application shell → Dashboard: renders (evidence: `src/App.tsx`)
- Application shell → Account overview: renders (evidence: `src/App.tsx`)
- Application shell → Beneficiary list: renders (evidence: `src/App.tsx`)
- Application shell → Transfer entry: opens (evidence: `src/App.tsx`)
- Application shell → Trusted contact setup: renders (evidence: `src/App.tsx`)
- Application shell → Risk simulator: renders (evidence: `src/App.tsx`)
- Application shell → API activity panel: renders (evidence: `src/App.tsx`)
- Beneficiary list → Add beneficiary: opens (evidence: `src/components/payee/BeneficiaryList.tsx`)
- Add beneficiary → Payee verification hook: uses (evidence: `src/components/payee/AddPayeeModal.tsx`)
- Payee verification hook → Payee API client: calls (evidence: `src/hooks/usePayeeVerify.ts`)
- Payee API client → HTTP client: sends requests (evidence: `src/api/payeeApi.ts`)
- Transfer entry → Risk evaluation hook: evaluates risk (evidence: `src/components/transfer/TransferModal.tsx`)
- Risk evaluation hook → Risk API client: calls (evidence: `src/hooks/useRiskEvaluate.ts`)
- Risk API client → HTTP client: sends requests (evidence: `src/api/riskApi.ts`)
- Risk evaluation hook → Application state: updates result and step (evidence: `src/hooks/useRiskEvaluate.ts`)
- Transfer entry → Low-risk handling: renders (evidence: `src/components/transfer/TransferModal.tsx`)
- Transfer entry → Medium-risk handling: renders (evidence: `src/components/transfer/TransferModal.tsx`)
- Transfer entry → High-risk verification: renders (evidence: `src/components/transfer/TransferModal.tsx`)
- High-risk verification → Alert dispatch client: dispatches alert (evidence: `src/components/transfer/HighRiskVerificationModal.tsx`)
- Alert dispatch client → HTTP client: sends requests (evidence: `src/api/alertService.ts`)
- HTTP client → API router: calls API
- API router → Token middleware: applies (evidence: `server/src/app.ts`)
- API router → Authentication endpoint: mounts (evidence: `server/src/app.ts`)
- API router → Risk endpoint: mounts (evidence: `server/src/app.ts`)
- API router → Payee endpoint: mounts (evidence: `server/src/app.ts`)
- API router → Alert endpoint: mounts (evidence: `server/src/app.ts`)
- Authentication endpoint → Authentication service: calls (evidence: `server/src/routes/auth.ts`)
- Authentication service → Token middleware: signs token (evidence: `server/src/services/authService.ts`)
- Risk endpoint → Risk scoring: calls (evidence: `server/src/routes/risk.ts`)
- Payee endpoint → Payee verification: calls (evidence: `server/src/routes/payee.ts`)
- Alert endpoint → Alert service: calls (evidence: `server/src/routes/alerts.ts`)
- Sign-in → Application state: updates session (evidence: `src/components/auth/LoginPage.tsx`)
- Trusted contact setup → Application state: updates preferences (evidence: `src/components/onboarding/OnboardingModal.tsx`)
- Risk simulator → Application state: sets test risk (evidence: `src/components/simulator/SimulatorBar.tsx`)
- API activity panel → Application state: reads API activity (evidence: `src/components/debug/DebugPanel.tsx`)
- Dashboard → Translations: uses text (evidence: `src/components/desktop/DashboardLayout.tsx`)
- Transfer entry → Translations: uses text (evidence: `src/components/transfer/TransferModal.tsx`)
- Scam-safety guidance → Banking user: guides against scams (evidence: `README.md`)
