How hanlaigia/ml_loans_prediction works
This is a loan-default risk prediction web application: staff sign in, enter a loan application, request a risk prediction, and can save it for later review. The UI also exposes filtered loan records and statistical dashboards. The graph distinguishes the application, prediction, and persistence stages, plus the backend’s API and data-access layer. README documentation supports the major features and API wiring; some frontend request handlers and backend helper implementations were not sampled, so those links follow documented endpoints and uncertain internal calls are omitted.
Main entry points: loans.py Loan endpoints · main.py FastAPI entry · crud.py Loan and dashboard operations · page.tsx Loan application form
Components 15
Web application
- Sign in
frontend/app/login/page.tsx - Route protection
frontend/components/auth-guard.tsx - Loan application form
frontend/app/page.tsx - Statistics dashboard
frontend/app/dashboard/page.tsx - Saved loan records
frontend/app/all-data/page.tsx
Backend API
- FastAPI entry
backend/main.py - Loan endpoints
backend/routers/loans.py - Request and response schemas
backend/schemas.py
Risk prediction
- Model inference
backend/model_loader.py - Trained XGBoost model
Persistence and analytics
- Loan and dashboard operations
backend/crud.py - Loan and employee models
backend/models.py - SQLAlchemy connection
backend/database.py
Other components
- Loan staff
- MySQL database
Connections 20
- Loan staff → Sign in: signs in
- Sign in → FastAPI entry: submits credentials
- Loan staff → Loan application form: enters application
- Loan application form → Loan endpoints: requests prediction
- Loan application form → Loan endpoints: saves application
- Loan staff → Statistics dashboard: views statistics
- Statistics dashboard → FastAPI entry: requests dashboard
- Loan staff → Saved loan records: reviews records
- Saved loan records → Loan endpoints: filters or deletes
- FastAPI entry → Loan and dashboard operations: requests dashboard data
- FastAPI entry → Loan and dashboard operations: looks up employee
- FastAPI entry → Loan endpoints: dispatches loan routes
- Loan endpoints → Model inference: requests inference
- Model inference → Trained XGBoost model: predicts with
- Loan endpoints → Loan and dashboard operations: creates loan
- Loan endpoints → Loan and employee models: queries loan records
- Loan and dashboard operations → Loan and employee models: uses mapped entities
- Loan and dashboard operations → SQLAlchemy connection: uses session
- Loan endpoints → SQLAlchemy connection: gets database session
- SQLAlchemy connection → MySQL database: connects to