Skip to content

Latest commit

Β 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏦 LOAN EASY - AI-Powered Loan Approval System

A complete professional banking application with machine learning-powered loan approval predictions, comprehensive user authentication, document verification system, and collateral-based eligibility checking. Built with Flask, SQLAlchemy, and scikit-learn.

✨ Features

πŸ” Authentication System

  • User Registration & Login: Secure bcrypt password hashing
  • Session Management: Flask-Login integration
  • Profile Management: Complete user profiles with personal, financial, and employment information

πŸ“„ Document Verification (NEW!)

  • PAN Card Verification: Format validation + simulated Income Tax Department lookup
  • Aadhar Verification: 12-digit validation + simulated UIDAI e-KYC
  • Bank Account Verification: IFSC validation + simulated NPCI penny drop
  • CIBIL Score Verification: Credit score cross-checking with simulated bureau
  • Income Verification: ITR cross-checking with variance detection
  • Comprehensive Reports: Detailed verification results with scoring (0-100%)

πŸ€– Machine Learning

  • Gradient Boosting Model: 98.48% accuracy on real loan data
  • Trained on 4,269 Real Applications: Actual loan approval patterns
  • Real-time Predictions: Instant eligibility checks with confidence scores
  • 11+ Features: Income, credit history, collateral, employment, and more

πŸ’Ό Collateral-Based Eligibility

  • Asset Verification: Residential, commercial, luxury assets, and bank deposits
  • 20% Rule: Requires minimum 20% of loan amount in collateral
  • Pre-Application Check: Prevents ineligible applications

🎨 Professional UI

  • LOAN EASY Branding: Corporate banking design with navy/blue theme
  • Responsive Design: Works on desktop, tablet, and mobile
  • Modern Interface: Clean forms, status badges, verification cards

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/YOUR_USERNAME/loan-easy.git
cd loan-easy

2. Create Virtual Environment

python -m venv .venv
.venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Run the Application

python app_auth.py

Open your browser and go to: http://127.0.0.1:5000

5. Create Your Account

  1. Register with email and password
  2. Complete your profile (11 sections)
  3. Automatic verification runs!
  4. View verification results
  5. Apply for loans (if collateral requirement met)

🌐 Live Demo

Deployed on Vercel: https://loan-easy.vercel.app (Replace with your URL)


πŸ“– Complete Documentation

πŸ“Š Data Features

The model uses the following features:

Feature Description Type
ApplicantIncome Primary applicant's income Numerical
CoapplicantIncome Co-applicant's income Numerical
LoanAmount Requested loan amount (in $1000s) Numerical
Loan_Amount_Term Loan repayment period (months) Numerical
Credit_History Credit repayment history (0=Bad, 1=Good) Binary
Gender Applicant's gender Categorical
Married Marital status Categorical
Dependents Number of dependents Categorical
Education Education level Categorical
Self_Employed Employment type Categorical
Property_Area Urban/Semiurban/Rural Categorical

🧠 Machine Learning Models

Decision Tree Classifier

  • Fast and interpretable
  • Good for understanding decision rules
  • Max depth limited to prevent overfitting

Support Vector Machine (SVM)

  • RBF kernel for non-linear classification
  • Probability estimates enabled
  • Good for high-dimensional data

Random Forest Classifier

  • Ensemble of 100 decision trees
  • Reduced overfitting through averaging
  • Generally highest accuracy

πŸ“ˆ Model Performance

After training, you'll see:

  • Test accuracy for each model
  • Cross-validation scores (5-fold)
  • Confusion matrices
  • Classification reports
  • Visual comparison chart saved as model_comparison.png

🌐 Web Interface

The Flask application provides:

  • Clean, modern UI with gradient design
  • Input form for all loan features
  • Real-time prediction with confidence score
  • Responsive design for mobile devices
  • Loading animations and result displays

πŸ“ Project Structure

loan-easy/
β”œβ”€β”€ app_auth.py                         # Main Flask application
β”œβ”€β”€ verification_service.py             # Document verification module
β”œβ”€β”€ train_model_real.py                 # ML model training (real data)
β”œβ”€β”€ requirements.txt                    # Python dependencies
β”œβ”€β”€ vercel.json                         # Vercel deployment config
β”œβ”€β”€ wsgi.py                             # WSGI entry point
β”œβ”€β”€ runtime.txt                         # Python version
β”œβ”€β”€ .gitignore                          # Git ignore rules
β”‚
β”œβ”€β”€ templates/                          # HTML templates
β”‚   β”œβ”€β”€ base.html                       # Base template with LOAN EASY branding
β”‚   β”œβ”€β”€ index.html                      # Landing page
β”‚   β”œβ”€β”€ register.html                   # User registration
β”‚   β”œβ”€β”€ login.html                      # User login
β”‚   β”œβ”€β”€ dashboard.html                  # User dashboard
β”‚   β”œβ”€β”€ create_profile.html             # Profile creation form (11 sections)
β”‚   β”œβ”€β”€ edit_profile.html               # Profile editing
β”‚   β”œβ”€β”€ view_profile.html               # Profile display
β”‚   β”œβ”€β”€ verification_results.html       # Verification report
β”‚   β”œβ”€β”€ apply_loan.html                 # Loan application form
β”‚   β”œβ”€β”€ loan_result.html                # Loan decision result
β”‚   └── applications.html               # Application history
β”‚
β”œβ”€β”€ instance/                           # Database folder
β”‚   └── loaneasy.db                     # SQLite database
β”‚
β”œβ”€β”€ real_data/                          # Training data
β”‚   └── loan_approval_dataset.csv       # 4,269 real loan applications
β”‚
β”œβ”€β”€ Models/                             # Trained ML models
β”‚   β”œβ”€β”€ loan_model_real.pkl             # Gradient Boosting model (98.48%)
β”‚   β”œβ”€β”€ label_encoders_real.pkl         # Label encoders
β”‚   └── feature_names_real.pkl          # Feature names
β”‚
└── Documentation/
    β”œβ”€β”€ README.md                       # This file
    β”œβ”€β”€ DEPLOYMENT_GUIDE.md             # GitHub & Vercel deployment
    β”œβ”€β”€ VERIFICATION_SYSTEM_DOCS.md     # Verification system details
    β”œβ”€β”€ AUTHENTICATION_SYSTEM_COMPLETE.md  # Auth system guide
    └── REAL_MODEL_SUCCESS.md           # ML model documentation

🎯 How to Use the Web App

  1. Fill in all applicant information:

    • Income details
    • Loan amount and term
    • Personal information
    • Credit history
  2. Click "Check Eligibility"

  3. Get instant prediction:

    • βœ… Approved: Green success message with confidence %
    • ❌ Not Approved: Red rejection message with suggestions

πŸ”§ Customization

Modify Training Data

Edit generate_data.py to adjust:

  • Number of samples
  • Feature distributions
  • Approval logic rules

Tune Models

In train_model.py, adjust:

  • max_depth for Decision Tree
  • n_estimators for Random Forest
  • kernel for SVM

Customize UI

Edit templates in templates/ folder:

  • index.html - Main prediction interface
  • about.html - Information page

πŸ“Š Understanding Predictions

The model considers:

  1. Credit History (Most Important) - Good credit significantly increases approval chances
  2. Income-to-Loan Ratio - Higher income relative to loan amount is favorable
  3. Total Household Income - Combined applicant and co-applicant income
  4. Education Level - Graduates have slightly higher approval rates
  5. Property Location - Urban properties may have different criteria

πŸ› οΈ Troubleshooting

Model Not Loading

# Run these commands in order:
python generate_data.py
python train_model.py
python app.py

Port Already in Use

# Change port in app.py:
app.run(debug=True, port=5001)

Missing Dependencies

pip install --upgrade -r requirements.txt

οΏ½ Deployment

Deploy to Vercel (Recommended)

  1. Push to GitHub:

    git init
    git add .
    git commit -m "Initial commit"
    git remote add origin https://github.com/YOUR_USERNAME/loan-easy.git
    git push -u origin main
  2. Deploy to Vercel:

    • Go to vercel.com
    • Click "Import Project"
    • Select your GitHub repository
    • Click "Deploy"
    • Done! πŸŽ‰

Full deployment guide: See DEPLOYMENT_GUIDE.md


πŸ§ͺ Testing

Test Verification System:

Use these test credentials:

  • PAN: ABCDE1234F (valid format)
  • Aadhar: 123456789012 (any 12 digits)
  • Bank IFSC: SBIN0001234 (valid SBI IFSC)
  • Account: 12345678901234 (any 14 digits)
  • CIBIL Score: 750

The system will verify all documents and show detailed results!


πŸ› οΈ Technology Stack

Component Technology
Backend Python 3.11, Flask 3.0
Database SQLite (local), PostgreSQL (production)
Authentication Flask-Login, Bcrypt
ORM SQLAlchemy
Machine Learning scikit-learn, Gradient Boosting
Frontend HTML5, CSS3, JavaScript
Icons FontAwesome 6.4
Deployment Vercel, GitHub

πŸ“Š Database Schema

Users Table

  • id, email, password_hash, full_name, phone, created_at

UserProfile Table

  • id, user_id, pan_number, aadhar_number, date_of_birth
  • bank_name, account_number, ifsc_code
  • cibil_score, annual_income, employment_type
  • residential_asset_value, commercial_asset_value, luxury_asset_value, bank_balance
  • verification_report, verification_date (NEW!)
  • pan_verified, aadhar_verified, bank_verified, cibil_verified, income_verified (NEW!)

LoanApplication Table

  • id, user_id, loan_amount, loan_term, purpose
  • prediction_result, confidence_score, application_date

πŸ” Security Features

  • βœ… Password hashing with bcrypt
  • βœ… Session management with Flask-Login
  • βœ… CSRF protection
  • βœ… SQL injection prevention (SQLAlchemy ORM)
  • βœ… Input validation and sanitization
  • βœ… Secure secret key for production
  • βœ… Document verification to prevent fraud

πŸ“ˆ Model Performance

Gradient Boosting Classifier:

  • Accuracy: 98.48%
  • Training Data: 4,269 real loan applications
  • Features: 11 (income, credit history, collateral, etc.)
  • Cross-Validation: 5-fold with 98% avg accuracy

Feature Importance:

  1. Credit History (35%)
  2. Total Income (25%)
  3. Loan-to-Income Ratio (20%)
  4. Collateral Value (10%)
  5. Other factors (10%)

🎯 Future Enhancements

  • Email notifications for loan decisions
  • SMS verification for phone numbers
  • Integration with real government APIs (PAN, Aadhar)
  • Real-time CIBIL score fetching
  • Payment gateway integration
  • Admin dashboard for loan management
  • Document upload (PDF/images)
  • e-Signature integration
  • Mobile app (React Native)
  • Multi-language support

πŸ› Troubleshooting

Database Issues

# Delete and recreate database
Remove-Item instance\loaneasy.db
python app_auth.py

Model Not Found

# Retrain the model
python train_model_real.py

Port Already in Use

# Find and kill process on port 5000
Get-Process python | Stop-Process -Force

πŸ“ License

This project is open source and available for educational purposes.


🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“§ Contact

For questions or suggestions, please open an issue on the repository.


🌟 Show Your Support

Give a ⭐️ if this project helped you!


πŸ“œ Changelog

Version 2.0 (October 2025)

  • βœ… Added document verification system
  • βœ… Integrated PAN, Aadhar, Bank, CIBIL, Income verification
  • βœ… Professional LOAN EASY branding
  • βœ… Collateral-based eligibility checking
  • βœ… Comprehensive user profiles
  • βœ… Verification results page

Version 1.5 (October 2025)

  • βœ… User authentication system
  • βœ… Profile management
  • βœ… Loan application workflow

Version 1.0 (October 2025)

  • βœ… ML model training on real data
  • βœ… 98.48% accuracy achieved
  • βœ… Basic Flask web interface

Built with ❀️ by the LOAN EASY Team

Happy Banking! οΏ½

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages