This repository is publicly visible for portfolio and educational review purposes only.
Unauthorized reuse, reproduction, modification, deployment, redistribution, or commercial usage of this project or its components is strictly prohibited.
Copyright 2026 Rudra Tyagi. All Rights Reserved.
PhishGuard AI is a production-oriented phishing detection MLOps system that classifies URL/network-security feature records as phishing or legitimate.
The system combines:
- FastAPI inference services
- Modular ML training pipeline
- Schema validation and drift detection
- Scikit-learn and XGBoost model selection
- MLflow experiment tracking
- DVC and DagsHub artifact versioning
- MongoDB Atlas data ingestion and prediction audit logging
- Docker packaging
- GitHub Actions CI/CD
- AWS ECR and ECS Fargate deployment assets
to create an end-to-end phishing detection platform suitable for local development, reproducible training, and cloud deployment.
The goal of PhishGuard AI is to provide a scalable phishing-risk classification service with reproducible ML lifecycle practices.
URL / Network Feature Data
|
Data Ingestion
|
Schema Validation + Drift Detection
|
Feature Imputation
|
Model Selection + Training
|
MLflow Tracking
|
DVC-Versioned Artifacts
|
FastAPI Batch Prediction
|
Prediction Logging
|
AWS-Ready Deployment
| Prediction Type | Status |
|---|---|
| Phishing URL / malicious record detection | Supported |
| Legitimate URL / safe record detection | Supported |
| Batch CSV prediction | Supported |
| Prediction audit logging | Supported |
CSV Upload from Web UI
|
FastAPI /predict Route
|
Target Column Removed if Present
|
Saved Preprocessor Loaded
|
Saved Classification Model Loaded
|
Batch Predictions Generated
|
Results Written to prediction_output/output.csv
|
Predictions Logged to JSONL and optionally MongoDB
|
HTML Result Table Rendered
|
CSV Download Available from /download
Local CSV or MongoDB Atlas
|
Data Ingestion Layer
|
Data Validation Layer
|
Data Transformation Layer
|
Model Training Layer
|
MLflow + DagsHub Tracking
|
DVC Dataset and Model References
|
FastAPI Application
|
Frontend Templates and Static Assets
|
Docker Container
|
GitHub Actions
|
Amazon ECR + ECS Fargate
Model and dataset artifacts are versioned with DVC and configured for DagsHub remote storage. S3 syncing support exists in the codebase, but the current model artifact workflow is DVC/DagsHub-focused.
- HTML
- CSS
- JavaScript
- Jinja2 templates
- CSV upload interface
- Prediction result rendering
- Batch summary display
- Download link for generated prediction output
- Static UI assets under
frontend/static
- FastAPI
- Uvicorn
- Jinja2Templates
- API routing
- CORS configuration
- Health checks
- Optional training endpoint
- Batch prediction orchestration
- Model and preprocessor loading
- Prediction output generation
- Prediction logging
Key routes:
| Route | Method | Responsibility |
|---|---|---|
/ |
GET | Render upload UI |
/health |
GET | Application and artifact health status |
/health/mongodb |
GET | Optional MongoDB connectivity check |
/train |
GET | Run training pipeline when enabled |
/predict |
POST | Run batch CSV prediction |
/download |
GET | Download latest prediction CSV |
- Pandas
- MongoDB Atlas
- Local CSV datasets
- Load data from local CSV or MongoDB Atlas
- Export feature-store CSV artifacts
- Split train and test datasets
- Support reproducible local training through
DATA_INGESTION_SOURCE=local - Support Atlas-backed production ingestion through
DATA_INGESTION_SOURCE=mongodb
- Scikit-learn
- XGBoost
- NumPy
- Pandas
- Feature preprocessing with
KNNImputer - Classification model training
- Candidate model comparison with
GridSearchCV - F1-score based model selection
- Final model and preprocessor serialization
- Batch inference through the
NetworkModelwrapper
- PyYAML
- SciPy KS test
- JSONL logging
- MongoDB prediction-log collection
- Validate dataset columns against
data_schema/schema.yaml - Detect train/test drift
- Write drift reports to training artifacts
- Log every prediction request locally to
logs/predictions.jsonl - Optionally persist prediction logs to MongoDB Atlas
- DVC
- DagsHub
- MLflow
- Docker
- GitHub Actions
- AWS ECR
- AWS ECS Fargate
- AWS Secrets Manager
- Version datasets and final model artifacts
- Track training experiments and model metrics
- Build and health-check Docker images
- Validate project structure in CI
- Deploy container images to AWS ECS Fargate
- Keep credentials externalized through environment variables and cloud secrets
Classifies network-security feature rows into phishing or legitimate outcomes using supervised classification models.
The /predict endpoint accepts CSV uploads, runs inference over all rows, adds a predicted_column, and stores the result in:
prediction_output/output.csv
The training pipeline is split into separate components:
- Data ingestion
- Data validation
- Data transformation
- Model training
- MLflow tracking
- Artifact persistence
The project validates incoming training data against:
data_schema/schema.yaml
The schema currently defines 30 phishing-related numeric features plus the Result target column.
Training and test splits are compared during validation. Numeric columns use the Kolmogorov-Smirnov test, while non-numeric columns use normalized distribution differences.
The trainer evaluates multiple classifier families and selects the model with the best F1 score.
Supported candidates include:
- Random Forest
- Decision Tree
- Gradient Boosting
- Logistic Regression
- AdaBoost
- XGBoost, when installed
Training runs log parameters, metrics, and artifacts to MLflow. When DagsHub settings are configured, MLflow tracking is routed to the DagsHub repository.
Every prediction row is logged with:
- Request ID
- Timestamp
- Source
- Row index
- Input features
- Prediction
Logs are written locally and optionally inserted into MongoDB Atlas.
phising-detection-mlops-system/
|
|-- app.py
|-- main.py
|-- push_data.py
|-- config.yaml
|-- requirements.txt
|-- setup.py
|-- pyproject.toml
|-- Dockerfile
|-- docker-compose.yml
|-- dvc_workflow.txt
|
|-- .github/
| |-- workflows/
| |-- ci.yml
| |-- cd.yml
|
|-- data_schema/
| |-- schema.yaml
|
|-- demo_data/
| |-- recruiter_demo.csv
|
|-- deploy/
| |-- aws/
| |-- ecs-task-definition.json
|
|-- docs/
| |-- ARCHITECTURE.md
| |-- AWS_DEPLOYMENT.md
| |-- DOCKER.md
| |-- DVC_DAGSHUB_MLFLOW.md
| |-- GITHUB_ACTIONS.md
| |-- LOCAL_DEVELOPMENT.md
| |-- MONGODB_ATLAS.md
|
|-- final_model/
| |-- model.pkl.dvc
| |-- preprocessor.pkl.dvc
|
|-- frontend/
| |-- templates/
| | |-- index.html
| | |-- table.html
| |-- static/
| |-- css/
| |-- js/
|
|-- network_data/
| |-- phisingData.csv.dvc
|
|-- network_security/
| |-- cloud/
| |-- components/
| |-- config/
| |-- constant/
| |-- db/
| |-- entity/
| |-- exception/
| |-- logging/
| |-- monitoring/
| |-- pipeline/
| |-- tracking/
| |-- utils/
|
|-- scripts/
| |-- check_dvc_setup.py
| |-- validate_project.py
| |-- validate_secrets.py
|
|-- tests/
| |-- test_api_health.py
| |-- test_config.py
| |-- test_dvc_metadata.py
| |-- test_fetch_data.py
| |-- test_mongodb.py
The model expects phishing-detection feature columns such as:
having_IP_AddressURL_LengthShortining_Servicehaving_At_SymbolSSLfinal_StateDomain_registeration_lengthHTTPS_tokenURL_of_Anchorweb_trafficPage_RankGoogle_IndexStatistical_report
The target column is:
Result
During transformation, Result = -1 is normalized to 0.
| Component | Responsibility |
|---|---|
data_ingestion.py |
Read local or MongoDB data, write feature store, split train/test |
data_validation.py |
Validate schema and generate drift report |
data_transformation.py |
Apply KNN imputation and persist transformed arrays |
model_trainer.py |
Train candidate models, select best F1 model, log MLflow run |
training_pipeline.py |
Orchestrate end-to-end training |
estimator.py |
Wrap preprocessor and model for prediction |
prediction_logger.py |
Log prediction records locally and optionally to MongoDB |
settings.py |
Load config.yaml and environment overrides |
PhishGuard AI uses MLflow for training visibility and DVC for reproducibility.
Tracked training outputs include:
- Best model name
- Expected score
- Scoring metric
- Train F1, precision, and recall
- Test F1, precision, and recall
- Serialized model artifact
- Serialized preprocessing artifact
DVC-tracked artifacts include:
network_data/phisingData.csv
final_model/model.pkl
final_model/preprocessor.pkl
The repository includes .dvc pointer files for these assets, so the real dataset and model binaries can be pulled from the configured DVC remote.
git clone <repository-url>
cd phising-detection-mlops-systempython -m venv .venv
.\.venv\Scripts\Activate.ps1python -m venv .venv
source .venv/bin/activatepip install --upgrade pip
pip install -r requirements.txt
pip install -e .Create a local .env from the example file.
Copy-Item .env.example .envcp .env.example .envImportant variables:
APP_ENV=development
DATA_INGESTION_SOURCE=local
LOCAL_DATA_FILE_PATH=network_data/phisingData.csv
MONGODB_URI=your_mongodb_atlas_uri
DAGSHUB_REPO_OWNER=your_dagshub_username_or_org
DAGSHUB_REPO_NAME=phising-detection-mlops-system
DAGSHUB_TOKEN=your_dagshub_token
MLFLOW_TRACKING_URI=your_mlflow_tracking_uri
API_HOST=0.0.0.0
API_PORT=8000
TRAINING_ENDPOINT_ENABLED=trueAfter configuring the DVC remote and credentials:
dvc pullpython scripts/validate_project.py
python scripts/check_dvc_setup.py
pytest -qpython main.pyTraining can also be triggered from the API when TRAINING_ENDPOINT_ENABLED=true:
GET /train
uvicorn app:app --host 0.0.0.0 --port 8000 --reloadApplication URLs:
Web UI: http://localhost:8000
API docs: http://localhost:8000/docs
Health: http://localhost:8000/health
MongoDB health: http://localhost:8000/health/mongodb
docker compose up --build apidocker build -t phishguard-ai:local .
docker run --env-file .env -p 8000:8000 phishguard-ai:localThe container exposes port 8000 and includes a /health health check.
- Complete and wire the standalone
batch_prediction.pypipeline module - Add richer API request validation for uploaded CSV files
- Add model performance reports to the UI
- Add automated DVC artifact pull checks before application startup
- Add more tests around prediction logging and training pipeline behavior
- Add Airflow orchestration for scheduled retraining
- Add SageMaker training and model registry integration
- Add AWS S3 data lake support where required
- Add model monitoring dashboards
- Add drift-triggered retraining workflows
- Add blue/green or canary deployment on ECS
- Add authentication and authorization for training/admin endpoints
| Layer | Technologies |
|---|---|
| Backend | FastAPI, Uvicorn, Jinja2 |
| ML | Scikit-learn, XGBoost, NumPy, Pandas |
| Validation | PyYAML, SciPy KS test |
| Database | MongoDB Atlas |
| Tracking | MLflow, DagsHub |
| Versioning | DVC |
| Frontend | HTML, CSS, JavaScript |
| Packaging | setuptools, pyproject.toml |
| Testing | pytest |
| Containerization | Docker, Docker Compose |
| CI/CD | GitHub Actions |
| Cloud | AWS ECR, ECS Fargate, Secrets Manager |
- Architecture Overview
- Local Development Guide
- Docker Guide
- DVC, DagsHub, and MLflow Guide
- MongoDB Atlas Guide
- AWS Deployment Guide
- GitHub Actions Guide



Rudra Tyagi
- ML Systems
- MLOps
- Cloud-Native AI Infrastructure
- Cybersecurity AI
- Production ML Deployment
This project demonstrates:
- End-to-end ML system design
- Phishing detection classification workflow
- FastAPI backend development
- Modular ML pipeline architecture
- Data validation and drift detection
- MLflow experiment tracking
- DVC dataset and model versioning
- MongoDB Atlas integration
- Prediction audit logging
- Dockerized deployment workflow
- GitHub Actions CI/CD
- AWS ECR and ECS Fargate deployment planning
- Create the DagsHub repository and update
DVC_REMOTE_URL,DAGSHUB_REPO_OWNER, andDAGSHUB_REPO_NAME. - Push or pull current DVC artifacts after DagsHub credentials are configured.
- Create the MongoDB Atlas cluster, database user, network access entry, and set
MONGODB_URI. - Create AWS ECR, ECS, IAM, CloudWatch, and Secrets Manager resources listed in
docs/AWS_DEPLOYMENT.md. - Add GitHub repository secrets listed in
docs/GITHUB_ACTIONS.md.
This repository is proprietary software.
Unauthorized copying, modification, distribution, deployment, or commercial use is prohibited.