Enterprise-grade customer churn prediction system with comprehensive authentication and security features.
- β AutoGluon AutoML - State-of-the-art automated machine learning
- β Hyperparameter Optimization - Model tuning with Optuna
- β Real-time Predictions - Fast API for single customer predictions
- β Batch Processing - Efficient batch prediction capabilities
- β Interactive Dashboard - Streamlit-based business dashboard
- β JWT Token Authentication - Secure API access with Bearer tokens
- β Role-Based Access Control - Admin, Analyst, and Viewer roles
- β API Rate Limiting - Protection against abuse
- β Comprehensive Audit Logging - Track all security events
- β Dashboard Authentication - Protected Streamlit interface
- β Secure Configuration - Environment variable management
# Clone the repository
git clone <your-repo-url>
cd AutoGluOn_End_to_End
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Run automated security setup
python setup_security.pyThis will:
- Create secure environment variables
- Generate JWT secret keys
- Set up audit log directories
- Display default credentials
# Terminal 1: Start API
uvicorn app:app --reload --host 0.0.0.0 --port 8000
# Terminal 2: Start Dashboard
streamlit run dashboard.pyDashboard: http://localhost:8501
- Username:
admin - Password:
admin123
API Docs: http://localhost:8000/docs
- SECURITY.md - Complete security guide
- SECURITY_IMPLEMENTATION.md - Implementation details
- auth/README.md - Authentication module docs
- README_DASHBOARD.md - Dashboard guide
- README_DEPLOYMENT.md - Deployment guide
| Username | Password | Role | Permissions |
|---|---|---|---|
| admin | admin123 | Admin | Full access, user management |
| analyst | analyst123 | Analyst | Predictions, batch processing |
| viewer | viewer123 | Viewer | Read-only, single predictions |
curl -X POST "http://localhost:8000/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin&password=admin123"# Save token
TOKEN="your-jwt-token-here"
# Single prediction
curl -X POST "http://localhost:8000/predict" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "C12345",
"features": {
"tenure_months": 24,
"monthly_charges": 65.50,
"total_charges": 1572.00,
"service_calls": 2,
"contract_duration": "Monthly",
"paperless_billing": 1,
"tech_support": 0,
"online_backup": 1,
"payment_method": "Electronic",
"internet_service": 1,
"streaming_tv": 1,
"streaming_movies": 0,
"device_protection": 1,
"online_security": 0,
"senior_citizen": 0
},
"threshold": 0.5
}'import requests
# Login
response = requests.post(
"http://localhost:8000/token",
data={"username": "analyst", "password": "analyst123"}
)
token = response.json()["access_token"]
# Make prediction
headers = {"Authorization": f"Bearer {token}"}
response = requests.post(
"http://localhost:8000/predict",
headers=headers,
json={
"customer_id": "C12345",
"features": {
"tenure_months": 24,
"monthly_charges": 65.50,
# ... other features
},
"threshold": 0.5
}
)
result = response.json()
print(f"Churn Probability: {result['churn_probability']:.2%}")
print(f"Risk Level: {result['risk_level']}")AutoGluOn_End_to_End/
βββ auth/ # Authentication module
β βββ __init__.py
β βββ authentication.py # JWT, RBAC, user management
β βββ audit_log.py # Audit logging
β βββ README.md
βββ config/
β βββ database.env.template
β βββ security.yaml # Security configuration
βββ data/ # Data extraction & validation
βββ monitoring/ # Data quality monitoring
βββ logs/ # Application & audit logs
β βββ audit/ # Security audit logs
βββ app.py # FastAPI application (secured)
βββ dashboard.py # Streamlit dashboard (secured)
βββ setup_security.py # Security setup script
βββ test_security.py # Security test suite
βββ .env.example # Environment template
βββ requirements.txt # Python dependencies
βββ SECURITY.md # Security documentation
βββ SECURITY_IMPLEMENTATION.md # Implementation guide
python test_security.pyTests include:
- User authentication
- JWT token validation
- Role-based access control
- Audit logging
- Password hashing
# Install httpie
pip install httpie
# Health check (no auth required)
http GET localhost:8000/health
# Login
http POST localhost:8000/login username=admin password=admin123
# Test with auth
http POST localhost:8000/predict Authorization:"Bearer <token>" < customer.json- JWT token-based authentication
- Bcrypt password hashing
- Token expiration (configurable)
- Secure session management
- Role-based access control (RBAC)
- Three-tier permission system
- Endpoint-level protection
- Resource-based access control
- Per-endpoint limits
- IP-based tracking
- Configurable thresholds
- Automatic blocking
- All authentication events
- Prediction tracking
- Failed access attempts
- Admin actions
- Daily log rotation
- Environment variables
- Secure secret management
- YAML configuration
- Production-ready defaults
- Customer overview
- Churn risk metrics
- Prediction interface
- Risk segmentation
- Batch predictions
- Data export
- Analytics views
- Campaign planning
- User management
- Audit log viewing
- System configuration
- Access control
# API
uvicorn app:app --reload
# Dashboard
streamlit run dashboard.py# API with Gunicorn
gunicorn app:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
# Dashboard
streamlit run dashboard.py --server.port 8501 --server.address 0.0.0.0See README_DEPLOYMENT.md for detailed deployment instructions.
# JWT Authentication
JWT_SECRET_KEY=your-secret-key
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Audit Logging
AUDIT_LOG_DIR=./logs/audit
# API Configuration
API_HOST=0.0.0.0
API_PORT=8000roles:
admin:
permissions:
- read
- write
- predict
- batch_predict
- manage_users
rate_limits:
predict_single:
requests: 30
window: "1 minute"View logs in logs/audit/audit_YYYY-MM-DD.jsonl
# View today's logs
cat logs/audit/audit_$(date +%Y-%m-%d).jsonl | jq
# Count events by type
cat logs/audit/*.jsonl | jq -r '.event_type' | sort | uniq -c# Get audit statistics (admin only)
http GET localhost:8000/admin/audit/stats?days=7 Authorization:"Bearer <token>"
# List users (admin only)
http GET localhost:8000/admin/users Authorization:"Bearer <token>"# In auth/authentication.py
class UserRole(str, Enum):
ADMIN = "admin"
ANALYST = "analyst"
VIEWER = "viewer"
DATA_SCIENTIST = "data_scientist" # New role# In app.py
@app.get("/new_endpoint")
async def new_endpoint(
current_user: User = Depends(require_role(UserRole.ANALYST))
):
# Your logic here
passfrom auth.audit_log import get_audit_logger, AuditEventType
logger = get_audit_logger()
logger.log_event(AuditEvent(
event_type=AuditEventType.DATA_EXPORTED,
username=current_user.username,
details={"export_type": "csv", "rows": 1000}
))- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see LICENSE file for details.
This implementation includes demo credentials for ease of use. In production:
- Change all default passwords
- Generate new secret keys
- Enable HTTPS
- Use database-backed user storage
- Implement additional security measures
See SECURITY.md for complete security guidelines.
- Documentation: Check the docs/ folder
- Issues: Open GitHub issue
- Security: Report privately (see SECURITY.md)
Built with: AutoGluon, FastAPI, Streamlit, JWT, and β€οΈ
Version: 1.0
Last Updated: December 28, 2025