How ai4devsec/minor-project-2 works
Project type and purpose
• This is a full-stack machine-learning web application.
• It provides a web UI (Flask + Jinja2 templates) to serve model predictions, plus a standalone training pipeline (Python scripts + Jupyter notebook).
• It uses Docker for containerization, GitLab CI for build/test, and Kubernetes for deployment.
Main components
A. User & UI Layer
– Browser / End-User
– Static assets (Code/static/style.css)
– HTML templates (Code/templates/index.html)
B. Application Server
– Flask app (Code/application.py)
– Business logic / request handling
C. Model & Code Modules
– src/data_processing.py (data cleaning/feature engineering)
– src/model_training.py (model creation, evaluation)
– src/custom_exception.py, src/logger.py (support)
D. Training Pipeline
– pipeline/training_pipeline.py (orchestrates data load → preprocessing → training → model artifact save)
– notebook/iris.ipynb (exploratory analysis)
– DATA/data.csv (raw data source)
E. CI/CD & Build
– .gitlab-ci.yml (defines stages: test, build, train, deploy)
– setup.py, requirements.txt (package metadata)
F. Container & Deployment
– Dockerfile (build image containing app & dependencies)
– Kubernetes deployment manifest (Code/kubernetes-deployment.yaml)
G. Artifact & Model Storage (implicit)
– Docker image registry (e.g., GitLab Registry)
– Model artifacts saved in container filesystem or mounted volume
Relationships & Data Flows
1. Developer pushes code → GitLab CI triggers pipeline.
2. CI runs unit tests, training pipeline (produces model.pkl), builds Docker image.
3. Image (with model embedded) is pushed to registry.
4. Kubernetes pulls image, spins up pods (Flask service).
5. End-user’s browser → HTTP → Flask service → loads model → returns prediction.
6. Static files served directly by Flask or via a CDN/Ingress.
Architectural patterns & principles
• Separation of concerns: UI / service logic / model logic / pipeline are distinct modules.
• Twelve-factor app: config via environment variables (Docker/K8s), stateless service, logs stdout/stderr.
• CI/CD pipeline automates test → train → build → deploy.
• Microservice style: the ML service is self-contained, containerized, and horizontally scalable in K8s.
– Components: Browser, Static Assets, Templates, Flask App, Model Module, Data Processing Module, Training Pipeline, CI/CD, Docker Registry, K8s Cluster.
– Clear text labels and arrowheads indicating direction of flow.