# kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch architecture

> Architecture diagram of the GitHub repository kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch
- Repository: https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch

## Overview

This is a web-based credit-risk scoring and monitoring platform, not the Python/FastAPI training system described in the README’s aspirational project brief. The user signs in, enters applicant attributes, receives a server-side model score and explanation, and the app saves the result for history and dashboard views. The sampled code supports model scoring, risk categorization, model-card data, and Supabase-backed prediction records. Training and experiment workflows are described in the README but are not represented in the supplied tree; unsampled implementation details are omitted.

Main entry points: [`src/lib/credit.functions.ts`](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/credit.functions.ts) (Scoring server functions), [`src/routes/_authenticated/predict.tsx`](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/predict.tsx) (Applicant predictor), [`src/routes/_authenticated/dashboard.tsx`](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/dashboard.tsx) (Dashboard), [`src/lib/predictions.ts`](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/predictions.ts) (Prediction history store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and routing"]
  node_auth_page["Sign-in page<br/>[auth.tsx]"]
  node_route_map["Route map<br/>[routeTree.gen.ts]"]
  node_auth_gate["Authenticated route gate<br/>[route.tsx]"]
  node_supabase_client["Supabase client<br/>[client.ts]"]
end

subgraph group_scoring["Scoring and model"]
  node_predict_page["Applicant predictor<br/>[predict.tsx]"]
  node_credit_fields["Applicant field definitions<br/>[credit-fields.ts]"]
  node_score_api["Scoring server functions"]
  node_model["Credit model and explanations"]
end

subgraph group_records["Prediction records"]
  node_prediction_store["Prediction history store<br/>[predictions.ts]"]
  node_supabase_db[("Supabase predictions database")]
end

subgraph group_insights["Risk insights"]
  node_app_shell["Authenticated app shell<br/>[app-shell.tsx]"]
  node_dashboard["Dashboard<br/>[dashboard.tsx]"]
  node_explainability["Explainability view<br/>[explainability.tsx]"]
  node_performance["Model performance view<br/>[performance.tsx]"]
  node_history["History view<br/>[history.tsx]"]
  node_risk_badge["Risk category badge<br/>[risk-badge.tsx]"]
end

node_user(("Platform user"))

node_user -->|"signs in"| node_auth_page
node_auth_page -->|"authenticates with"| node_supabase_client
node_route_map -->|"routes to"| node_auth_gate
node_auth_gate -->|"checks session"| node_supabase_client
node_user -->|"submits applicant"| node_predict_page
node_predict_page -->|"renders fields"| node_credit_fields
node_predict_page -->|"requests score"| node_score_api
node_score_api -->|"scores applicant"| node_model
node_score_api -->|"loads model details"| node_model
node_predict_page -->|"saves result"| node_prediction_store
node_prediction_store -->|"reads and writes"| node_supabase_client
node_user -->|"views summary"| node_dashboard
node_dashboard -->|"loads model info"| node_score_api
node_dashboard -->|"loads predictions"| node_prediction_store
node_user -->|"views explanations"| node_explainability
node_explainability -->|"loads model info"| node_score_api
node_user -->|"views performance"| node_performance
node_performance -->|"loads metrics"| node_score_api
node_performance -->|"loads predictions"| node_prediction_store
node_user -->|"reviews history"| node_history
node_history -->|"loads predictions"| node_prediction_store
node_dashboard -->|"renders within"| node_app_shell
node_explainability -->|"renders within"| node_app_shell
node_performance -->|"renders within"| node_app_shell
node_history -->|"renders within"| node_app_shell
node_dashboard -->|"shows risk category"| node_risk_badge
node_history -->|"shows risk category"| node_risk_badge
node_predict_page -->|"shows scored risk"| node_risk_badge

click node_auth_page "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/auth.tsx"
click node_route_map "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routeTree.gen.ts"
click node_auth_gate "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/route.tsx"
click node_supabase_client "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/integrations/supabase/client.ts"
click node_predict_page "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/predict.tsx"
click node_credit_fields "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/credit-fields.ts"
click node_score_api "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/credit.functions.ts"
click node_model "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/credit-model.server.ts"
click node_prediction_store "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/predictions.ts"
click node_app_shell "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/components/app-shell.tsx"
click node_dashboard "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/dashboard.tsx"
click node_explainability "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/explainability.tsx"
click node_performance "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/performance.tsx"
click node_history "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/history.tsx"
click node_risk_badge "https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/components/risk-badge.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_auth_page,node_route_map,node_auth_gate,node_supabase_client,node_user toneBlue
class node_predict_page,node_credit_fields,node_score_api,node_model toneAmber
class node_prediction_store,node_supabase_db toneMint
class node_app_shell,node_dashboard,node_explainability,node_performance,node_history,node_risk_badge toneRose
```

## Components

### Access and routing

- [Sign-in page](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/auth.tsx): `src/routes/auth.tsx`
- [Route map](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routeTree.gen.ts): `src/routeTree.gen.ts`
- [Authenticated route gate](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/route.tsx): `src/routes/_authenticated/route.tsx`
- [Supabase client](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`

### Scoring and model

- [Applicant predictor](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/predict.tsx): `src/routes/_authenticated/predict.tsx`
- [Applicant field definitions](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/credit-fields.ts): `src/lib/credit-fields.ts`
- [Scoring server functions](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/credit.functions.ts): `src/lib/credit.functions.ts`
- [Credit model and explanations](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/credit-model.server.ts): `src/lib/credit-model.server.ts`

### Prediction records

- [Prediction history store](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/lib/predictions.ts): `src/lib/predictions.ts`
- **Supabase predictions database**

### Risk insights

- [Authenticated app shell](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/components/app-shell.tsx): `src/components/app-shell.tsx`
- [Dashboard](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/dashboard.tsx): `src/routes/_authenticated/dashboard.tsx`
- [Explainability view](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/explainability.tsx): `src/routes/_authenticated/explainability.tsx`
- [Model performance view](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/performance.tsx): `src/routes/_authenticated/performance.tsx`
- [History view](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/routes/_authenticated/history.tsx): `src/routes/_authenticated/history.tsx`
- [Risk category badge](https://github.com/kullayireddy/build-a-production-ready-credit-risk-loan-default-prediction-platform-from-scratch/blob/main/src/components/risk-badge.tsx): `src/components/risk-badge.tsx`

### Other components

- **Platform user**

## Connections

- Platform user → Sign-in page: signs in (evidence: `src/routes/auth.tsx`)
- Sign-in page → Supabase client: authenticates with (evidence: `src/routes/auth.tsx`)
- Route map → Authenticated route gate: routes to (evidence: `src/routeTree.gen.ts`)
- Authenticated route gate → Supabase client: checks session (evidence: `src/routes/_authenticated/route.tsx`)
- Platform user → Applicant predictor: submits applicant (evidence: `src/routes/_authenticated/predict.tsx`)
- Applicant predictor → Applicant field definitions: renders fields (evidence: `src/routes/_authenticated/predict.tsx`)
- Applicant predictor → Scoring server functions: requests score (evidence: `src/routes/_authenticated/predict.tsx`)
- Scoring server functions → Credit model and explanations: scores applicant (evidence: `src/lib/credit.functions.ts`)
- Scoring server functions → Credit model and explanations: loads model details (evidence: `src/lib/credit.functions.ts`)
- Applicant predictor → Prediction history store: saves result (evidence: `src/routes/_authenticated/predict.tsx`)
- Prediction history store → Supabase client: reads and writes (evidence: `src/lib/predictions.ts`)
- Platform user → Dashboard: views summary
- Dashboard → Scoring server functions: loads model info (evidence: `src/routes/_authenticated/dashboard.tsx`)
- Dashboard → Prediction history store: loads predictions (evidence: `src/routes/_authenticated/dashboard.tsx`)
- Platform user → Explainability view: views explanations
- Explainability view → Scoring server functions: loads model info (evidence: `src/routes/_authenticated/explainability.tsx`)
- Platform user → Model performance view: views performance
- Model performance view → Scoring server functions: loads metrics (evidence: `src/routes/_authenticated/performance.tsx`)
- Model performance view → Prediction history store: loads predictions (evidence: `src/routes/_authenticated/performance.tsx`)
- Platform user → History view: reviews history
- History view → Prediction history store: loads predictions (evidence: `src/routes/_authenticated/history.tsx`)
- Dashboard → Authenticated app shell: renders within (evidence: `src/routes/_authenticated/dashboard.tsx`)
- Explainability view → Authenticated app shell: renders within (evidence: `src/routes/_authenticated/explainability.tsx`)
- Model performance view → Authenticated app shell: renders within (evidence: `src/routes/_authenticated/performance.tsx`)
- History view → Authenticated app shell: renders within (evidence: `src/routes/_authenticated/history.tsx`)
- Dashboard → Risk category badge: shows risk category (evidence: `src/routes/_authenticated/dashboard.tsx`)
- History view → Risk category badge: shows risk category (evidence: `src/routes/_authenticated/history.tsx`)
- Applicant predictor → Risk category badge: shows scored risk (evidence: `src/routes/_authenticated/predict.tsx`)
