A hackathon prototype for PSB's FinTech Cybersecurity Hackathon 2025 - Credit Risk Management Track
Project Z-Score addresses India's dual crisis of credit exclusion (451M individuals lack formal credit access) and rising microfinance delinquencies (163% YoY surge in defaults). Our solution combines alternative data sources, explainable AI, and gamified financial literacy to create a comprehensive credit infrastructure for the underbanked.
- Trust-Based Scoring: Dynamic assessment using alternative data (utility bills, social proof, digital footprints)
- Explainable AI: SHAP-powered decision transparency for regulatory compliance
- Gamified Journey: Transform credit building from intimidating process to engaging experience
- DPDPA Compliant: Built with privacy-by-design and regulatory compliance as core principles
-
Clone and setup:
git clone https://github.com/Rizzy1857/Z-Cred.git cd Z-Cred make setup-dev -
Run the application:
make run # Main application make run-user # User interface make run-admin # Admin dashboard
-
Run tests:
make test # Run all tests make test-cov # With coverage
For detailed setup instructions, see DEVELOPMENT.md.
- Dynamic Trust Scoring: Multi-component assessment (Behavioral, Social, Digital Trust)
- Obscurity Model: Guided journey from credit-invisible to scorable status
- ML Pipeline: Logistic Regression baseline + XGBoost ensemble with SHAP explainability
- Gamification: Z-Credits system with missions, achievements, and Trust Bar visualization
- DPDPA Compliance: Granular consent management, data minimization, withdrawal mechanisms
- RBI Guidelines: Direct fund flow, cooling-off periods, Key Fact Statement generation
- Secure Architecture: PBKDF2 password hashing, session management, input validation
- F1 - Payment History: BBPS utility payment data for financial discipline assessment
- F2 - Loan Performance: MFI/NGO loan history from informal/semi-formal sources
- F3 - Social Proof: Community trust metrics from SHG/NGO endorsements
- F4 - Digital Footprint: Telecom data, transaction SMS patterns, device stability
- Frontend: Streamlit with custom CSS for professional UI
- Backend: Python with SQLite for offline-first architecture
- ML Pipeline: scikit-learn, XGBoost, SHAP for explainable predictions
- Security: bcrypt, session management, DPDPA-compliant consent flows
- Visualization: Plotly, Matplotlib for interactive charts and explanations
zscore/
app.py # Main Streamlit application
auth.py # Authentication system
local_db.py # Database operations
model_pipeline.py # ML models and training
requirements.txt # Dependencies
README.md # This file
data/
applicants.db # Main SQLite database
sample_data/ # Demo datasets
- Python 3.8+ (recommended: Python 3.10+)
- Git
- 4GB+ available disk space
- 8GB+ RAM (recommended for optimal performance)
Use our automated setup script for the fastest deployment:
# Clone the repository
git clone <repository-url>
cd Z-Cred
# Run automated setup and launch
./start.sh
# Alternative: Skip setup if already configured
./start.sh --skip-setup
# Start specific application
./start.sh --app=user # User interface (port 8502)
./start.sh --app=admin # Admin interface (port 8503)
./start.sh --app=main # Main interface (port 8501)-
Clone the repository
git clone <repository-url> cd Z-Cred
-
Create virtual environment
python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies (pinned versions)
pip install --upgrade pip pip install -r requirements.txt
-
Initialize database and demo data
python setup_demo_data.py
-
Cache SHAP explainers (optional, for better performance)
python -c " from model_integration import model_integrator from shap_cache import cache_shap_explainers model = model_integrator.get_credit_model() cache_shap_explainers(model) print(' SHAP explainers cached for optimal performance') "
-
Run the application
# Main application streamlit run app.py --server.port 8501 # User-focused interface streamlit run app_user.py --server.port 8502 # Admin interface streamlit run app_admin.py --server.port 8503
-
Access the application
- Main App:
http://localhost:8501 - User App:
http://localhost:8502 - Admin App:
http://localhost:8503
- Main App:
For production deployment, use the optimized commands:
# Build production environment
python -m venv prod_env
source prod_env/bin/activate
pip install -r requirements.txt
# Run with production settings
streamlit run app.py --server.port 8501 --server.headless true \
--server.enableCORS false --server.enableXsrfProtection true
# Or use the launcher script
python launcher.py --production --port 8501For development with hot-reload and debugging:
# Install development dependencies
pip install pytest pytest-cov black flake8
# Run tests
python -m pytest test_unified_scoring.py -v
python -m pytest test_*.py
# Code formatting
black *.py
# Performance profiling
python -c "
import cProfile
import app_user
cProfile.run('app_user.main()', 'profile_output.prof')
"# Build Docker image
docker build -t z-cred .
# Run container
docker run -p 8501:8501 z-cred
# Docker Compose for full stack
docker-compose up -dCommon Issues:
-
Port already in use:
# Find and kill process using port lsof -ti:8501 | xargs kill -9 # Or use different port streamlit run app.py --server.port 8504
-
Database locked errors:
# Reset database rm data/applicants.db python setup_demo_data.py -
SHAP explainer errors:
# Clear SHAP cache rm -rf cache/shap/ python -c "from shap_cache import shap_cache; shap_cache.clear_cache()"
-
Memory issues:
# Run with memory optimization export STREAMLIT_BROWSER_GATHER_USAGE_STATS=false streamlit run app.py --server.maxUploadSize 1
For optimal performance:
- Pre-cache SHAP explainers: Run the caching command above
- Use SSD storage: Ensure database is on SSD for faster I/O
- Increase RAM: 8GB+ recommended for large datasets
- Browser cache: Enable browser caching for faster subsequent loads
Tested Configurations:
- macOS 12+ with Python 3.10+
- Ubuntu 20.04+ with Python 3.8+
- Windows 10+ with Python 3.9+
- Docker on Linux/macOS
Performance Benchmarks:
- Cold start: <30 seconds
- Warm start: <5 seconds
- Trust score calculation: <1 second
- SHAP explanation: <2 seconds (cached)
- UI response time: <500ms
Z-Cred showcases three realistic scenarios representing different segments of India's credit-invisible population, each demonstrating unique aspects of alternative credit scoring.
Profile: 32-year-old handicraft artisan from Rajasthan, leading a Self-Help Group Credit Need: ₹25,000 for business equipment expansion Trust Score: 77/100
Key Demo Points:
- Social Proof: SHG leadership and community endorsements
- Payment History: Consistent utility bill payments despite seasonal income
- Alternative Data: Government scheme participation and community ratings
- AI Explanation: SHAP shows community trust as top positive factor
Login: meera@selfhelp.in / demo123
Profile: 26-year-old food delivery partner from Bangalore Credit Need: ₹80,000 for electric vehicle purchase Trust Score: 83/100
Key Demo Points:
- Digital Footprint: High platform ratings (4.7+ on Swiggy/Zomato)
- Income Diversification: Multiple gig platform earnings
- Real-time Data: GPS tracking, transaction velocity, customer feedback
- AI Explanation: Platform consistency drives high trust score
Login: arjun@delivery.in / demo123
Profile: 38-year-old tailoring business owner from Kerala with 12 years experience Credit Need: ₹1,50,000 for business expansion and equipment Trust Score: 85/100
Key Demo Points:
- Business Track Record: 12-year operational history with growth trajectory
- Customer Loyalty: 89% retention rate, excellent online reviews
- Financial Discipline: Perfect rent payments, supplier relationship management
- AI Explanation: Business stability and customer trust drive approval
Login: fatima@tailoring.in / demo123
- User Selection: Choose from three distinct personas
- Trust Score Analysis: See breakdown of behavioral, social, and digital components
- AI Explanations: SHAP-powered transparency for each decision factor
- Credit Journey: Gamified missions and achievements for score improvement
- Compliance Demo: DPDPA consent management and data transparency
Quick Access: All demo documentation available at docs/DEMO_SCENARIOS.md
- Logistic Regression: AUC ~0.92, F1-Score ~0.89
- XGBoost Ensemble: AUC ~0.96, F1-Score ~0.93
- Response Time: <1s per applicant assessment
- Explainability: 100% decisions explained via SHAP
- Target Addressable Market: 451M credit-invisible Indians
- Partner Ecosystem: MFIs, NGOs, Rural Banks, SHGs
- Risk Reduction Goal: 15-20% improvement in Portfolio at Risk (PAR)
- Valid consent (free, specific, informed, unambiguous)
- Purpose limitation (credit assessment only)
- Data minimization (collect only necessary data)
- Data localization (India-based storage)
- Consent withdrawal mechanisms
- LSP partnership model with regulated entities
- Direct fund flow (no intermediary handling)
- Key Fact Statement generation
- Mandatory cooling-off period
- Grievance redressal mechanism
- Authentication system with role management
- SQLite database with offline-first architecture
- ML pipeline with Logistic Regression + XGBoost
- Trust scoring framework (Behavioral, Social, Digital components)
- Basic gamification (Z-Credits, Trust Bar)
- DPDPA-compliant consent management
- Professional Streamlit UI
- SHAP integration for explainable AI
- Advanced visualizations (Trust Bar animations, SHAP plots)
- Demo data scenarios refinement
- PDF credit reports generation
- Offline/online data synchronization
- Mobile-optimized interface for field agents
- Account Aggregator framework integration
for detailed usage guide check Usage Documentation
- Model training:
python model_pipeline.py - Database reset:
python -c "from local_db import reset_database; reset_database()" - Add sample data:
python -c "from local_db import add_sample_data; add_sample_data()"
calculate_trust_score(applicant_data): Returns Trust Bar components and overall scorepredict_credit_risk(features): ML prediction with confidence intervalsgenerate_shap_explanation(features, prediction): Explainable AI breakdownlog_consent(user_id, consent_type, granted): DPDPA compliance logging
Refer detailed documentaion API Documentation
This is a hackathon prototype. For the competition:
- Focus on demo-ready scenarios
- Prioritize visual polish and stability
- Ensure all compliance features work smoothly
- Test end-to-end user journeys
Refer detailed documentaion Contribution Documentaion*
For project-related questions:
- Team Lead: Rizzy
Built for PSB's FinTech Cybersecurity Hackathon 2025 - Credit Risk Management Track
Empowering India's underbanked through trust, technology, and transparency.