An AI-powered web application that automatically classifies home loan application documents using AWS Textract for OCR and AWS Bedrock for machine learning classification.
- Automatic Document Classification: Classifies 6 types of home loan documents
- AI-Powered OCR: Extracts text using AWS Textract with PyPDF fallback
- Machine Learning: Classification using AWS Bedrock (Claude) with offline fallback
- Web Interface: Modern, responsive UI with drag-and-drop file upload
- Model Evaluation: Comprehensive evaluation dashboard with metrics and visualizations
- Real-time Processing: Background task processing with progress tracking
- Cloud-Ready: Easy deployment to Render cloud platform
- 📄 Government ID - Driver's License, Passport, National ID
- 💰 Payslip - Income statements, Pay stubs
- 🏦 Bank Statement - Account statements, Transaction records
- 💼 Employment Letter - Job verification, Employment confirmation
- ⚡ Utility Bill - Electric, Gas, Water, Internet bills
- 🐷 Savings Statement - Investment accounts, Savings records
-
Clone the repository
git clone <your-repo-url> cd document_classification_homeloan
-
Create virtual environment
python3 -m venv venv_linux source venv_linux/bin/activate # Linux/Mac # or venv_linux\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables (optional)
cp .env.example .env # Edit .env with your AWS credentials -
Run the application
python main.py
-
Access the application
- Main interface: http://localhost:8000
- Model evaluation: http://localhost:8000/evaluation-standalone
- Push to GitHub
- Deploy to Render - See DEPLOYMENT.md for detailed instructions
- Set AWS credentials in Render environment variables (optional)
The system includes a comprehensive evaluation interface:
- Batch Testing: Upload multiple labeled documents for testing
- Performance Metrics: Accuracy, Precision, Recall, F1-Score
- Confusion Matrix: Visual classification performance analysis
- Per-Class Metrics: Individual document type performance
- Export Results: Download evaluation reports
Access at: /evaluation-standalone
document_classification_homeloan/
├── src/
│ ├── api/ # FastAPI routes and endpoints
│ ├── classification/ # Document classification logic
│ ├── evaluation/ # Model evaluation system
│ ├── utils/ # Configuration and utilities
│ └── web/ # Web interface
│ ├── templates/ # HTML templates
│ └── static/ # CSS, JS, assets
├── data/ # Data storage
│ ├── uploads/ # Uploaded files
│ └── results/ # Classification results
├── main.py # Application entry point
├── requirements.txt # Python dependencies
├── render.yaml # Render deployment config
└── README.md # This file
- Backend: FastAPI, Python 3.11+
- AI/ML: AWS Textract, AWS Bedrock (Claude), scikit-learn
- Frontend: HTML5, Bootstrap 5, JavaScript
- Data Processing: pandas, numpy
- Visualization: matplotlib, seaborn
- Deployment: Render (native Python)
- File type validation and size limits
- Content-based file validation using python-magic
- Secure environment variable handling
- HTTPS enforcement on deployment
- Input sanitization and validation
Key environment variables:
# AWS Configuration (optional)
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
# Application Settings
ENVIRONMENT=production
LOG_LEVEL=INFO
MAX_FILE_SIZE=20971520 # 20MBThe system gracefully handles AWS service unavailability:
- Text Extraction: Falls back from AWS Textract to PyPDF
- Classification: Falls back from AWS Bedrock to rule-based classifier
- Offline Mode: Fully functional without AWS credentials
- Processing Time: ~30 seconds per document (with AWS services)
- Accuracy: 95%+ with proper training data
- File Support: PDF documents up to 20MB
- Concurrent Users: Scalable with background task processing
The system includes comprehensive testing capabilities:
- Unit tests with pytest
- API endpoint testing
- UI component testing
- End-to-end workflow testing
Run tests:
pytest tests/- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.
For deployment issues, see DEPLOYMENT.md or create an issue in the repository.
Live Demo: https://document-classification-system.onrender.com