A production-grade End-to-End MLOps System for detecting phishing URLs using machine learning, cloud services, Docker, and CI/CD automation.
The system follows a modular architecture with the following components:
- Client: User-facing browser/app interface
- FastAPI Service: Inference API running in Docker on EC2
- Training Pipeline: Automated ML pipeline for data processing and model training
- Data & Storage: AWS S3 for data storage and DVC for version control
- Tracking: MLflow + DagsHub for experiment tracking
- CI/CD: GitHub Actions for automated testing, building, and deployment to AWS ECR
network-security-mlops/
│
├── app.py
├── main.py
├── Dockerfile
├── requirements.txt
├── setup.py
├── README.md
│
├── config/
│ └── schema.yaml
│
├── .github/
│ └── workflows/
│ └── main.yml
│
├── Artifacts/
│
├── networksecurity/
│ ├── components/
│ │ ├── data_ingestion.py
│ │ ├── data_validation.py
│ │ ├── data_transformation.py
│ │ ├── model_trainer.py
│ │
│ ├── entity/
│ │ ├── config_entity.py
│ │ ├── artifact_entity.py
│ │
│ ├── pipeline/
│ │ └── training_pipeline.py
│ │
│ ├── utils/
│ │ ├── main_utils.py
│ │ ├── ml_utils.py
│ │
│ ├── cloud/
│ │ └── s3_syncer.py
│ │
│ ├── logging/
│ │ └── logger.py
│ │
│ ├── exception/
│ │ └── exception.py
│ │
│ └── constant/
│ └── training_pipeline.py
│
└── dvc.yaml
The training pipeline consists of four main stages:
- Downloads dataset from source
- Splits data into training and testing sets
- Stores artifacts locally and on AWS S3
- Performs schema validation checks
- Identifies missing values
- Generates validation reports
- Applies StandardScaler normalization
- Encodes categorical variables
- Saves preprocessor as joblib file
- Trains multiple ML algorithms
- Performs hyperparameter tuning with GridSearchCV
- Automatically selects the best model
- Logs experiments to MLflow
- Saves model artifacts to AWS S3
uvicorn app:app --reload --port 8080{
"url_length": 50,
"https": 1,
"domain_age": 5,
"has_special_chars": 0
}{
"prediction": 0,
"label": "Safe URL"
}docker build -t networksecurity .docker run -p 8080:8080 networksecurityThe system features a fully automated deployment pipeline:
- Push code to main branch
- CI Stage: Runs linting and tests
- Build Stage: Docker image is built
- Push Stage: Image pushed to AWS ECR
- EC2 Deployment: Self-hosted runner pulls latest image
- Stops old container
- Runs new container
- API becomes live instantly
- Python
- NumPy
- Pandas
- Scikit-Learn
- GridSearchCV
- Joblib
- MLflow
- DVC
- Docker
- GitHub Actions
- AWS S3
- AWS ECR
- AWS EC2
- FastAPI
- Uvicorn
To execute the complete training pipeline:
python main.pyHamza Khan
📧 Email: hamzahere52@gmail.com
🔗 GitHub: https://github.com/Hamzakhan001