How m-tanusree-reddy/credit-risk-predictor- works
Purpose and entry points
Credit Risk Predictor scores applicant default risk using persisted model artifacts behind a FastAPI service, with a React/Vite dashboard for individual assessment and capped batch CSV scoring. Primary runtime entry points are backend/main.py (Uvicorn/FastAPI) and frontend/src/main.tsx (browser application). A previous Streamlit implementation remains at frontend/legacy_streamlit_app.py.
Model-serving boundary
The Python prediction service owns model inference and feature scaling, using serialized artifacts in models/credit_risk_model.pkl and models/scaler.pkl. backend/main.py is the API boundary between browser-facing request data and Python/ML dependencies. Training/source data is retained separately in Data/cs-training.csv, with development work represented by notebook.ipynb; these are not part of the normal interactive serving path.
Frontend application shell
The SPA is initialized by frontend/src/main.tsx and composed from frontend/src/App.tsx. It is built and served through Vite configuration in frontend/vite.config.ts; local frontend configuration can select a non-default API base URL via frontend/.env.example. The frontend is an independent Node/browser runtime from the Python backend.
Assessment and dashboard flows
The UI separates major user workflows into dashboard, single-applicant assessment, and batch views: frontend/src/components/DashboardView.tsx, frontend/src/components/AssessmentView.tsx, and frontend/src/components/BatchView.tsx. Shared client-side request/response contracts are represented in frontend/src/types.ts, while API communication is centralized in frontend/src/utils/api.ts. This keeps model-service protocol concerns outside visual components.
Batch ingestion and scoring
Batch processing begins in the browser, where CSV input is parsed and capped at 500 records before submission to avoid browser and API CPU bottlenecks. frontend/src/components/BatchView.tsx owns the user-facing progress and result workflow; frontend/src/utils/api.ts crosses the service boundary for scoring. The application cleans likely index/system columns and uses structured identifiers when applicant-name metadata is absent.
Explainability path
Detailed explanation is intentionally deferred from fast batch scoring: frontend/src/components/ExplainabilityView.tsx provides the on-demand SHAP-oriented presentation, while frontend/src/components/BatchView.tsx exposes the interaction from scored applicants. This creates a control-flow split between low-latency risk-level predictions and per-applicant detailed explanation requests, expected to be served by backend/main.py.
Deployment and auxiliary API surface
The repository includes a TypeScript API handler at api/extract.ts and Vercel deployment configuration in vercel.json, indicating a serverless/deployment-facing integration surface distinct from local FastAPI execution. frontend/server.ts is also a server-side frontend-adjacent runtime entry point. These should be checked when changing deployment routing so browser requests, serverless handlers, and backend/main.py do not diverge.
Main entry points: App.tsx Application shell · api.ts API client · BatchView.tsx Batch scoring · main.py Prediction API
Components 19
React / Vite frontend
Independent browser and Node runtime.
- Browser user
- SPA entry
frontend/src/main.tsx - Application shell
frontend/src/App.tsx - Dashboard
frontend/src/components/DashboardView.tsx - Single assessment
frontend/src/components/AssessmentView.tsx - Batch scoring · Parses CSV, removes likely system columns, and caps input at 500 records.
frontend/src/components/BatchView.tsx - Explanation view · On-demand SHAP-oriented applicant detail.
frontend/src/components/ExplainabilityView.tsx - API client
frontend/src/utils/api.ts - Client contracts
frontend/src/types.ts - Vite build / serve
frontend/vite.config.ts - Frontend server
frontend/server.ts
Python model service
FastAPI serving boundary for inference and explanations.
- Prediction API · Accepts browser-facing scoring and detailed explanation requests.
backend/main.py - Risk model
models/credit_risk_model.pkl - Feature scaler
models/scaler.pkl
Deployment integration
Serverless and routing surface.
- Extract handler
api/extract.ts - Vercel routing
vercel.json
Other components
- Training data · Retained outside the normal serving path.
Data/cs-training.csv - Model development · Development work outside the normal serving path.
notebook.ipynb - Legacy Streamlit UI · Previous implementation retained alongside the SPA.
frontend/legacy_streamlit_app.py
Connections 19
- Browser user → SPA entry: loads
- SPA entry → Application shell: mounts
- Application shell → Dashboard: renders
- Application shell → Single assessment: renders
- Application shell → Batch scoring: renders
- Single assessment → API client: score request
- Batch scoring → API client: capped CSV scoring
- Batch scoring → Explanation view: select applicant
- Explanation view → API client: detail request
- API client → Client contracts: uses
- API client → Prediction API: HTTP scoring / explanation
- Prediction API → Risk model: loads for inference
- Prediction API → Feature scaler: loads for features
- Vite build / serve → SPA entry: builds / serves
- Frontend server → Application shell: server-side runtime
- Vercel routing → Extract handler: routes deployment traffic
- Vercel routing → Frontend server: deploys runtime
- Training data → Model development: development input
- Model development → Risk model: produces artifact