# codewithrishabh09/borrower-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/codewithrishabh09/borrower-copilot
- Repository: https://github.com/codewithrishabh09/borrower-copilot

## Overview

Borrower Copilot is a client-side Indian loan self-assessment tool. A borrower starts an assessment, answers required and profile-dependent questions, and receives a rules-based analysis with borrowing guidance, affordability, rate/APR, and stress-test results; results also provide recommendations and a lender-facing Negotiation Card. The graph follows the documented workflow and source-indexed calls. Some page behavior and calculation details are unsampled, so uncertain links are omitted.

Main entry points: [`src/App.tsx`](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/App.tsx) (App flow), [`src/engine/borrowerAnalyzer.ts`](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/engine/borrowerAnalyzer.ts) (Borrower analyzer), [`src/pages/Results.tsx`](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Results.tsx) (Results screen), [`src/pages/Questions.tsx`](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Questions.tsx) (Question screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Assessment experience"]
  node_app["App flow<br/>[App.tsx]"]
  node_home["Home screen<br/>[Home.tsx]"]
  node_question_screen["Question screen<br/>[Questions.tsx]"]
  node_analysis_screen["Analysis screen"]
  node_storage_hook["Session state<br/>[useLocalStorage.ts]"]
end

subgraph group_inputs["Borrower inputs"]
  node_question_flow["Question flow<br/>[questionFlow.ts]"]
  node_must_questions["Required questions<br/>[mustQuestions.ts]"]
  node_adaptive_questions["Adaptive questions"]
  node_question_card["Question controls<br/>[QuestionCard.tsx]"]
  node_borrower_profile["Borrower profile<br/>[borrower.ts]"]
end

subgraph group_analysis["Financial analysis"]
  node_analyzer["Borrower analyzer"]
  node_calculators["Financial calculators"]
  node_decision_rules["Borrowing decision"]
  node_eligibility_rules["Eligibility rules<br/>[eligibility.ts]"]
  node_rate_rules["Rate rules<br/>[interestRate.ts]"]
  node_negotiation_rules["Negotiation strategy<br/>[negotiation.ts]"]
  node_loan_products["Loan assumptions<br/>[loanProducts.ts]"]
end

subgraph group_outputs["Results and guidance"]
  node_results["Results screen<br/>[Results.tsx]"]
  node_recommendations["Recommendations"]
  node_summary["Assessment summary"]
  node_plan_comparison["Plan comparison<br/>[PlanComparison.tsx]"]
  node_negotiation_card["Negotiation Card"]
end

node_borrower(("Borrower"))

node_borrower -->|"starts assessment"| node_home
node_app -->|"shows"| node_home
node_home -->|"starts"| node_app
node_app -->|"shows"| node_question_screen
node_question_screen -->|"requests questions"| node_question_flow
node_question_flow -->|"loads"| node_must_questions
node_question_flow -->|"loads"| node_adaptive_questions
node_question_screen -->|"renders"| node_question_card
node_question_screen -->|"submits profile"| node_app
node_app -->|"stores"| node_borrower_profile
node_app -->|"persists state with"| node_storage_hook
node_storage_hook -->|"reads and writes browser storage"| node_borrower
node_app -->|"shows"| node_analysis_screen
node_app -->|"analyzes profile with"| node_analyzer
node_analyzer -->|"calls calculations"| node_calculators
node_analyzer -->|"evaluates decision with"| node_decision_rules
node_analyzer -->|"checks eligibility with"| node_eligibility_rules
node_analyzer -->|"estimates rate with"| node_rate_rules
node_analyzer -->|"generates strategy with"| node_negotiation_rules
node_analyzer -->|"loads assumptions from"| node_loan_products
node_app -->|"shows analysis"| node_results
node_results -->|"generates"| node_recommendations
node_results -->|"renders"| node_summary
node_results -->|"renders"| node_plan_comparison
node_results -->|"renders"| node_negotiation_card

click node_app "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/App.tsx"
click node_home "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Home.tsx"
click node_question_screen "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Questions.tsx"
click node_analysis_screen "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/AnalyzingScreen.tsx"
click node_storage_hook "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/hooks/useLocalStorage.ts"
click node_question_flow "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/engine/questionFlow.ts"
click node_must_questions "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/questions/mustQuestions.ts"
click node_adaptive_questions "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/questions/adaptiveQuestions.ts"
click node_question_card "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/QuestionCard.tsx"
click node_borrower_profile "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/types/borrower.ts"
click node_analyzer "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/engine/borrowerAnalyzer.ts"
click node_calculators "https://github.com/codewithrishabh09/borrower-copilot/tree/main/src/engine"
click node_decision_rules "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/borrowingDecision.ts"
click node_eligibility_rules "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/eligibility.ts"
click node_rate_rules "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/interestRate.ts"
click node_negotiation_rules "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/negotiation.ts"
click node_loan_products "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/data/loanProducts.ts"
click node_results "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Results.tsx"
click node_recommendations "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/engine/recommendationEngine.ts"
click node_summary "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/AssessmentSummary.tsx"
click node_plan_comparison "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/PlanComparison.tsx"
click node_negotiation_card "https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/NegotiationCard.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_app,node_home,node_question_screen,node_analysis_screen,node_storage_hook toneBlue
class node_question_flow,node_must_questions,node_adaptive_questions,node_question_card,node_borrower_profile toneAmber
class node_analyzer,node_calculators,node_decision_rules,node_eligibility_rules,node_rate_rules,node_negotiation_rules,node_loan_products toneMint
class node_results,node_recommendations,node_summary,node_plan_comparison,node_negotiation_card toneRose
class node_borrower toneIndigo
```

## Components

### Assessment experience

- [App flow](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/App.tsx): `src/App.tsx`
- [Home screen](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Home.tsx): `src/pages/Home.tsx`
- [Question screen](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Questions.tsx): `src/pages/Questions.tsx`
- [Analysis screen](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/AnalyzingScreen.tsx): `src/pages/AnalyzingScreen.tsx`
- [Session state](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/hooks/useLocalStorage.ts): `src/hooks/useLocalStorage.ts`

### Borrower inputs

- [Question flow](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/engine/questionFlow.ts): `src/engine/questionFlow.ts`
- [Required questions](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/questions/mustQuestions.ts): `src/questions/mustQuestions.ts`
- [Adaptive questions](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/questions/adaptiveQuestions.ts): `src/questions/adaptiveQuestions.ts`
- [Question controls](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/QuestionCard.tsx): `src/components/QuestionCard.tsx`
- [Borrower profile](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/types/borrower.ts): `src/types/borrower.ts`

### Financial analysis

- [Borrower analyzer](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/engine/borrowerAnalyzer.ts): `src/engine/borrowerAnalyzer.ts`
- [Financial calculators](https://github.com/codewithrishabh09/borrower-copilot/tree/main/src/engine): `src/engine`
- [Borrowing decision](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/borrowingDecision.ts): `src/rules/borrowingDecision.ts`
- [Eligibility rules](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/eligibility.ts): `src/rules/eligibility.ts`
- [Rate rules](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/interestRate.ts): `src/rules/interestRate.ts`
- [Negotiation strategy](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/rules/negotiation.ts): `src/rules/negotiation.ts`
- [Loan assumptions](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/data/loanProducts.ts): `src/data/loanProducts.ts`

### Results and guidance

- [Results screen](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/pages/Results.tsx): `src/pages/Results.tsx`
- [Recommendations](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/engine/recommendationEngine.ts): `src/engine/recommendationEngine.ts`
- [Assessment summary](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/AssessmentSummary.tsx): `src/components/AssessmentSummary.tsx`
- [Plan comparison](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/PlanComparison.tsx): `src/components/PlanComparison.tsx`
- [Negotiation Card](https://github.com/codewithrishabh09/borrower-copilot/blob/main/src/components/NegotiationCard.tsx): `src/components/NegotiationCard.tsx`

### Other components

- **Borrower**

## Connections

- Borrower → Home screen: starts assessment (evidence: `README.md`)
- App flow → Home screen: shows (evidence: `src/App.tsx`)
- Home screen → App flow: starts (evidence: `src/App.tsx`)
- App flow → Question screen: shows (evidence: `src/App.tsx`)
- Question screen → Question flow: requests questions (evidence: `src/pages/Questions.tsx`)
- Question flow → Required questions: loads (evidence: `src/engine/questionFlow.ts`)
- Question flow → Adaptive questions: loads (evidence: `src/engine/questionFlow.ts`)
- Question screen → Question controls: renders (evidence: `src/pages/Questions.tsx`)
- Question screen → App flow: submits profile (evidence: `src/App.tsx`)
- App flow → Borrower profile: stores (evidence: `src/App.tsx`)
- App flow → Session state: persists state with (evidence: `src/App.tsx`)
- Session state → Borrower: reads and writes browser storage (evidence: `src/hooks/useLocalStorage.ts`)
- App flow → Analysis screen: shows (evidence: `src/App.tsx`)
- App flow → Borrower analyzer: analyzes profile with (evidence: `src/App.tsx`)
- Borrower analyzer → Financial calculators: calls calculations (evidence: `src/engine/borrowerAnalyzer.ts`)
- Borrower analyzer → Borrowing decision: evaluates decision with (evidence: `src/engine/borrowerAnalyzer.ts`)
- Borrower analyzer → Eligibility rules: checks eligibility with (evidence: `src/engine/borrowerAnalyzer.ts`)
- Borrower analyzer → Rate rules: estimates rate with (evidence: `src/engine/borrowerAnalyzer.ts`)
- Borrower analyzer → Negotiation strategy: generates strategy with (evidence: `src/engine/borrowerAnalyzer.ts`)
- Borrower analyzer → Loan assumptions: loads assumptions from (evidence: `src/engine/borrowerAnalyzer.ts`)
- App flow → Results screen: shows analysis (evidence: `src/App.tsx`)
- Results screen → Recommendations: generates (evidence: `src/pages/Results.tsx`)
- Results screen → Assessment summary: renders (evidence: `src/pages/Results.tsx`)
- Results screen → Plan comparison: renders (evidence: `src/pages/Results.tsx`)
- Results screen → Negotiation Card: renders (evidence: `src/pages/Results.tsx`)
