Clarity and trust in personal loan decisions
SmartLend.AI is a production-ready, AI-powered personal loan recommendation system that analyzes financial profiles and provides transparent, explainable loan decisions with personalized improvement suggestions.
- Intelligent Loan Scoring: ML-style multi-factor scoring algorithm with weighted feature analysis
- Dynamic Risk Assessment: Real-time risk categorization (Low/Medium/High)
- Approval Probability Prediction: AI-powered likelihood scoring with model uncertainty
- Smart Loan Recommendations: Optimal loan amount, dynamic interest rates, and EMI calculations
- Explainable AI: Transparent decision-making with detailed explanations
- Personalized Suggestions: Actionable improvement recommendations based on financial profile
- Frontend: Responsive HTML/CSS/JavaScript with modern UI/UX
- Backend: Flask REST API with comprehensive error handling
- AI Engine: Sophisticated scoring system simulating ML model behavior
- Security: Input validation, CORS protection, rate limiting ready
- Production Ready: Clean architecture, logging, health checks
SmartLend.AI/
├── backend/
│ ├── app.py # Flask REST API server
│ ├── ai_engine.py # AI recommendation engine
│ └── requirements.txt # Python dependencies
└── frontend/
├── index.html # Main UI
├── styles.css # Styling
└── script.js # Frontend logic
- Python 3.8+
- pip (Python package manager)
- Modern web browser
# Create project directory
mkdir SmartLend.AI
cd SmartLend.AI# Navigate to backend directory
cd backend
# Install Python dependencies
pip install -r requirements.txt
# Start Flask server
python app.pyThe backend server will start at http://localhost:5000
You should see:
🚀 SmartLend.AI Backend Server Starting...
📍 API Endpoint: http://localhost:5000/ai-loan-recommendation
🏥 Health Check: http://localhost:5000/health
# Open a new terminal
cd frontend
# Open index.html in your browser
# Option 1: Double-click index.html
# Option 2: Use Python's built-in server
python -m http.server 8000
# Then visit http://localhost:8000- Click "Analyze My Loan" to begin
Fill in the following details:
- Monthly Income: Your gross monthly salary (₹)
- Employment Type: Salaried / Self-Employed / Business / Freelancer
- Credit Score: Your CIBIL score (300-850)
- Existing EMIs: Current monthly loan obligations (₹)
- Requested Loan Amount: Desired loan amount (₹)
- Loan Tenure: Repayment period (1-30 years)
View comprehensive recommendation:
- Approval Probability: Percentage likelihood of approval
- Risk Assessment: Low / Medium / High risk category
- Recommended Loan Terms:
- Optimal loan amount
- Dynamic interest rate
- Monthly EMI
- AI Explanation: Why the decision was made
- Improvement Tips: Personalized suggestions to enhance eligibility
The AI engine transforms raw financial data into ML-ready features:
-
Credit Score Normalization (35% weight)
- Normalized 300-850 scale
- Higher scores = better approval odds
-
Income Stability (25% weight)
- Monthly income assessment
- Employment type consideration
-
Debt-to-Income Ratio (20% weight)
- Existing EMI vs. income
- Lower DTI = higher capacity
-
Loan-to-Income Ratio (15% weight)
- Requested amount vs. annual income
- Reasonable borrowing limits
-
Employment Security (5% weight)
- Salaried > Self-Employed > Business > Freelancer
AI Score = Σ(weighted_features × transformation_function)
Approval Probability = sigmoid(AI_Score)
Risk Level = threshold_based_classification(AI_Score)
Interest Rate = base_rate + risk_adjustment + credit_adjustment + market_factor- Base Rate: 9.5% (market baseline)
- Credit Score Impact: -1.5% to +2.0%
- Risk Adjustment: 0% to +2.5%
- Tenure Factor: +0.1% per year
- Market Volatility: ±0.3% (simulated)
POST /ai-loan-recommendation
Content-Type: application/json
{
"monthly_income": 50000,
"employment_type": "salaried",
"credit_score": 750,
"existing_emi": 5000,
"requested_amount": 500000,
"tenure": 5
}{
"success": true,
"data": {
"approval_probability": 78.45,
"risk_level": "Low",
"recommended_loan_amount": 450000,
"interest_rate": 9.2,
"monthly_emi": 9367.50,
"ai_explanation": "✓ Strong approval likelihood...",
"improvement_suggestions": [
"✅ Excellent financial profile!"
],
"ai_score": 82.3
}
}GET /health
Response:
{
"status": "healthy",
"ai_engine": "operational",
"timestamp": "2025-01-04T00:00:00Z"
}- All inputs validated on both frontend and backend
- Range checks (credit score: 300-850, tenure: 1-30 years)
- Type validation (numbers, strings)
- SQL injection prevention (no database in this version)
- Enabled for cross-origin requests
- Configure allowed origins for production
- Comprehensive try-catch blocks
- User-friendly error messages
- Detailed logging for debugging
- Transparent decision-making
- Encourages responsible borrowing
- No discriminatory bias in scoring
- Trust Colors: Blue, white, grey (financial trust)
- Card-Based Layout: Clean, organized information
- Responsive Design: Mobile-first approach
- Smooth Animations: Professional but minimal
- Accessibility: High contrast, semantic HTML
- Landing → Engaging introduction with trust badges
- Form → Clear input fields with helpful hints
- Results → Comprehensive dashboard with visual indicators
- Actions → Easy navigation between sections
Edit backend/ai_engine.py:
WEIGHTS = {
'credit_score': 0.35, # Increase for credit-focused
'income_stability': 0.25,
'debt_to_income': 0.20,
'loan_to_income': 0.15,
'employment_security': 0.05
}def _calculate_dynamic_interest_rate(self, credit_score, risk_level, tenure):
base_rate = 9.5 # Change market base rate
# Adjust credit score brackets
# Modify risk premiumsEdit frontend/styles.css:
:root {
--primary-blue: #2563eb; /* Brand color */
--success-green: #10b981; /* Approval color */
--warning-orange: #f59e0b; /* Caution color */
--danger-red: #ef4444; /* Risk color */
}# Add Procfile
web: gunicorn app:app
# Install gunicorn
pip install gunicorn
# Update requirements.txt
pip freeze > requirements.txt- Update API_BASE_URL in
script.jsto production backend URL - Deploy static files (index.html, styles.css, script.js)
# Production settings
FLASK_ENV=production
API_KEY=your_api_key_here
CORS_ORIGINS=https://yourdomain.comHigh Approval Profile:
- Income: ₹100,000
- Employment: Salaried
- Credit Score: 800
- Existing EMI: ₹5,000
- Requested: ₹500,000
- Tenure: 5 years
- Expected: 85%+ approval, Low risk, ~8.5% interest
Medium Risk Profile:
- Income: ₹40,000
- Employment: Self-Employed
- Credit Score: 650
- Existing EMI: ₹15,000
- Requested: ₹300,000
- Tenure: 7 years
- Expected: 50-70% approval, Medium risk, ~11% interest
High Risk Profile:
- Income: ₹25,000
- Employment: Freelancer
- Credit Score: 550
- Existing EMI: ₹10,000
- Requested: ₹400,000
- Tenure: 10 years
- Expected: <40% approval, High risk, ~14% interest
Error: Port 5000 already in use
# Change port in app.py
app.run(debug=True, host='0.0.0.0', port=5001)
# Update API_BASE_URL in script.jsError: Module not found
# Reinstall dependencies
pip install -r requirements.txtError: CORS policy error
- Ensure Flask-CORS is installed
- Check API_BASE_URL in script.js matches backend
Error: API connection failed
- Verify backend is running on correct port
- Check browser console for detailed errors
- Database integration (PostgreSQL/MongoDB)
- User authentication & loan history
- Real ML model training on historical data
- Document upload (income proof, ID verification)
- Multi-language support
- Email/SMS notifications
- Integration with actual credit bureaus
- Chatbot for financial guidance
- A/B testing framework
- Analytics dashboard
This project is for educational and demonstration purposes.
Disclaimer: This is an AI-powered tool for informational purposes only. Final loan approval is subject to lender verification, credit checks, and specific terms and conditions. Always consult with financial advisors for major financial decisions.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Commit with clear messages
- Test thoroughly
- Submit pull request
For issues, questions, or suggestions:
- Open an issue on GitHub
- Email: support@smartlend.ai (demo)
Built with:
- Flask (Python web framework)
- Vanilla JavaScript (no framework dependencies)
- Modern CSS3 (responsive design)
- Mathematical algorithms for financial calculations
Made with ❤️ for transparent, ethical AI in fintech
SmartLend.AI - Empowering informed financial decisions through artificial intelligence