# mahirfaysal01/upay-financial-resilience-ai architecture

> Architecture diagram of the GitHub repository mahirfaysal01/upay-financial-resilience-ai, 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/mahirfaysal01/upay-financial-resilience-ai
- Repository: https://github.com/mahirfaysal01/upay-financial-resilience-ai

## Overview

upay Financial Resilience AI is a bilingual financial decision-support app. A customer selects a synthetic financial persona; the shared financial context builds their profile and forecast, risk, anomaly, recommendations, and savings data for dashboard and specialist views. Users can explore cash-flow forecasts, spending, savings goals, risk, and what-if scenarios, then get AI coaching or export data. The README also documents interventions and responsible-AI disclosures. Edges reflect shown imports, calls, and documented capabilities; unsampled page and server internals limit detail.

Main entry points: [`src/context/FinancialContext.tsx`](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/context/FinancialContext.tsx) (Financial context), [`src/components/AppLayout.tsx`](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/components/AppLayout.tsx) (Navigation and layout), [`src/App.tsx`](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/App.tsx) (App composition), [`src/pages/AICoach.tsx`](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/AICoach.tsx) (AI coach)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_app["App composition<br/>[App.tsx]"]
  node_layout["Navigation and layout<br/>[AppLayout.tsx]"]
  node_home["Persona selection<br/>[HomePage.tsx]"]
  node_dashboard["Financial dashboard<br/>[Dashboard.tsx]"]
  node_forecastpage["Cash-flow forecast"]
  node_riskpage["Financial risk<br/>[FinancialRisk.tsx]"]
  node_spending["Spending intelligence"]
  node_simulator["What-if simulator"]
  node_goals["Savings goals<br/>[SavingsGoals.tsx]"]
  node_profile["Profile overview"]
  node_coachpage["AI coach<br/>[AICoach.tsx]"]
end

subgraph group_state["Financial state"]
  node_financialstate["Financial context"]
  node_notifications["Notification context"]
  node_synthetic[("Synthetic ledger and personas<br/>[syntheticData.ts]")]
end

subgraph group_intelligence["Financial intelligence"]
  node_profileengine["Profile engineering"]
  node_forecastengine["Cash-flow forecasting"]
  node_riskengine["Shortage risk scoring"]
  node_anomalies["Spending anomaly detection"]
  node_recommendations["Intervention recommendations"]
  node_savingsengine["Savings planning"]
  node_simulationengine["Scenario simulation"]
end

subgraph group_support["Persistence and assistance"]
  node_coachengine["Coach response engine<br/>[aiCoachEngine.ts]"]
  node_aiservice["AI service client<br/>[aiService.ts]"]
  node_aiclient["AI API client<br/>[aiClient.ts]"]
  node_server["Server AI endpoints<br/>[server.ts]"]
  node_firebase["Firebase goal sync<br/>[firebaseSync.ts]"]
  node_export["Financial data export"]
  node_translations["Bilingual translations<br/>[translations.ts]"]
  node_voice["Speech assistance"]
end

node_customer(("Customer"))

node_customer -->|"opens app"| node_app
node_app -->|"provides state"| node_financialstate
node_app -->|"provides notifications"| node_notifications
node_app -->|"renders"| node_layout
node_layout -->|"routes to"| node_home
node_layout -->|"routes to"| node_dashboard
node_layout -->|"routes to"| node_forecastpage
node_layout -->|"routes to"| node_riskpage
node_layout -->|"routes to"| node_spending
node_layout -->|"routes to"| node_simulator
node_layout -->|"routes to"| node_goals
node_layout -->|"routes to"| node_coachpage
node_home -->|"selects persona"| node_financialstate
node_financialstate -->|"loads persona data"| node_synthetic
node_financialstate -->|"builds profile"| node_profileengine
node_profileengine -->|"generates transactions"| node_synthetic
node_financialstate -->|"calculates forecast"| node_forecastengine
node_financialstate -->|"calculates risk"| node_riskengine
node_financialstate -->|"detects anomalies"| node_anomalies
node_financialstate -->|"generates actions"| node_recommendations
node_financialstate -->|"loads goals"| node_savingsengine
node_dashboard -->|"reads metrics"| node_financialstate
node_forecastpage -->|"reads forecast"| node_financialstate
node_riskpage -->|"reads risk"| node_financialstate
node_spending -->|"reads spending"| node_financialstate
node_simulator -->|"reads finances"| node_financialstate
node_simulator -->|"runs scenarios"| node_simulationengine
node_simulationengine -->|"uses forecast"| node_forecastengine
node_simulationengine -->|"uses risk scoring"| node_riskengine
node_goals -->|"reads goals"| node_financialstate
node_profile -->|"reads profile"| node_financialstate
node_profile -->|"exports data"| node_export
node_coachpage -->|"reads context"| node_financialstate
node_coachpage -->|"requests guidance"| node_coachengine
node_coachengine -.->|"requests AI endpoint"| node_server
node_dashboard -->|"requests insights"| node_coachengine
node_aiservice -->|"uses client"| node_aiclient
node_financialstate -->|"syncs goals"| node_firebase
node_financialstate -->|"uses language"| node_translations
node_coachpage -->|"uses speech"| node_voice

click node_app "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/App.tsx"
click node_layout "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/components/AppLayout.tsx"
click node_home "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/HomePage.tsx"
click node_dashboard "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/Dashboard.tsx"
click node_forecastpage "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/CashFlowForecast.tsx"
click node_riskpage "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/FinancialRisk.tsx"
click node_spending "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/SpendingIntelligence.tsx"
click node_simulator "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/WhatIfSimulator.tsx"
click node_goals "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/SavingsGoals.tsx"
click node_profile "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/ProfileOverview.tsx"
click node_financialstate "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/context/FinancialContext.tsx"
click node_notifications "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/context/NotificationContext.tsx"
click node_synthetic "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/data/syntheticData.ts"
click node_profileengine "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/financialProfileEngine.ts"
click node_forecastengine "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/forecastingEngine.ts"
click node_riskengine "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/shortageRiskEngine.ts"
click node_anomalies "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/anomalyDetectionEngine.ts"
click node_recommendations "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/recommendationEngine.ts"
click node_savingsengine "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/savingsPlannerEngine.ts"
click node_simulationengine "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/simulationEngine.ts"
click node_coachpage "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/AICoach.tsx"
click node_coachengine "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/aiCoachEngine.ts"
click node_aiservice "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/aiService.ts"
click node_aiclient "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/aiClient.ts"
click node_server "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/server.ts"
click node_firebase "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/firebaseSync.ts"
click node_export "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/utils/exportFinancialData.ts"
click node_translations "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/utils/translations.ts"
click node_voice "https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/utils/speechVoiceHelper.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_layout,node_home,node_dashboard,node_forecastpage,node_riskpage,node_spending,node_simulator,node_goals,node_profile,node_coachpage toneBlue
class node_financialstate,node_notifications,node_synthetic toneAmber
class node_profileengine,node_forecastengine,node_riskengine,node_anomalies,node_recommendations,node_savingsengine,node_simulationengine toneMint
class node_coachengine,node_aiservice,node_aiclient,node_server,node_firebase,node_export,node_translations,node_voice toneRose
class node_customer toneIndigo
```

## Components

### User experience

- [App composition](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/App.tsx): `src/App.tsx`
- [Navigation and layout](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/components/AppLayout.tsx): `src/components/AppLayout.tsx`
- [Persona selection](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/HomePage.tsx): `src/pages/HomePage.tsx`
- [Financial dashboard](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Cash-flow forecast](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/CashFlowForecast.tsx): `src/pages/CashFlowForecast.tsx`
- [Financial risk](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/FinancialRisk.tsx): `src/pages/FinancialRisk.tsx`
- [Spending intelligence](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/SpendingIntelligence.tsx): `src/pages/SpendingIntelligence.tsx`
- [What-if simulator](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/WhatIfSimulator.tsx): `src/pages/WhatIfSimulator.tsx`
- [Savings goals](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/SavingsGoals.tsx): `src/pages/SavingsGoals.tsx`
- [Profile overview](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/ProfileOverview.tsx): `src/pages/ProfileOverview.tsx`
- [AI coach](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/pages/AICoach.tsx): `src/pages/AICoach.tsx`

### Financial state

- [Financial context](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/context/FinancialContext.tsx): `src/context/FinancialContext.tsx`
- [Notification context](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/context/NotificationContext.tsx): `src/context/NotificationContext.tsx`
- [Synthetic ledger and personas](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/data/syntheticData.ts): `src/data/syntheticData.ts`

### Financial intelligence

- [Profile engineering](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/financialProfileEngine.ts): `src/services/financialProfileEngine.ts`
- [Cash-flow forecasting](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/forecastingEngine.ts): `src/services/forecastingEngine.ts`
- [Shortage risk scoring](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/shortageRiskEngine.ts): `src/services/shortageRiskEngine.ts`
- [Spending anomaly detection](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/anomalyDetectionEngine.ts): `src/services/anomalyDetectionEngine.ts`
- [Intervention recommendations](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/recommendationEngine.ts): `src/services/recommendationEngine.ts`
- [Savings planning](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/savingsPlannerEngine.ts): `src/services/savingsPlannerEngine.ts`
- [Scenario simulation](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/simulationEngine.ts): `src/services/simulationEngine.ts`

### Persistence and assistance

- [Coach response engine](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/aiCoachEngine.ts): `src/services/aiCoachEngine.ts`
- [AI service client](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/aiService.ts): `src/services/aiService.ts`
- [AI API client](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/aiClient.ts): `src/services/aiClient.ts`
- [Server AI endpoints](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/server.ts): `server.ts`
- [Firebase goal sync](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/services/firebaseSync.ts): `src/services/firebaseSync.ts`
- [Financial data export](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/utils/exportFinancialData.ts): `src/utils/exportFinancialData.ts`
- [Bilingual translations](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/utils/translations.ts): `src/utils/translations.ts`
- [Speech assistance](https://github.com/mahirfaysal01/upay-financial-resilience-ai/blob/main/src/utils/speechVoiceHelper.ts): `src/utils/speechVoiceHelper.ts`

### Other components

- **Customer**

## Connections

- Customer → App composition: opens app (evidence: `README.md`)
- App composition → Financial context: provides state (evidence: `src/App.tsx`)
- App composition → Notification context: provides notifications (evidence: `src/App.tsx`)
- App composition → Navigation and layout: renders (evidence: `src/App.tsx`)
- Navigation and layout → Persona selection: routes to (evidence: `src/components/AppLayout.tsx`)
- Navigation and layout → Financial dashboard: routes to (evidence: `src/components/AppLayout.tsx`)
- Navigation and layout → Cash-flow forecast: routes to (evidence: `src/components/AppLayout.tsx`)
- Navigation and layout → Financial risk: routes to (evidence: `src/components/AppLayout.tsx`)
- Navigation and layout → Spending intelligence: routes to (evidence: `src/components/AppLayout.tsx`)
- Navigation and layout → What-if simulator: routes to (evidence: `src/components/AppLayout.tsx`)
- Navigation and layout → Savings goals: routes to (evidence: `src/components/AppLayout.tsx`)
- Navigation and layout → AI coach: routes to (evidence: `src/components/AppLayout.tsx`)
- Persona selection → Financial context: selects persona (evidence: `src/pages/HomePage.tsx`)
- Financial context → Synthetic ledger and personas: loads persona data (evidence: `src/context/FinancialContext.tsx`)
- Financial context → Profile engineering: builds profile (evidence: `src/context/FinancialContext.tsx`)
- Profile engineering → Synthetic ledger and personas: generates transactions (evidence: `src/services/financialProfileEngine.ts`)
- Financial context → Cash-flow forecasting: calculates forecast (evidence: `src/context/FinancialContext.tsx`)
- Financial context → Shortage risk scoring: calculates risk (evidence: `src/context/FinancialContext.tsx`)
- Financial context → Spending anomaly detection: detects anomalies (evidence: `src/context/FinancialContext.tsx`)
- Financial context → Intervention recommendations: generates actions (evidence: `src/context/FinancialContext.tsx`)
- Financial context → Savings planning: loads goals (evidence: `src/context/FinancialContext.tsx`)
- Financial dashboard → Financial context: reads metrics (evidence: `src/pages/Dashboard.tsx`)
- Cash-flow forecast → Financial context: reads forecast (evidence: `src/components/AppLayout.tsx`)
- Financial risk → Financial context: reads risk (evidence: `src/pages/FinancialRisk.tsx`)
- Spending intelligence → Financial context: reads spending (evidence: `src/pages/SpendingIntelligence.tsx`)
- What-if simulator → Financial context: reads finances (evidence: `src/pages/WhatIfSimulator.tsx`)
- What-if simulator → Scenario simulation: runs scenarios (evidence: `src/pages/WhatIfSimulator.tsx`)
- Scenario simulation → Cash-flow forecasting: uses forecast (evidence: `src/services/simulationEngine.ts`)
- Scenario simulation → Shortage risk scoring: uses risk scoring (evidence: `src/services/simulationEngine.ts`)
- Savings goals → Financial context: reads goals (evidence: `src/components/AppLayout.tsx`)
- Profile overview → Financial context: reads profile (evidence: `src/components/AppLayout.tsx`)
- Profile overview → Financial data export: exports data (evidence: `src/pages/ProfileOverview.tsx`)
- AI coach → Financial context: reads context (evidence: `src/pages/AICoach.tsx`)
- AI coach → Coach response engine: requests guidance (evidence: `src/pages/AICoach.tsx`)
- Coach response engine → Server AI endpoints: requests AI endpoint
- Financial dashboard → Coach response engine: requests insights (evidence: `src/pages/Dashboard.tsx`)
- AI service client → AI API client: uses client (evidence: `src/services/aiService.ts`)
- Financial context → Firebase goal sync: syncs goals (evidence: `src/context/FinancialContext.tsx`)
- Financial context → Bilingual translations: uses language (evidence: `src/context/FinancialContext.tsx`)
- AI coach → Speech assistance: uses speech (evidence: `src/pages/AICoach.tsx`)
