# aryanjaiswal-454/network-security architecture

> Architecture diagram of the GitHub repository aryanjaiswal-454/network-security, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aryanjaiswal-454/network-security
- Repository: https://github.com/aryanjaiswal-454/network-security

## Overview

#### Purpose and Entry Points
This repository trains and serves a phishing/network-security classifier. It includes an offline training pipeline, batch prediction output, and a likely web-facing application layer.
- Training/runtime launch points: `main.py`, `app.py`
- Data-loading utility/operational script: `push_data.py`
- Packaged project root: `setup.py`

#### Training Pipeline Orchestration
`networksecurity/pipeline/training_pipeline.py` is the central workflow coordinator. It composes stage-specific components and passes typed configuration/artifact objects between them.
- Pipeline orchestration: `networksecurity/pipeline/training_pipeline.py`
- Stage contracts/configuration: `networksecurity/entity/artifact_entity.py`, `networksecurity/entity/config_entity.py`
- Shared training constants: `networksecurity/constant/training_pipeline/__init__.py`

#### Data Ingestion and Persistence Boundary
Raw phishing data is available locally and may also be loaded or synchronized through external storage/database integrations.
- Source dataset: `Network_Data/phisingData.csv`
- Ingestion stage: `networksecurity/components/data_ingestion.py`
- S3 integration boundary: `networksecurity/cloud/s3_syncer.py`
- MongoDB is an expected external dependency, indicated by `test_mongodb.py` and likely exercised by data-push operations in `push_data.py`.

#### Schema Validation and Feature Preparation
The pipeline validates incoming data against a declared schema before transforming it into model-ready features. This establishes the key quality boundary between raw external records and training/inference inputs.
- Schema contract: `data_schema/schema.yaml`
- Validation stage: `networksecurity/components/data_validation.py`
- Transformation stage: `networksecurity/components/data_transformation.py`
- General serialization/data utilities: `networksecurity/utils/main_utils/utils.py`

#### Model Training and Persisted Inference Assets
Model training produces a fitted classifier and preprocessing artifact. The checked-in `final_model` directory is the deployment/inference model boundary.
- Trainer stage: `networksecurity/components/model_trainer.py`
- Persisted model: `final_model/model.pkl`
- Persisted feature preprocessor: `final_model/preprocessor.pkl`
- Estimator abstraction: `networksecurity/utils/ml_utils/model/estimator.py`
- Classification evaluation: `networksecurity/utils/ml_utils/metric/classification_metric.py`

#### Prediction Delivery
Batch prediction is implemented separately from training and writes tabular output. The application layer likely exposes predictions or rendered results using an HTML template.
- Batch inference pipeline: `networksecurity/pipeline/batch_prediction.py`
- Example prediction output: `prediction_output/output.csv`
- Validation/inference input example: `valid_data/test.csv`
- Presentation template: `templates/table.html`
- Application entry point: `app.py`

#### Runtime and Operational Infrastructure
The project is Python-packaged and containerized, with CI automation. Logging and exception wrappers provide cross-cutting observability/error boundaries around pipeline stages.
- Container runtime: `Dockerfile`
- Dependencies: `requirements.txt`
- CI workflow: `.github/workflows/main.yml`
- Logging: `networksecurity/logging/logger.py`
- Exception handling: `networksecurity/exception/exception.py`

Main entry points: [`networksecurity/pipeline/training_pipeline.py`](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/pipeline/training_pipeline.py) (Training pipeline), [`networksecurity/components/model_trainer.py`](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/model_trainer.py) (Model trainer), [`networksecurity/components/data_ingestion.py`](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_ingestion.py) (Data ingestion), [`networksecurity/components/data_validation.py`](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_validation.py) (Data validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training pipeline"]
  node_raw_data["Phishing dataset<br/>CSV dataset<br/>[phisingData.csv]"]
  node_ingestion["Data ingestion<br/>pipeline component<br/>[data_ingestion.py]"]
  node_external_storage[("S3 sync<br/>cloud boundary<br/>[s3_syncer.py]")]
  node_data_push["Data push<br/>operational script<br/>[push_data.py]"]
  node_training_pipeline{{"Training pipeline<br/>workflow coordinator"}}
  node_contracts["Stage contracts<br/>config and artifacts<br/>[artifact_entity.py]"]
  node_schema["Data schema<br/>validation contract<br/>[schema.yaml]"]
  node_validation["Data validation<br/>pipeline component<br/>[data_validation.py]"]
  node_transformation["Data transformation<br/>pipeline component"]
  node_trainer["Model trainer<br/>pipeline component<br/>[model_trainer.py]"]
  node_estimator["Estimator and metrics<br/>ML abstraction<br/>[estimator.py]"]
end

subgraph group_inference["Inference delivery"]
  node_model["Fitted model<br/>inference asset<br/>[model.pkl]"]
  node_preprocessor["Feature preprocessor<br/>inference asset<br/>[preprocessor.pkl]"]
  node_batch_prediction{{"Batch prediction<br/>inference pipeline"}}
  node_prediction_output["Prediction output<br/>CSV output<br/>[output.csv]"]
  node_application{{"Application<br/>runtime entry point<br/>[app.py]"}}
  node_template["Results template<br/>HTML presentation<br/>[table.html]"]
end

subgraph group_platform["Runtime infrastructure"]
  node_runtime["Container runtime<br/>deployment definition"]
  node_ci["CI workflow<br/>automation<br/>[main.yml]"]
  node_observability["Logging and exceptions<br/>cross-cutting support<br/>[logger.py]"]
end

node_raw_data -->|"source data"| node_ingestion
node_data_push -.->|"synchronizes"| node_external_storage
node_external_storage -.->|"external source"| node_ingestion
node_training_pipeline -->|"orchestrates"| node_ingestion
node_training_pipeline -->|"orchestrates"| node_validation
node_training_pipeline -->|"orchestrates"| node_transformation
node_training_pipeline -->|"orchestrates"| node_trainer
node_contracts -->|"typed inputs and artifacts"| node_training_pipeline
node_ingestion -->|"ingested records"| node_validation
node_schema -->|"validates against"| node_validation
node_validation -->|"validated data"| node_transformation
node_transformation -->|"prepared features"| node_trainer
node_estimator -->|"training and evaluation"| node_trainer
node_trainer -->|"persists"| node_model
node_trainer -->|"persists"| node_preprocessor
node_model -->|"loads"| node_batch_prediction
node_preprocessor -->|"loads"| node_batch_prediction
node_batch_prediction -->|"writes"| node_prediction_output
node_model -->|"serves predictions"| node_application
node_preprocessor -->|"prepares inputs"| node_application
node_application -->|"renders"| node_template
node_runtime -.->|"packages runtime"| node_application
node_ci -.->|"builds and automates"| node_runtime
node_observability -.->|"stage diagnostics"| node_training_pipeline

click node_raw_data "https://github.com/aryanjaiswal-454/network-security/blob/main/Network_Data/phisingData.csv"
click node_ingestion "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_ingestion.py"
click node_external_storage "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/cloud/s3_syncer.py"
click node_data_push "https://github.com/aryanjaiswal-454/network-security/blob/main/push_data.py"
click node_training_pipeline "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/pipeline/training_pipeline.py"
click node_contracts "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/entity/artifact_entity.py"
click node_schema "https://github.com/aryanjaiswal-454/network-security/blob/main/data_schema/schema.yaml"
click node_validation "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_validation.py"
click node_transformation "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_transformation.py"
click node_trainer "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/model_trainer.py"
click node_estimator "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/utils/ml_utils/model/estimator.py"
click node_model "https://github.com/aryanjaiswal-454/network-security/blob/main/final_model/model.pkl"
click node_preprocessor "https://github.com/aryanjaiswal-454/network-security/blob/main/final_model/preprocessor.pkl"
click node_batch_prediction "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/pipeline/batch_prediction.py"
click node_prediction_output "https://github.com/aryanjaiswal-454/network-security/blob/main/prediction_output/output.csv"
click node_application "https://github.com/aryanjaiswal-454/network-security/blob/main/app.py"
click node_template "https://github.com/aryanjaiswal-454/network-security/blob/main/templates/table.html"
click node_runtime "https://github.com/aryanjaiswal-454/network-security/tree/main/Dockerfile"
click node_ci "https://github.com/aryanjaiswal-454/network-security/blob/main/.github/workflows/main.yml"
click node_observability "https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/logging/logger.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_raw_data,node_ingestion,node_external_storage,node_data_push,node_training_pipeline,node_contracts,node_schema,node_validation,node_transformation,node_trainer,node_estimator toneBlue
class node_model,node_preprocessor,node_batch_prediction,node_prediction_output,node_application,node_template toneAmber
class node_runtime,node_ci,node_observability toneMint
```

## Components

### Training pipeline

Offline workflow stages and contracts.

- [Phishing dataset](https://github.com/aryanjaiswal-454/network-security/blob/main/Network_Data/phisingData.csv): CSV dataset · `Network_Data/phisingData.csv`
- [Data ingestion](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_ingestion.py): pipeline component · Acquires training records from local or external sources. · `networksecurity/components/data_ingestion.py`
- [S3 sync](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/cloud/s3_syncer.py): cloud boundary · `networksecurity/cloud/s3_syncer.py`
- [Data push](https://github.com/aryanjaiswal-454/network-security/blob/main/push_data.py): operational script · Loads or synchronizes records with MongoDB-backed operations. · `push_data.py`
- [Training pipeline](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/pipeline/training_pipeline.py): workflow coordinator · Composes stages and transfers typed artifacts. · `networksecurity/pipeline/training_pipeline.py`
- [Stage contracts](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/entity/artifact_entity.py): config and artifacts · `networksecurity/entity/artifact_entity.py`
- [Data schema](https://github.com/aryanjaiswal-454/network-security/blob/main/data_schema/schema.yaml): validation contract · `data_schema/schema.yaml`
- [Data validation](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_validation.py): pipeline component · `networksecurity/components/data_validation.py`
- [Data transformation](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/data_transformation.py): pipeline component · Builds model-ready features. · `networksecurity/components/data_transformation.py`
- [Model trainer](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/components/model_trainer.py): pipeline component · `networksecurity/components/model_trainer.py`
- [Estimator and metrics](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/utils/ml_utils/model/estimator.py): ML abstraction · Wraps fitted prediction and classification evaluation. · `networksecurity/utils/ml_utils/model/estimator.py`

### Inference delivery

Persisted assets and prediction entry points.

- [Fitted model](https://github.com/aryanjaiswal-454/network-security/blob/main/final_model/model.pkl): inference asset · `final_model/model.pkl`
- [Feature preprocessor](https://github.com/aryanjaiswal-454/network-security/blob/main/final_model/preprocessor.pkl): inference asset · `final_model/preprocessor.pkl`
- [Batch prediction](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/pipeline/batch_prediction.py): inference pipeline · `networksecurity/pipeline/batch_prediction.py`
- [Prediction output](https://github.com/aryanjaiswal-454/network-security/blob/main/prediction_output/output.csv): CSV output · `prediction_output/output.csv`
- [Application](https://github.com/aryanjaiswal-454/network-security/blob/main/app.py): runtime entry point · Likely exposes prediction results through a web-facing layer. · `app.py`
- [Results template](https://github.com/aryanjaiswal-454/network-security/blob/main/templates/table.html): HTML presentation · `templates/table.html`

### Runtime infrastructure

Packaging, container, and CI support.

- [Container runtime](https://github.com/aryanjaiswal-454/network-security/tree/main/Dockerfile): deployment definition · `Dockerfile`
- [CI workflow](https://github.com/aryanjaiswal-454/network-security/blob/main/.github/workflows/main.yml): automation · `.github/workflows/main.yml`
- [Logging and exceptions](https://github.com/aryanjaiswal-454/network-security/blob/main/networksecurity/logging/logger.py): cross-cutting support · Wraps pipeline-stage diagnostics and failures. · `networksecurity/logging/logger.py`

## Connections

- Phishing dataset → Data ingestion: source data
- Data push → S3 sync: synchronizes
- S3 sync → Data ingestion: external source
- Training pipeline → Data ingestion: orchestrates
- Training pipeline → Data validation: orchestrates
- Training pipeline → Data transformation: orchestrates
- Training pipeline → Model trainer: orchestrates
- Stage contracts → Training pipeline: typed inputs and artifacts
- Data ingestion → Data validation: ingested records
- Data schema → Data validation: validates against
- Data validation → Data transformation: validated data
- Data transformation → Model trainer: prepared features
- Estimator and metrics → Model trainer: training and evaluation
- Model trainer → Fitted model: persists
- Model trainer → Feature preprocessor: persists
- Fitted model → Batch prediction: loads
- Feature preprocessor → Batch prediction: loads
- Batch prediction → Prediction output: writes
- Fitted model → Application: serves predictions
- Feature preprocessor → Application: prepares inputs
- Application → Results template: renders
- Container runtime → Application: packages runtime
- CI workflow → Container runtime: builds and automates
- Logging and exceptions → Training pipeline: stage diagnostics
