FraudShield is a mobile-first web app for detecting fraud in mobile-money transactions. It is designed as a final-year project with a polished analyst dashboard, FastAPI backend, SQLite demo database, and an offline machine-learning training pipeline for the PaySim dataset.
- Dark fintech React dashboard for an admin fraud analyst.
- Receipt screenshot upload/check workflow for Nigerian fintech and bank receipts.
- Student-facing link and payment-prompt verification page.
- Admin fraud-signature database for suspicious domains, keywords, and patterns.
- FastAPI backend with seeded demo transactions and seeded fraud signatures.
- Single-transaction fraud prediction.
- CSV upload with row-level validation errors.
- Review queue for marking transactions as fraud, legitimate, or needs review.
- Analytics for transaction risk, receipt checks, link checks, student reports, signatures, and real trained model metrics.
- Offline training script for PaySim with temporal split, class imbalance handling, PR-AUC, F2-score, and leakage-aware feature comparisons.
FraudShield/
backend/
app/
main.py
database.py
model_service.py
link_service.py
ocr_service.py
receipt_service.py
schemas.py
ml/
train_model.py
models/
data/
requirements.txt
frontend/
src/
components/
pages/
lib/
styles.css
package.json
sample_transactions.csv
cd FraudShield/backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000The API will seed SQLite automatically on first startup.
Health check:
curl http://localhost:8000/healthcd FraudShield/frontend
npm install
npm run devOpen:
http://localhost:5173
If the backend is hosted elsewhere, set:
VITE_API_BASE_URL=https://your-api-url npm run devDownload the PaySim mobile-money fraud dataset and run the training script from the FraudShield directory:
cd FraudShield
python backend/ml/train_model.py --input /path/to/paysim.csvThe script saves:
backend/models/fraud_model.joblib
backend/models/model_metrics.json
The FastAPI service automatically uses fraud_model.joblib when it exists. Without it, the API uses a clearly labeled demo fallback scorer so the app remains runnable.
- PaySim is simulated mobile-money data.
- Fraud labels appear only in
TRANSFERandCASH_OUT. - Balance fields can leak simulated fraud behavior.
- The training script compares a full feature set against a no-balance feature set.
- Train/test split is temporal using the
stepcolumn. - Model selection uses PR-AUC, F2-score, precision, recall, ROC-AUC, and confusion matrix.
- The final report should discuss leakage and class imbalance directly.
GET /healthPOST /predictPOST /receipts/uploadGET /receiptsGET /receipts/{id}GET /receipts/{id}/imagePATCH /receipts/{id}/reviewPOST /verify-linkPOST /reportsGET /reportsGET /link-checksGET /fraud-signaturesPOST /fraud-signaturesPATCH /fraud-signatures/{id}DELETE /fraud-signatures/{id}POST /transactions/uploadGET /transactionsGET /transactions/{id}PATCH /transactions/{id}/reviewGET /analytics
Use sample_transactions.csv from this folder on the Upload page.
Recommended Chapter One objectives are available in docs/evaluation-objectives.md. They align the written project with the implemented React/FastAPI/SQLite stack and the combined transaction plus link-verification functionality.
Receipt upload works without OCR installed, but records will be flagged with low OCR quality. For real text extraction install Tesseract and Python OCR dependencies:
sudo apt-get install -y tesseract-ocr
cd FraudShield/backend
pip install -r requirements.txtThe receipt module extracts provider, amount, status, reference, sender, receiver, and date when OCR text is available.