# arun-prasath-14/ai_loan_acceptance_and_analyze_risk architecture

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

- Interactive diagram: https://gitdiagram.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk
- Repository: https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk

## Overview

Loan-IQ combines a React applicant-facing interface with a Flask credit-risk and bank-policy service. The primary workflow collects an application, requests an underwriting assessment, and presents the decision, policy checks, and SHAP rationale; users can then ask policy questions with assessment context. A separate policy-assistant workflow uses hybrid FAISS/BM25 retrieval and RRF reranking over bank and regulatory manuals. The README documents several backend capabilities not fully visible in the sampled excerpts, so those links are cited to the README; unsampled API routing is shown as unverified.

Main entry points: [`app.py`](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py) (Flask service), [`src/App.jsx`](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/App.jsx) (Workspace router), [`src/services/api.js`](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/services/api.js) (API client), [`src/components/EvaluationResultTab.jsx`](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/EvaluationResultTab.jsx) (Decision and rationale)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Applicant interface"]
  node_react_app["Workspace router<br/>[App.jsx]"]
  node_overview["Overview and glossary<br/>[OverviewTab.jsx]"]
  node_application_form["Application form"]
  node_results["Decision and rationale"]
  node_policy_chat["Policy chat"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_underwriting["Credit assessment"]
  node_anomaly_rules["Sanity and hard rules<br/>[app.py]"]
  node_risk_scoring["Risk scoring<br/>[app.py]"]
  node_model_artifact["Stacking model<br/>[loan_model.pkl]"]
  node_preprocessor["Feature preprocessing<br/>[preprocessor.pkl]"]
  node_explanation["SHAP explanation<br/>[app.py]"]
  node_decision["Decision and recommendations<br/>[app.py]"]
end

subgraph group_policy["Policy intelligence"]
  node_hybrid_retrieval["Hybrid retrieval and RRF<br/>[app.py]"]
  node_policy_manuals["Bank and RBI manuals"]
  node_retrieval_indexes[("FAISS and BM25 indexes")]
  node_policy_answer["Policy response synthesis<br/>[app.py]"]
end

subgraph group_service["Application service"]
  node_flask["Flask service<br/>[app.py]"]
end

node_applicant(("Applicant"))

node_applicant -->|"uses"| node_react_app
node_react_app -->|"renders"| node_overview
node_react_app -->|"renders"| node_application_form
node_react_app -->|"renders"| node_results
node_react_app -->|"renders"| node_policy_chat
node_application_form -->|"submits"| node_api_client
node_api_client -.->|"requests assessment"| node_flask
node_policy_chat -->|"sends query"| node_api_client
node_api_client -.->|"requests chat"| node_flask
node_flask -->|"runs checks"| node_anomaly_rules
node_flask -->|"runs scoring"| node_risk_scoring
node_risk_scoring -->|"transforms features"| node_preprocessor
node_risk_scoring -->|"scores with"| node_model_artifact
node_flask -->|"generates rationale"| node_explanation
node_flask -->|"combines assessment"| node_decision
node_flask -->|"queries policies"| node_hybrid_retrieval
node_hybrid_retrieval -->|"searches"| node_retrieval_indexes
node_hybrid_retrieval -->|"retrieves passages"| node_policy_manuals
node_flask -->|"synthesizes answer"| node_policy_answer
node_hybrid_retrieval -->|"supplies context"| node_policy_answer
node_flask -.->|"returns assessment"| node_results
node_results -->|"starts follow-up"| node_policy_chat

click node_react_app "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/App.jsx"
click node_overview "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/OverviewTab.jsx"
click node_application_form "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/ApplicationFormTab.jsx"
click node_results "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/EvaluationResultTab.jsx"
click node_policy_chat "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/PolicyAssistantTab.jsx"
click node_api_client "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/services/api.js"
click node_flask "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py"
click node_anomaly_rules "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py"
click node_risk_scoring "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py"
click node_model_artifact "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/models/loan_model.pkl"
click node_preprocessor "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/models/preprocessor.pkl"
click node_explanation "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py"
click node_decision "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py"
click node_hybrid_retrieval "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py"
click node_policy_manuals "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/tree/main/knowledge_base"
click node_retrieval_indexes "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/tree/main/rag_index"
click node_policy_answer "https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.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_react_app,node_overview,node_application_form,node_results,node_policy_chat,node_api_client toneBlue
class node_anomaly_rules,node_risk_scoring,node_model_artifact,node_preprocessor,node_explanation,node_decision toneAmber
class node_hybrid_retrieval,node_policy_manuals,node_retrieval_indexes,node_policy_answer toneMint
class node_flask toneRose
class node_applicant toneIndigo
```

## Components

### Applicant interface

- [Workspace router](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/App.jsx): `src/App.jsx`
- [Overview and glossary](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/OverviewTab.jsx): `src/components/OverviewTab.jsx`
- [Application form](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/ApplicationFormTab.jsx): `src/components/ApplicationFormTab.jsx`
- [Decision and rationale](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/EvaluationResultTab.jsx): `src/components/EvaluationResultTab.jsx`
- [Policy chat](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/components/PolicyAssistantTab.jsx): `src/components/PolicyAssistantTab.jsx`
- [API client](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/src/services/api.js): `src/services/api.js`

### Credit assessment

- [Sanity and hard rules](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py): `app.py`
- [Risk scoring](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py): `app.py`
- [Stacking model](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/models/loan_model.pkl): `models/loan_model.pkl`
- [Feature preprocessing](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/models/preprocessor.pkl): `models/preprocessor.pkl`
- [SHAP explanation](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py): `app.py`
- [Decision and recommendations](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py): `app.py`

### Policy intelligence

- [Hybrid retrieval and RRF](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py): `app.py`
- [Bank and RBI manuals](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/tree/main/knowledge_base): `knowledge_base`
- [FAISS and BM25 indexes](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/tree/main/rag_index): `rag_index`
- [Policy response synthesis](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py): `app.py`

### Application service

- [Flask service](https://github.com/arun-prasath-14/ai_loan_acceptance_and_analyze_risk/blob/main/app.py): `app.py`

### Other components

- **Applicant**

## Connections

- Applicant → Workspace router: uses (evidence: `README.md`)
- Workspace router → Overview and glossary: renders (evidence: `src/App.jsx`)
- Workspace router → Application form: renders (evidence: `src/App.jsx`)
- Workspace router → Decision and rationale: renders (evidence: `src/App.jsx`)
- Workspace router → Policy chat: renders (evidence: `src/App.jsx`)
- Application form → API client: submits (evidence: `src/components/ApplicationFormTab.jsx`)
- API client → Flask service: requests assessment
- Policy chat → API client: sends query (evidence: `src/components/PolicyAssistantTab.jsx`)
- API client → Flask service: requests chat
- Flask service → Sanity and hard rules: runs checks (evidence: `app.py`)
- Flask service → Risk scoring: runs scoring (evidence: `app.py`)
- Risk scoring → Feature preprocessing: transforms features (evidence: `README.md`)
- Risk scoring → Stacking model: scores with (evidence: `README.md`)
- Flask service → SHAP explanation: generates rationale (evidence: `README.md`)
- Flask service → Decision and recommendations: combines assessment (evidence: `README.md`)
- Flask service → Hybrid retrieval and RRF: queries policies (evidence: `README.md`)
- Hybrid retrieval and RRF → FAISS and BM25 indexes: searches (evidence: `README.md`)
- Hybrid retrieval and RRF → Bank and RBI manuals: retrieves passages (evidence: `README.md`)
- Flask service → Policy response synthesis: synthesizes answer (evidence: `app.py`)
- Hybrid retrieval and RRF → Policy response synthesis: supplies context (evidence: `app.py`)
- Flask service → Decision and rationale: returns assessment
- Decision and rationale → Policy chat: starts follow-up (evidence: `src/components/EvaluationResultTab.jsx`)
