How gouravverma23/mplads-risk-analytics works
This repository implements a FastAPI risk analytics service for public-works expenditures and project execution. Users submit single or batch records; the API engineers features from the records and historical CSV baselines, scores them with the corresponding anomaly or execution model, and returns risk metrics, explanations, flags, and recommended actions. The two pillars share the API but have distinct feature-engineering and scoring stages. The sampled source supports these request paths and model/index responsibilities; startup wiring and some endpoint details are only partially shown, so uncertain links are omitted.
Main entry points: main.py FastAPI service · execution_feature_engineering.py Execution features · feature_engineering.py Expenditure features · expenditure_anomaly_model.joblib Expenditure model artifact
Components 16
API and contracts
- FastAPI service
app/main.py - Expenditure contracts
app/schemas/expenditure_schema.py - Work contracts
app/schemas/execution_schema.py
Expenditure risk
- Expenditure features
app/services/feature_engineering.py - Expenditure scorer
ExpenditureModelModule.py - Expenditure model artifact
models/expenditure_anomaly_model.joblib
Execution risk
- Execution features
app/services/execution_feature_engineering.py - Execution scorer
ExecutionModelModule.py - Execution model artifact
models/execution_delay_model.joblib
Historical data
- Expenditure history
New Datasets/Expenditures Lok Sabha.csv - MP allocations
New Datasets/Allocated Limit MP Lok Sabha.csv - Recommended works
New Datasets/Works Recommended.csv - Sanctioned works
New Datasets/Works Sanctioned.csv - Completed works
New Datasets/Works Completed.csv
Other components
- API client
- Risk results
Connections 16
- API client → FastAPI service: submits request
- FastAPI service → Expenditure contracts: validates expenditure
- FastAPI service → Work contracts: validates work
- FastAPI service → Expenditure features: engineers features
- FastAPI service → Expenditure scorer: scores transaction
- FastAPI service → Execution features: engineers features
- FastAPI service → Execution scorer: scores project
- Expenditure history → Expenditure features: historical records
- MP allocations → Expenditure features: budget baseline
- Recommended works → Execution features: work history
- Sanctioned works → Execution features: work history
- Completed works → Execution features: completion history
- Expenditure model artifact → FastAPI service: loaded at startup
- Execution model artifact → FastAPI service: loaded at startup
- FastAPI service → Risk results: returns scores
- Risk results → API client: delivers response