# sudeshnapathak/bank-onboarding-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/sudeshnapathak/bank-onboarding-copilot
- Repository: https://github.com/sudeshnapathak/bank-onboarding-copilot

## Overview

Bank Onboarding Copilot guides customers through savings-account intake, document upload and field confirmation, then prepares a case for human review; it does not make autonomous approval or rejection decisions. The graph includes the documented chat and review stages, OCR and rules, analyst workflow, security, persistence, and the customer/analyst frontend. Some agent and API internals were not excerpted, so their documented capabilities are shown without speculative implementation-level links.

Main entry points: [`backend/app/graphs/review.py`](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/graphs/review.py) (Review graph), [`backend/app/api/review.py`](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/api/review.py) (Analyst API), [`backend/app/agents`](https://github.com/sudeshnapathak/bank-onboarding-copilot/tree/main/backend/app/agents) (Chat agents), [`backend/app/ocr/pipeline.py`](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/ocr/pipeline.py) (Document pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer_ui["Customer experience"]
  node_web_app["Role-based app<br/>[App.tsx]"]
  node_customer_apply["Chat and upload<br/>[Apply.tsx]"]
  node_analyst_views["Queue and case views<br/>[ReviewQueue.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
end

subgraph group_intake["Chat and intake"]
  node_chat_graph["Chat graph<br/>[chat.py]"]
  node_chat_agents["Chat agents"]
  node_turn_service["Turn handling<br/>[turns.py]"]
  node_case_flow["Case flow<br/>[flow.py]"]
  node_form_schema["Form schema<br/>[form_schema.py]"]
  node_rag["Guidance retrieval<br/>[retriever.py]"]
end

subgraph group_evidence["Documents and rules"]
  node_document_pipeline["Document pipeline<br/>[pipeline.py]"]
  node_pdf_support["PDF handling<br/>[pdf.py]"]
  node_ocr_engine["OCR engines<br/>[engine.py]"]
  node_document_parsers["ID parsers"]
  node_rule_validation["Field validation<br/>[validation.py]"]
  node_rules_engine["Risk scoring<br/>[engine.py]"]
end

subgraph group_review["Analyst review"]
  node_review_graph["Review graph<br/>[review.py]"]
  node_review_api["Analyst API<br/>[review.py]"]
  node_decision_service["Human decision<br/>[decision.py]"]
  node_llm_service["LLM explanations<br/>[factory.py]"]
end

subgraph group_platform["Platform services"]
  node_api_routes["Backend API<br/>[main.py]"]
  node_security["Security controls"]
  node_encrypted_storage["Encrypted uploads<br/>[storage.py]"]
  node_audit_log[("Audit log<br/>[audit.py]")]
  node_case_database[("Case database<br/>[models.py]")]
end

node_customer(("Customer"))
node_analyst(("Analyst"))

node_customer -->|"uses"| node_web_app
node_analyst -->|"uses"| node_web_app
node_web_app -->|"routes customers"| node_customer_apply
node_web_app -->|"routes analysts"| node_analyst_views
node_customer_apply -->|"submits chat and uploads"| node_api_client
node_analyst_views -->|"requests review data"| node_api_client
node_api_client -->|"calls API"| node_api_routes
node_api_routes -.->|"handles customer turns"| node_chat_graph
node_chat_graph -->|"routes turns"| node_chat_agents
node_chat_agents -->|"uses case flow"| node_case_flow
node_chat_graph -.->|"processes turns"| node_turn_service
node_case_flow -->|"uses matching rules"| node_rules_engine
node_case_flow -->|"reads schema"| node_form_schema
node_chat_agents -.->|"answers guidance queries"| node_rag
node_chat_agents -.->|"processes uploads"| node_document_pipeline
node_document_pipeline -->|"reads PDF input"| node_pdf_support
node_document_pipeline -->|"runs OCR"| node_ocr_engine
node_document_pipeline -->|"parses extracted text"| node_document_parsers
node_review_graph -->|"validates submitted evidence"| node_rule_validation
node_review_graph -->|"scores flags"| node_rules_engine
node_review_graph -->|"summarizes readiness"| node_llm_service
node_review_api -->|"starts and resumes review"| node_review_graph
node_review_graph -->|"applies analyst decision"| node_decision_service
node_review_api -.->|"records decision"| node_decision_service
node_review_api -->|"loads document images"| node_encrypted_storage
node_encrypted_storage -->|"encrypts uploads"| node_security
node_review_graph -->|"records review events"| node_audit_log
node_review_api -->|"records access"| node_audit_log
node_decision_service -->|"records decisions"| node_audit_log
node_audit_log -->|"persists audit entries"| node_case_database
node_review_api -->|"reads case and review data"| node_case_database
node_review_graph -->|"persists analysis"| node_case_database

click node_web_app "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/App.tsx"
click node_customer_apply "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/pages/Apply.tsx"
click node_analyst_views "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/pages/ReviewQueue.tsx"
click node_api_client "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/api/client.ts"
click node_api_routes "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/main.py"
click node_chat_graph "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/graphs/chat.py"
click node_chat_agents "https://github.com/sudeshnapathak/bank-onboarding-copilot/tree/main/backend/app/agents"
click node_turn_service "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/turns.py"
click node_case_flow "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/flow.py"
click node_form_schema "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/form_schema.py"
click node_document_pipeline "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/ocr/pipeline.py"
click node_pdf_support "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/ocr/pdf.py"
click node_ocr_engine "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/ocr/engine.py"
click node_document_parsers "https://github.com/sudeshnapathak/bank-onboarding-copilot/tree/main/backend/app/ocr/parsers"
click node_rule_validation "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/rules/validation.py"
click node_rules_engine "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/rules/engine.py"
click node_review_graph "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/graphs/review.py"
click node_review_api "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/api/review.py"
click node_decision_service "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/decision.py"
click node_llm_service "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/llm/factory.py"
click node_rag "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/rag/retriever.py"
click node_security "https://github.com/sudeshnapathak/bank-onboarding-copilot/tree/main/backend/app/security"
click node_encrypted_storage "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/storage.py"
click node_audit_log "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/audit.py"
click node_case_database "https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/models.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_web_app,node_customer_apply,node_analyst_views,node_api_client toneBlue
class node_chat_graph,node_chat_agents,node_turn_service,node_case_flow,node_form_schema,node_rag toneAmber
class node_document_pipeline,node_pdf_support,node_ocr_engine,node_document_parsers,node_rule_validation,node_rules_engine toneMint
class node_review_graph,node_review_api,node_decision_service,node_llm_service toneRose
class node_api_routes,node_security,node_encrypted_storage,node_audit_log,node_case_database,node_customer,node_analyst toneIndigo
```

## Components

### Customer experience

- [Role-based app](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat and upload](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/pages/Apply.tsx): `frontend/src/pages/Apply.tsx`
- [Queue and case views](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/pages/ReviewQueue.tsx): `frontend/src/pages/ReviewQueue.tsx`
- [API client](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### Chat and intake

- [Chat graph](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/graphs/chat.py): `backend/app/graphs/chat.py`
- [Chat agents](https://github.com/sudeshnapathak/bank-onboarding-copilot/tree/main/backend/app/agents): `backend/app/agents`
- [Turn handling](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/turns.py): `backend/app/services/turns.py`
- [Case flow](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/flow.py): `backend/app/services/flow.py`
- [Form schema](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/form_schema.py): `backend/app/services/form_schema.py`
- [Guidance retrieval](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/rag/retriever.py): `backend/app/rag/retriever.py`

### Documents and rules

- [Document pipeline](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/ocr/pipeline.py): `backend/app/ocr/pipeline.py`
- [PDF handling](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/ocr/pdf.py): `backend/app/ocr/pdf.py`
- [OCR engines](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/ocr/engine.py): `backend/app/ocr/engine.py`
- [ID parsers](https://github.com/sudeshnapathak/bank-onboarding-copilot/tree/main/backend/app/ocr/parsers): `backend/app/ocr/parsers`
- [Field validation](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/rules/validation.py): `backend/app/rules/validation.py`
- [Risk scoring](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/rules/engine.py): `backend/app/rules/engine.py`

### Analyst review

- [Review graph](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/graphs/review.py): `backend/app/graphs/review.py`
- [Analyst API](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/api/review.py): `backend/app/api/review.py`
- [Human decision](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/decision.py): `backend/app/services/decision.py`
- [LLM explanations](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/llm/factory.py): `backend/app/llm/factory.py`

### Platform services

- [Backend API](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Security controls](https://github.com/sudeshnapathak/bank-onboarding-copilot/tree/main/backend/app/security): `backend/app/security`
- [Encrypted uploads](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/storage.py): `backend/app/services/storage.py`
- [Audit log](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/services/audit.py): `backend/app/services/audit.py`
- [Case database](https://github.com/sudeshnapathak/bank-onboarding-copilot/blob/main/backend/app/models.py): `backend/app/models.py`

### Other components

- **Customer**
- **Analyst**

## Connections

- Customer → Role-based app: uses (evidence: `README.md`)
- Analyst → Role-based app: uses (evidence: `README.md`)
- Role-based app → Chat and upload: routes customers (evidence: `frontend/src/App.tsx`)
- Role-based app → Queue and case views: routes analysts (evidence: `frontend/src/App.tsx`)
- Chat and upload → API client: submits chat and uploads (evidence: `frontend/src/pages/Apply.tsx`)
- Queue and case views → API client: requests review data (evidence: `frontend/src/pages/ReviewQueue.tsx`)
- API client → Backend API: calls API (evidence: `frontend/src/api/client.ts`)
- Backend API → Chat graph: handles customer turns (evidence: `README.md`)
- Chat graph → Chat agents: routes turns (evidence: `README.md`)
- Chat agents → Case flow: uses case flow (evidence: `backend/app/agents/router.py`)
- Chat graph → Turn handling: processes turns
- Case flow → Risk scoring: uses matching rules (evidence: `backend/app/services/flow.py`)
- Case flow → Form schema: reads schema (evidence: `backend/app/services/flow.py`)
- Chat agents → Guidance retrieval: answers guidance queries (evidence: `README.md`)
- Chat agents → Document pipeline: processes uploads (evidence: `README.md`)
- Document pipeline → PDF handling: reads PDF input (evidence: `backend/app/ocr/pipeline.py`)
- Document pipeline → OCR engines: runs OCR (evidence: `backend/app/ocr/pipeline.py`)
- Document pipeline → ID parsers: parses extracted text (evidence: `backend/app/ocr/pipeline.py`)
- Review graph → Field validation: validates submitted evidence (evidence: `backend/app/graphs/review.py`)
- Review graph → Risk scoring: scores flags (evidence: `backend/app/graphs/review.py`)
- Review graph → LLM explanations: summarizes readiness (evidence: `backend/app/graphs/review.py`)
- Analyst API → Review graph: starts and resumes review (evidence: `backend/app/api/review.py`)
- Review graph → Human decision: applies analyst decision (evidence: `backend/app/graphs/review.py`)
- Analyst API → Human decision: records decision (evidence: `backend/app/api/review.py`)
- Analyst API → Encrypted uploads: loads document images (evidence: `backend/app/api/review.py`)
- Encrypted uploads → Security controls: encrypts uploads (evidence: `backend/app/services/storage.py`)
- Review graph → Audit log: records review events (evidence: `backend/app/graphs/review.py`)
- Analyst API → Audit log: records access (evidence: `backend/app/api/review.py`)
- Human decision → Audit log: records decisions (evidence: `backend/app/services/decision.py`)
- Audit log → Case database: persists audit entries (evidence: `backend/app/services/audit.py`)
- Analyst API → Case database: reads case and review data (evidence: `backend/app/api/review.py`)
- Review graph → Case database: persists analysis (evidence: `backend/app/graphs/review.py`)
