Skip to content

muzammilibm/Claims-Reporting-Automation-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Claims Reporting Automation System

A cloud‑native simulation of a real enterprise workflow: mainframe output β†’ report generation (Excel/PDF) β†’ cloud upload β†’ ML-powered predictions β†’ dashboard for download.

This project modernizes a legacy reporting pipeline using FastAPI, React, GCP Cloud Run, Cloud Storage, PostgreSQL, and Python automation β€” all built using mock data (fully safe and compliant).


πŸš€ Features

πŸ”Ή End‑to‑End Automated Reporting

  • Upload mock claim files (CSV/TXT)
  • Parse, clean, and validate data
  • Generate Excel + PDF reports
  • Upload reports to Google Cloud Storage
  • View and download reports from a modern UI

πŸ€– ML-Powered Claims Prediction

  • Predict claim outcomes (Paid/Denied) for pending claims
  • Random Forest classification model
  • Probability scores and confidence levels
  • Interactive dashboard with visual predictions
  • Real-time processing via React frontend

πŸ”Ή Cloud‑Native Architecture

  • Backend: FastAPI on Cloud Run
  • Frontend: React dashboard with Tailwind CSS
  • Storage: Cloud Storage buckets
  • Database: Cloud SQL (PostgreSQL) or SQLite (default)
  • Scheduled jobs via Cloud Scheduler

πŸ”Ή Enterprise‑Grade Modules

  • Clean folder architecture
  • ML model integration
  • RESTful API design
  • Error handling and validation
  • CORS-enabled for frontend integration

πŸ“Έ Screenshots

ML Claims Prediction Dashboard

Claims Prediction UI

Interactive dashboard showing ML predictions for pending claims with probability scores and confidence levels.

API Docs

FastAPI interactive documentation - Shows the /docs endpoint


🧱 Architecture Overview

Client (React)
β†’ Backend API (FastAPI)
β†’ Data Processing (pandas)
β†’ Report Generators (Excel/PDF)
β†’ Cloud Storage (GCP)
β†’ Database (PostgreSQL)

High-Level Workflow

Upload File β†’ Parse & Clean β†’ Aggregate Data 
β†’ Excel/PDF Generation β†’ Upload to GCP β†’ Metadata Saved 
β†’ Dashboard Download

ML Prediction Flow:
Upload CSV β†’ Feature Engineering β†’ Train Model 
β†’ Predict Pending Claims β†’ Display Results in Dashboard

πŸ› οΈ Tech Stack

Frontend

  • React
  • Tailwind CSS
  • Axios
  • Vercel / Cloud Run deployment

Backend

  • FastAPI
  • Python (pandas, numpy, scikit-learn, openpyxl, reportlab)
  • SQLAlchemy
  • Pydantic
  • Google Cloud Storage SDK
  • Machine Learning (Random Forest Classifier)

Cloud

  • Cloud Run
  • Cloud Storage
  • Cloud SQL
  • Cloud Scheduler

πŸ“ Folder Structure

Claims-Reporting-Automation-System/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py                 # FastAPI application
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── reports.py         # API endpoints (upload, predict, list)
β”‚   β”œβ”€β”€ ml/
β”‚   β”‚   └── claims_predictor.py # ML model for predictions
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── report.py          # SQLAlchemy Report model
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”œβ”€β”€ base.py            # Database base
β”‚   β”‚   └── session.py        # Database session
β”‚   └── services/
β”‚       β”œβ”€β”€ excel_generator.py # Excel/PDF report generation
β”‚       β”œβ”€β”€ ml_service.py      # ML service wrapper
β”‚       └── storage.py        # Google Cloud Storage
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   └── ClaimsPredictor.js  # ML prediction UI
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── reports.js         # API client
β”‚   β”‚   β”œβ”€β”€ App.js
β”‚   β”‚   └── index.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── tailwind.config.js
β”œβ”€β”€ sample_data/
β”‚   └── claims_export_2025.txt # Sample claims data
β”œβ”€β”€ requirements.txt            # Python dependencies
└── README.md

πŸ§ͺ Sample Mock Data

Sample data is located in sample_data/claims_export_2025.txt:

ClaimID,Status,Amount,Date,Type
C001,Paid,550.25,2025-01-11,Medical
C002,Denied,200.00,2025-01-14,Dental
C003,Pending,130.50,2025-01-17,Vision
C004,Paid,1250.75,2025-01-18,Medical
...

Required Columns:

  • ClaimID: Unique identifier
  • Status: One of "Paid", "Denied", or "Pending"
  • Amount: Numeric claim amount
  • Date: Date in YYYY-MM-DD format
  • Type: Claim type (e.g., "Medical", "Dental", "Vision")

πŸ”Œ API Endpoints

Reports

  • POST /reports/upload - Upload CSV file, generate Excel/PDF reports, upload to GCS
  • POST /reports/predict - Upload CSV file, get ML predictions for pending claims
  • GET /reports - List all processed reports

System

  • GET /health - Health check endpoint

Interactive API Documentation

  • GET /docs - Swagger UI (FastAPI auto-generated docs)
  • GET /redoc - ReDoc documentation

πŸ“œ Environment Variables

Create .env file in project root:

# Database (optional - defaults to SQLite)
DATABASE_URL=postgresql://user:pass@host:port/db

# Google Cloud Storage (required for file uploads)
GCP_BUCKET_NAME=your-bucket-name

# Frontend API URL (optional)
REACT_APP_API_URL=http://localhost:8000

Note: See SETUP_ENV.md for detailed setup instructions.


▢️ How to Run Locally

Prerequisites

  • Python 3.11+ with virtual environment
  • Node.js 16+ and npm
  • (Optional) PostgreSQL for production-like setup

Backend Setup

  1. Create and activate virtual environment:

    python -m venv venv
    venv\Scripts\activate  # Windows
    # or
    source venv/bin/activate  # Linux/Mac
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure environment variables:

    • Copy .env.example to .env (if exists)
    • Set DATABASE_URL (optional - defaults to SQLite)
    • Set GCP_BUCKET_NAME (required for file uploads)
  4. Start the server:

    uvicorn app.main:app --reload

    Server runs at: http://localhost:8000

    • API Docs: http://localhost:8000/docs
    • Health Check: http://localhost:8000/health

Frontend Setup

  1. Navigate to frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start development server:

    npm start

    Frontend runs at: http://localhost:3000

Quick Test

  1. Start backend: uvicorn app.main:app --reload
  2. Start frontend: cd frontend && npm start
  3. Open http://localhost:3000
  4. Upload sample_data/claims_export_2025.txt for ML predictions

☁️ Deployment

Backend on Cloud Run

  • Build Docker image
  • Push to Container Registry
  • Deploy with Cloud SQL + Cloud Storage permissions

Frontend

  • Deploy to Vercel or Cloud Run

Scheduler

  • Cloud Scheduler β†’ calls /reports/generate on cron

πŸ“š Documentation

πŸ“Œ Features & Capabilities

Current Features

βœ… CSV/TXT file upload and validation
βœ… Excel and PDF report generation
βœ… Google Cloud Storage integration
βœ… ML-powered claims prediction
βœ… Interactive React dashboard
βœ… RESTful API with auto-generated docs
βœ… SQLite (default) or PostgreSQL support

Future Enhancements

  • Model persistence (save/load trained models)
  • Prediction history in database
  • Batch processing for large files
  • Export predictions as CSV
  • Role-based access control
  • Email notifications
  • Additional file formats
  • Multi-file parallel processing

πŸ“„ License

MIT License


🀝 Contributions

PRs and improvements are welcome!


πŸ§ͺ Testing the ML Prediction

  1. Start both servers (backend and frontend)
  2. Upload sample data:
    • Go to http://localhost:3000
    • Click "Select CSV/TXT File"
    • Choose sample_data/claims_export_2025.txt
    • Click "Predict Claims"
  3. View results:
    • See summary statistics
    • Review predictions table with probabilities
    • Check denial risk scores

πŸ”§ Troubleshooting

Common Issues

Import errors (sklearn, numpy):

pip install scikit-learn==1.3.2 numpy==1.26.4

CORS errors:

  • Backend includes CORS middleware for localhost:3000
  • Check app/main.py for CORS configuration

File not found:

  • Ensure sample_data/claims_export_2025.txt exists
  • Check file path in ML predictor script

Frontend connection errors:

  • Verify backend is running on port 8000
  • Check REACT_APP_API_URL in frontend .env

See ML_INTEGRATION_GUIDE.md for detailed troubleshooting.

⭐ Acknowledgment

This project is a modern cloud implementation inspired by the typical mainframe β†’ reporting β†’ SharePoint workflow used in enterprise environments, redesigned using modern engineering practices for learning and demonstration.


Built with: FastAPI β€’ React β€’ Tailwind CSS β€’ scikit-learn β€’ pandas β€’ PostgreSQL/SQLite β€’ Google Cloud Storage

About

An AI-assisted prototype exploring modernization concepts for legacy reporting pipelines using FastAPI, React, PostgreSQL, and GCP services. Development is currently paused due to over-reliance on AI-generated inputs, with plans to revisit using tighter human-in-the-loop controls.

Topics

Resources

Stars

Watchers

Forks

Contributors