How shalani98/fraud-detection-system works
What this project is (type + purpose)
This is a full-stack fraud detection web app:
• Frontend: React (Vite-based) UI that collects credit card feature inputs and calls an API.
• Backend: Flask API that loads a pre-trained scikit-learn model from fraud_model.pkl and returns a fraud prediction.
• Data: data/creditcard.csv is the dataset used for training/validation (in this repo it’s more “artifact/reference data” than a runtime dependency).
• Deployment target: AWS EC2 running the built frontend + Flask API.
Frontend (React/Vite)
• frontend/src/* (runtime UI code)
• frontend/src/pages/Web.jsx likely the main page that submits input
• frontend/src/App.jsx, main.jsx entry points
• frontend/dist/* (production build artifacts: static HTML/CSS/JS)
• frontend/dist/index.html
• frontend/dist/assets/index-*.js, index-*.css
• frontend/package.json, vite.config.js (build + dev tooling)
Backend (Flask + ML inference)
• backend/app.py (Flask server + API routes; loads model)
• backend/fraud_model.pkl (model artifact used at runtime)
• backend/requirements.txt (dependencies: Flask, scikit-learn, etc.)
Data
• data/creditcard.csv (dataset; not necessarily used at runtime)
Deployment (EC2)
README states “production-ready code deployed on AWS EC2”.
• Flask backend process
• Static frontend (either served by a separate static server or potentially by Flask / a web server)
User Browser → Frontend (React SPA)
• Browser loads static assets (HTML/CSS/JS)
Frontend (React) → Backend API (Flask)
• HTTP requests (likely JSON)
• Endpoint conceptually as: POST /predict (or similar; confirm by reading backend/app.py)
Backend API (Flask) → Model Artifact (fraud_model.pkl)
• On startup or first request: “load pickle”
• On request: “run model.predict(...) / predict_proba(...)”
Backend API → Frontend
• Response: prediction result (fraud / not fraud, probability, etc.)
Optional but accurate additions:
• Training pipeline (offline): creditcard.csv → training script (not present in tree) → fraud_model.pkl
• As a separate lane (“Offline training”) even if training code isn’t included, because the artifact exists and must come from somewhere.
Architectural patterns to highlight (based on structure)
• SPA + REST API separation (clear frontend/backend split)
• Artifact-based ML inference (pickle file shipped with the backend)
• Single-node deployment (EC2 hosting both layers) unless you split them in production
• Build step (Vite builds src → dist)
• “Build-time components” vs “Run-time components”
• “Offline ML lifecycle” vs “Online inference”
Use labels that tie directly to the repo to avoid hand-wavy architecture:
• “React UI (frontend/src, built to frontend/dist via Vite)”
• “Flask API (backend/app.py)”
• “scikit-learn model (backend/fraud_model.pkl)”
• “Dataset (offline): data/creditcard.csv”
• “AWS EC2 instance (production host)”
• “HTTP(S) JSON: feature vector → prediction”
• “Returns: fraud flag / probability”
“Don’t overthink it” but still be very detailed: component checklist
To “separate into as many components as possible” (without inventing things), include:
Runtime:
• Browser
• Static asset hosting (dist)
• Flask web server
• Prediction endpoint handler (inside Flask)
• Feature preprocessing step (if present in app.py; verify)
• Model loader
• Model inference
Offline/Build:
• React source → build → dist
• Dataset → training → pickle
Deployment:
• EC2 as the hosting boundary