Logo Lanfrica

ozgegurel/mpesa-credit-assessment-api

Domain:

socioeconomic

Record type:

software
Creator:
ozg
Host:
FastAPI-based M-Pesa credit assessment API with MongoDB and Google Cloud Run deployment. # M-Pesa Credit Assessment API A secure REST API for credit assessment based on M-Pesa transaction statements from Kenya. This FastAPI service analyzes transaction patterns to calculate credit scores and risk categories for users. ## πŸš€ Live Deployment **API URL:** `mpesa-api-xxxxx-uc.a.run.app` (Replace with your actual Cloud Run URL) **Health Check:** `GET mpesa-api-xxxxx-uc.a.run.app` ## πŸ“‹ Table of Contents - Features - Architecture - Project Structure - Quick Start - API Documentation - Credit Scoring Algorithm - Environment Variables - Docker Deployment - Google Cloud Run Deployment - Testing - Design Decisions - Troubleshooting ## ✨ Features - **Secure Authentication**: HTTP Basic Auth with bcrypt password hashing - **Credit Scoring**: Intelligent algorithm analyzing 5 key financial factors - **MongoDB Integration**: Efficient queries with proper indexing - **Docker Support**: Containerized for easy deployment - **Cloud Ready**: Deployed on Google Cloud Run - **Comprehensive Testing**: Unit tests with pytest - **Auto Documentation**: OpenAPI/Swagger docs - **CORS Support**: Ready for frontend integration ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€-┐ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Client App │───▢│ FastAPI API │───▢│ MongoDB Atlas β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - Web Frontend β”‚ β”‚ - Authentication β”‚ β”‚ - User Data β”‚ β”‚ - Mobile App β”‚ β”‚ - Credit Scoring β”‚ β”‚ - Transactions β”‚ β”‚ - Postman β”‚ β”‚ - Data Validationβ”‚ β”‚ - Indexes β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ └─────────────────-β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ### Core Components - **FastAPI Application**: Main API server with async support - **MongoDB Database**: Stores user profiles and transaction data - **Credit Scorer**: Rule-based algorithm for risk assessment - **Authentication**: Secure user verification system - **Docker Container**: Portable deployment unit ## πŸ“ Project Structure ``` …

Languages