# samarthchugh/networksecurity architecture

> Architecture diagram of the GitHub repository samarthchugh/networksecurity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samarthchugh/networksecurity
- Repository: https://github.com/samarthchugh/networksecurity

## Overview

##### Project type and purpose
- This is a Python‐based machine learning application focused on network security—specifically, detecting phishing sites from tabular data.
- It provides both a training pipeline (data ingestion → validation → transformation → model training) and a serving layer (Flask app + template UI + optional MongoDB integration via `push_data.py` and `test_mongodb.py`).

##### File structure
Top‐level overview:
- app.py, main.py: likely entry points for the web UI and CLI.
- push_data.py, test_mongodb.py: integration with a database (MongoDB).
- data_schema/schema.yaml: data validation rules.
- Network_Data/phisingData.csv & valid_data/test.csv: raw and test datasets.
- final_model/{model.pkl, preprocessor.pkl}: serialized artifacts from training.
- networksecurity/…: Python package organized by component:
– components: data_ingestion, data_validation, data_transformation, model_trainer
– pipeline: training pipeline, batch_prediction pipeline
– utils: general utilities, ML metric and estimator wrappers
– entity & constant: configuration and artifact classes
– logging & exception: custom logger and exception handling

##### README
- “Network Security Projects For Phishing Data” confirms this is an end‐to‐end phishing classification project.
- No in‐depth architecture section, so we infer from file layout.

##### Detail
- Data_schema component explicitly.
- Where utils and logging fit (cross‐cutting concerns).
- CI/CD workflow triggering Docker builds and deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        direction TB
        NetworkCSV["Network_Data/phisingData.csv"]:::data
        TestCSV["valid_data/test.csv"]:::data
    end

    %% Offline Pipeline
    subgraph "Offline Pipeline"
        direction TB
        Ingestion["Data Ingestion\ndata_ingestion.py"]:::pipeline
        Validation["Data Validation\ndata_validation.py\nschema.yaml"]:::pipeline
        Transformation["Data Transformation\ndata_transformation.py"]:::pipeline
        ModelTrainer["Model Trainer\nmodel_trainer.py"]:::pipeline
        TrainingPipeline["Training Pipeline\ntraining_pipeline.py"]:::pipeline
        BatchPrediction["Batch Prediction\nbatch_prediction.py"]:::pipeline
    end

    %% Model Artifacts
    artifacts["Model Artifacts\nmodel.pkl, preprocessor.pkl"]:::artifacts

    %% Online Service
    subgraph "Online Service"
        direction TB
        App["Flask App\napp.py, main.py"]:::serving
        Template["Template UI\ntemplates/table.html"]:::serving
        push["push_data.py"]:::serving
        testMongo["test_mongodb.py"]:::serving
        Mongo["MongoDB"]:::data
    end

    %% Utilities & Config
    subgraph "Utilities & Config"
        direction TB
        config["Config Entities\nconfig_entity.py\nartifact_entity.py"]:::infra
        constants["Constants\ntraining_pipeline"]:::infra
        utils1["General Utils\nutils.py"]:::infra
        utils2["Metrics\nclassification_metric.py"]:::infra
        utils3["Estimator Wrapper\nestimator.py"]:::infra
        logger["Logging\nlogger.py"]:::infra
        exception["Exception\nexception.py"]:::infra
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Docker["Docker Container\nDockerfile"]:::infra
        CI["CI/CD Workflow\n.github/workflows/main.yml"]:::infra
    end

    %% Connections
    NetworkCSV --> Ingestion
    TestCSV --> Ingestion
    Ingestion --> Validation
    Validation --> Transformation
    Transformation --> ModelTrainer
    ModelTrainer --> TrainingPipeline
    TrainingPipeline --> artifacts
    ModelTrainer --> artifacts
    artifacts --> BatchPrediction
    artifacts --> App
    App --> Template
    App --> push
    push --> Mongo
    testMongo --> Mongo
    CI --> Docker
    Docker --> TrainingPipeline
    Docker --> App

    config --> TrainingPipeline
    constants --> TrainingPipeline
    utils1 --> Transformation
    utils2 --> ModelTrainer
    utils3 --> ModelTrainer
    logger -.-> Ingestion
    logger -.-> Validation
    logger -.-> Transformation
    logger -.-> ModelTrainer
    logger -.-> App
    exception -.-> Ingestion
    exception -.-> Validation
    exception -.-> Transformation
    exception -.-> ModelTrainer
    exception -.-> App

    %% Click Events
    click NetworkCSV "https://github.com/samarthchugh/networksecurity/blob/main/Network_Data/phisingData.csv"
    click TestCSV "https://github.com/samarthchugh/networksecurity/blob/main/valid_data/test.csv"
    click Ingestion "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/components/data_ingestion.py"
    click Validation "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/components/data_validation.py"
    click Transformation "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/components/data_transformation.py"
    click ModelTrainer "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/components/model_trainer.py"
    click TrainingPipeline "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/pipeline/training_pipeline.py"
    click BatchPrediction "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/pipeline/batch_prediction.py"
    click App "https://github.com/samarthchugh/networksecurity/blob/main/app.py"
    click Template "https://github.com/samarthchugh/networksecurity/blob/main/templates/table.html"
    click push "https://github.com/samarthchugh/networksecurity/blob/main/push_data.py"
    click testMongo "https://github.com/samarthchugh/networksecurity/blob/main/test_mongodb.py"
    click config "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/entity/config_entity.py"
    click constants "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/constant/training_pipeline/__init__.py"
    click utils1 "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/utils/main_utils/utils.py"
    click utils2 "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/utils/ml_utils/metric/classification_metric.py"
    click utils3 "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/utils/ml_utils/model/estimator.py"
    click logger "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/logging/logger.py"
    click exception "https://github.com/samarthchugh/networksecurity/blob/main/networksecurity/exception/exception.py"
    click Docker "https://github.com/samarthchugh/networksecurity/tree/main/Dockerfile"
    click CI "https://github.com/samarthchugh/networksecurity/blob/main/.github/workflows/main.yml"

    %% Styles
    classDef data fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef pipeline fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef artifacts fill:#ffe0b2,stroke:#333,stroke-width:1px
    classDef serving fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef infra fill:#f0f4c3,stroke:#333,stroke-width:1px
```
