# kandatiranjithkumarreddy/borrower-copilot architecture

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

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

## Overview

Borrower Copilot is a client-side loan self-assessment and negotiation aid. A borrower starts on the landing page, enters a profile and loan details in the adaptive questionnaire, and the app passes that input to a deterministic assessment engine. The engine derives affordability, loan amounts, rates, EMI/APR, stress resilience, confidence, and a borrowing recommendation, then builds negotiation guidance for results presentation. The README documents these capabilities; some UI and engine modules were not sampled, so their internal links are shown only where the excerpts or README support them.

Main entry points: [`src/engine/index.ts`](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/index.ts) (Assessment engine), [`src/App.tsx`](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/App.tsx) (Screen coordinator), [`src/engine/recommendation.ts`](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/recommendation.ts) (Borrow recommendation), [`src/components/LandingPage.tsx`](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/LandingPage.tsx) (Landing page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Borrower experience"]
  node_landing["Landing page<br/>[LandingPage.tsx]"]
  node_questionnaire["Adaptive questionnaire<br/>[Questionnaire.tsx]"]
  node_personas["Demo personas<br/>[personas.ts]"]
  node_app["Screen coordinator<br/>[App.tsx]"]
end

subgraph group_assessment["Assessment orchestration"]
  node_assessment_engine["Assessment engine<br/>[index.ts]"]
end

subgraph group_financial["Financial analysis"]
  node_affordability["Affordability<br/>[affordability.ts]"]
  node_rate_bands["Fair rate bands<br/>[interestRate.ts]"]
  node_apr["APR solver<br/>[apr.ts]"]
  node_emi["EMI calculations<br/>[emi.ts]"]
  node_loan_capacity["Loan capacity<br/>[loanCapacity.ts]"]
  node_stress_test["Stress testing<br/>[stressTest.ts]"]
end

subgraph group_guidance["Decision and guidance"]
  node_recommendation["Borrow recommendation<br/>[recommendation.ts]"]
  node_confidence["Confidence scoring<br/>[confidence.ts]"]
  node_negotiation["Negotiation guidance<br/>[negotiation.ts]"]
end

subgraph group_presentation["Results presentation"]
  node_results["Results page<br/>[ResultsPage.tsx]"]
  node_negotiation_card["Negotiation card"]
  node_formatters["Financial formatters<br/>[formatters.ts]"]
  node_brand["Brand header<br/>[HeaderBrand.tsx]"]
end

node_borrower(("Borrower"))

node_borrower -->|"opens"| node_landing
node_landing -->|"starts assessment"| node_app
node_landing -->|"loads personas"| node_personas
node_app -->|"renders"| node_landing
node_app -->|"renders"| node_questionnaire
node_app -->|"assesses input"| node_assessment_engine
node_app -->|"renders results"| node_results
node_questionnaire -.->|"submits input"| node_app
node_assessment_engine -->|"calculates capacity"| node_affordability
node_assessment_engine -->|"calculates rates"| node_rate_bands
node_assessment_engine -->|"calculates APR"| node_apr
node_assessment_engine -->|"calculates EMI"| node_emi
node_assessment_engine -->|"calculates amounts"| node_loan_capacity
node_assessment_engine -->|"tests resilience"| node_stress_test
node_assessment_engine -->|"evaluates decision"| node_recommendation
node_assessment_engine -->|"scores confidence"| node_confidence
node_assessment_engine -->|"generates points"| node_negotiation
node_recommendation -->|"uses affordability"| node_affordability
node_recommendation -->|"calculates payment"| node_emi
node_recommendation -->|"uses rate band"| node_rate_bands
node_recommendation -->|"checks safe amount"| node_loan_capacity
node_stress_test -->|"uses income"| node_affordability
node_stress_test -->|"recalculates EMI"| node_emi
node_stress_test -->|"tests rate shock"| node_rate_bands
node_results -.->|"presents card"| node_negotiation_card
node_negotiation_card -->|"formats values"| node_formatters
node_landing -->|"renders header"| node_brand
node_questionnaire -->|"renders header"| node_brand

click node_landing "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/LandingPage.tsx"
click node_questionnaire "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/Questionnaire.tsx"
click node_personas "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/utils/personas.ts"
click node_app "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/App.tsx"
click node_assessment_engine "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/index.ts"
click node_affordability "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/affordability.ts"
click node_rate_bands "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/interestRate.ts"
click node_apr "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/apr.ts"
click node_emi "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/emi.ts"
click node_loan_capacity "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/loanCapacity.ts"
click node_stress_test "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/stressTest.ts"
click node_recommendation "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/recommendation.ts"
click node_confidence "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/confidence.ts"
click node_negotiation "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/negotiation.ts"
click node_results "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/ResultsPage.tsx"
click node_negotiation_card "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/NegotiationCard.tsx"
click node_formatters "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/utils/formatters.ts"
click node_brand "https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/HeaderBrand.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_landing,node_questionnaire,node_personas,node_app toneBlue
class node_assessment_engine toneAmber
class node_affordability,node_rate_bands,node_apr,node_emi,node_loan_capacity,node_stress_test toneMint
class node_recommendation,node_confidence,node_negotiation toneRose
class node_results,node_negotiation_card,node_formatters,node_brand,node_borrower toneIndigo
```

## Components

### Borrower experience

- [Landing page](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/LandingPage.tsx): `src/components/LandingPage.tsx`
- [Adaptive questionnaire](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/Questionnaire.tsx): `src/components/Questionnaire.tsx`
- [Demo personas](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/utils/personas.ts): `src/utils/personas.ts`
- [Screen coordinator](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/App.tsx): `src/App.tsx`

### Assessment orchestration

- [Assessment engine](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/index.ts): `src/engine/index.ts`

### Financial analysis

- [Affordability](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/affordability.ts): `src/engine/affordability.ts`
- [Fair rate bands](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/interestRate.ts): `src/engine/interestRate.ts`
- [APR solver](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/apr.ts): `src/engine/apr.ts`
- [EMI calculations](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/emi.ts): `src/engine/emi.ts`
- [Loan capacity](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/loanCapacity.ts): `src/engine/loanCapacity.ts`
- [Stress testing](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/stressTest.ts): `src/engine/stressTest.ts`

### Decision and guidance

- [Borrow recommendation](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/recommendation.ts): `src/engine/recommendation.ts`
- [Confidence scoring](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/confidence.ts): `src/engine/confidence.ts`
- [Negotiation guidance](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/engine/negotiation.ts): `src/engine/negotiation.ts`

### Results presentation

- [Results page](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/ResultsPage.tsx): `src/components/ResultsPage.tsx`
- [Negotiation card](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/NegotiationCard.tsx): `src/components/NegotiationCard.tsx`
- [Financial formatters](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/utils/formatters.ts): `src/utils/formatters.ts`
- [Brand header](https://github.com/kandatiranjithkumarreddy/borrower-copilot/blob/main/src/components/HeaderBrand.tsx): `src/components/HeaderBrand.tsx`

### Other components

- **Borrower**

## Connections

- Borrower → Landing page: opens (evidence: `README.md`)
- Landing page → Screen coordinator: starts assessment (evidence: `src/App.tsx`)
- Landing page → Demo personas: loads personas (evidence: `src/components/LandingPage.tsx`)
- Screen coordinator → Landing page: renders (evidence: `src/App.tsx`)
- Screen coordinator → Adaptive questionnaire: renders (evidence: `src/App.tsx`)
- Screen coordinator → Assessment engine: assesses input (evidence: `src/App.tsx`)
- Screen coordinator → Results page: renders results (evidence: `src/App.tsx`)
- Adaptive questionnaire → Screen coordinator: submits input (evidence: `src/App.tsx`)
- Assessment engine → Affordability: calculates capacity (evidence: `src/engine/index.ts`)
- Assessment engine → Fair rate bands: calculates rates (evidence: `src/engine/index.ts`)
- Assessment engine → APR solver: calculates APR (evidence: `src/engine/index.ts`)
- Assessment engine → EMI calculations: calculates EMI (evidence: `src/engine/index.ts`)
- Assessment engine → Loan capacity: calculates amounts (evidence: `src/engine/index.ts`)
- Assessment engine → Stress testing: tests resilience (evidence: `src/engine/index.ts`)
- Assessment engine → Borrow recommendation: evaluates decision (evidence: `src/engine/index.ts`)
- Assessment engine → Confidence scoring: scores confidence (evidence: `src/engine/index.ts`)
- Assessment engine → Negotiation guidance: generates points (evidence: `src/engine/index.ts`)
- Borrow recommendation → Affordability: uses affordability (evidence: `src/engine/recommendation.ts`)
- Borrow recommendation → EMI calculations: calculates payment (evidence: `src/engine/recommendation.ts`)
- Borrow recommendation → Fair rate bands: uses rate band (evidence: `src/engine/recommendation.ts`)
- Borrow recommendation → Loan capacity: checks safe amount (evidence: `src/engine/recommendation.ts`)
- Stress testing → Affordability: uses income (evidence: `src/engine/stressTest.ts`)
- Stress testing → EMI calculations: recalculates EMI (evidence: `src/engine/stressTest.ts`)
- Stress testing → Fair rate bands: tests rate shock (evidence: `src/engine/stressTest.ts`)
- Results page → Negotiation card: presents card (evidence: `README.md`)
- Negotiation card → Financial formatters: formats values (evidence: `src/components/NegotiationCard.tsx`)
- Landing page → Brand header: renders header (evidence: `src/components/LandingPage.tsx`)
- Adaptive questionnaire → Brand header: renders header (evidence: `src/components/Questionnaire.tsx`)
