# vikashishere/mlops-proj2---nlp-usecase architecture

> Architecture diagram of the GitHub repository vikashishere/mlops-proj2---nlp-usecase, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vikashishere/mlops-proj2---nlp-usecase
- Repository: https://github.com/vikashishere/mlops-proj2---nlp-usecase

## Overview

1. This repository is an end-to-end NLP project for hate-speech classification, organized as a small production-style ML system rather than a single notebook. The core architecture separates offline training, online/offline prediction, artifact management, and deployment.

2. The main runtime entry points are `app.py` and the pipeline modules under `hate/pipeline/`. `app.py` is the top-level launch point referenced by the README, while `train_pipeline.py` and `prediction_pipeline.py` represent the two primary execution paths: model building and model inference.

3. The training flow is staged through the `hate/components/` package:
   - `data_ingestion.py` handles loading the dataset from local files or synced cloud storage.
   - `data_transforamation.py` performs preprocessing/tokenization/vectorization steps for text data.
   - `model_trainer.py` fits the NLP model.
   - `model_evaluation.py` compares the trained model against a baseline or acceptance criterion.
   - `model_pusher.py` publishes the approved artifacts to the target storage location.

4. The `hate/entity/` package defines the contracts between stages:
   - `config_entity.py` captures configuration for each pipeline step.
   - `artifact_entity.py` captures outputs passed between steps.
   This is the main boundary that keeps pipeline stages decoupled and makes the architecture diagram easier to reason about.

5. The `hate/configuration/gcloud_syncer.py` module is the cloud-integration boundary. The README explicitly mentions GCloud CLI and downloading a toolkit to pull data from GCP, so the repo expects dataset/artifact synchronization with Google Cloud storage as part of the data or model lifecycle.

6. The data flow is centered on the `data/` and `download/` directories, which both contain `dataset.zip`. That suggests a packaged dataset source for ingestion, with a local download/cache area separate from the source-controlled project code.

7. The model artifacts appear to include a saved tokenizer and serialized model assets. There is a `tokenizer.pickle` at the repo root and notebook outputs such as `model.h5` and `tokenizer.pickle`, indicating the NLP pipeline depends on persisted preprocessing state as well as the trained model.

8. `hate/ml/model.py` is the model abstraction layer. This is likely where the trained model and tokenizer are loaded for inference, keeping prediction logic separate from the training pipeline and reducing coupling between serving and training code.

9. `hate/exception/` and `hate/logger/` are cross-cutting support layers. They provide centralized error handling and logging across components, which is important in a staged pipeline where failures can occur at ingestion, transformation, training, or cloud sync boundaries.

10. The repo includes CI/CD and containerization infrastructure: `.circleci/config.yml`, `Dockerfile`, `.dockerignore`, and `circleci_setup_template.sh`. The README also mentions EC2 and self-hosted runners, so deployment is likely container-based with CircleCI orchestrating builds and delivery to an EC2-hosted runtime.

11. `requirements.txt`, `setup.py`, and `template.py` indicate the project is packaged as a Python application, not just an ad hoc notebook. The `notebook/` directory is clearly the experimentation zone, while `hate/` is the production-oriented codepath.

12. For an architecture diagram, the main boundaries are:
   - experimentation vs production code,
   - training pipeline vs prediction pipeline,
   - local filesystem vs GCP-synced artifacts,
   - reusable pipeline contracts vs stage implementations,
   - application runtime vs CI/CD/deployment infrastructure.

Main entry points: [`hate/pipeline/train_pipeline.py`](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/pipeline/train_pipeline.py) (Train pipeline), [`hate/pipeline/prediction_pipeline.py`](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/pipeline/prediction_pipeline.py) (Prediction pipeline), [`hate/components/data_ingestion.py`](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/data_ingestion.py) (Ingestion), [`app.py`](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/app.py) (App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime"]
  node_app["App<br/>entrypoint<br/>[app.py]"]
  node_train_pipeline["Train pipeline<br/>[train_pipeline.py]"]
  node_prediction_pipeline["Prediction pipeline"]
end

subgraph group_group_pipeline["ML Pipeline"]
  node_data_ingestion["Ingestion<br/>stage<br/>[data_ingestion.py]"]
  node_transformation["Transform<br/>stage"]
  node_trainer["Trainer<br/>stage<br/>[model_trainer.py]"]
  node_evaluation["Evaluation<br/>stage"]
  node_pusher["Pusher<br/>stage<br/>[model_pusher.py]"]
end

subgraph group_group_support["Support"]
  node_config_entity["Config<br/>contract<br/>[config_entity.py]"]
  node_artifact_entity["Artifacts<br/>contract<br/>[artifact_entity.py]"]
  node_gcloud_syncer["GCloud sync<br/>integration<br/>[gcloud_syncer.py]"]
  node_model["Model API<br/>abstraction<br/>[model.py]"]
  node_logger["Logger<br/>cross-cutting"]
  node_exception["Exception<br/>cross-cutting"]
end

subgraph group_group_ops["Ops"]
  node_circleci["CircleCI<br/>ci/cd<br/>[config.yml]"]
  node_docker["Docker<br/>container"]
  node_package["Python app<br/>packaging<br/>[setup.py]"]
  node_notebook["Notebook<br/>experiment<br/>[expriement.ipynb]"]
  node_dataset[("Dataset<br/>[dataset.zip]")]
  node_download[("Download cache<br/>data<br/>[dataset.zip]")]
end

node_app -->|"launches"| node_train_pipeline
node_app -->|"launches"| node_prediction_pipeline
node_train_pipeline -->|"reads"| node_config_entity
node_train_pipeline -->|"passes"| node_artifact_entity
node_train_pipeline -->|"orchestrates"| node_data_ingestion
node_data_ingestion -->|"syncs"| node_gcloud_syncer
node_data_ingestion -->|"reads"| node_dataset
node_data_ingestion -->|"writes"| node_download
node_data_ingestion -->|"outputs"| node_transformation
node_transformation -->|"feeds"| node_trainer
node_trainer -->|"produces"| node_evaluation
node_evaluation -->|"approves"| node_pusher
node_pusher -->|"syncs"| node_gcloud_syncer
node_prediction_pipeline -->|"loads"| node_model
node_prediction_pipeline -->|"consumes"| node_artifact_entity
node_model -->|"serves"| node_prediction_pipeline
node_logger -.->|"supports"| node_train_pipeline
node_exception -.->|"supports"| node_train_pipeline
node_logger -.->|"supports"| node_prediction_pipeline
node_exception -.->|"supports"| node_prediction_pipeline
node_circleci -->|"builds"| node_docker
node_docker -->|"packages"| node_package
node_notebook -.->|"experiments with"| node_dataset

click node_app "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/app.py"
click node_train_pipeline "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/pipeline/train_pipeline.py"
click node_prediction_pipeline "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/pipeline/prediction_pipeline.py"
click node_data_ingestion "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/data_ingestion.py"
click node_transformation "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/data_transforamation.py"
click node_trainer "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/model_trainer.py"
click node_evaluation "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/model_evaluation.py"
click node_pusher "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/model_pusher.py"
click node_config_entity "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/entity/config_entity.py"
click node_artifact_entity "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/entity/artifact_entity.py"
click node_gcloud_syncer "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/configuration/gcloud_syncer.py"
click node_model "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/ml/model.py"
click node_logger "https://github.com/vikashishere/mlops-proj2---nlp-usecase/tree/master/hate/logger"
click node_exception "https://github.com/vikashishere/mlops-proj2---nlp-usecase/tree/master/hate/exception"
click node_circleci "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/.circleci/config.yml"
click node_docker "https://github.com/vikashishere/mlops-proj2---nlp-usecase/tree/master/Dockerfile"
click node_package "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/setup.py"
click node_notebook "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/notebook/expriement.ipynb"
click node_dataset "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/data/dataset.zip"
click node_download "https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/download/dataset.zip"

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_app,node_train_pipeline,node_prediction_pipeline toneBlue
class node_data_ingestion,node_transformation,node_trainer,node_evaluation,node_pusher toneAmber
class node_config_entity,node_artifact_entity,node_gcloud_syncer,node_model,node_logger,node_exception toneMint
class node_circleci,node_docker,node_package,node_notebook,node_dataset,node_download toneRose
```

## Components

### Runtime

Entry points and execution paths

- [App](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/app.py): entrypoint · Top-level launch point for the application · `app.py`
- [Train pipeline](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/pipeline/train_pipeline.py): pipeline · Orchestrates offline model building · `hate/pipeline/train_pipeline.py`
- [Prediction pipeline](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/pipeline/prediction_pipeline.py): pipeline · Runs inference using saved artifacts · `hate/pipeline/prediction_pipeline.py`

### ML Pipeline

Training stages and prediction path

- [Ingestion](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/data_ingestion.py): stage · Loads dataset from local or synced storage · `hate/components/data_ingestion.py`
- [Transform](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/data_transforamation.py): stage · Preprocesses and vectorizes text data · `hate/components/data_transforamation.py`
- [Trainer](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/model_trainer.py): stage · Fits the NLP model · `hate/components/model_trainer.py`
- [Evaluation](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/model_evaluation.py): stage · Checks trained model against acceptance criteria · `hate/components/model_evaluation.py`
- [Pusher](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/components/model_pusher.py): stage · Publishes approved model artifacts · `hate/components/model_pusher.py`

### Support

Shared contracts and cross-cutting helpers

- [Config](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/entity/config_entity.py): contract · Pipeline configuration contracts · `hate/entity/config_entity.py`
- [Artifacts](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/entity/artifact_entity.py): contract · Typed outputs passed between stages · `hate/entity/artifact_entity.py`
- [GCloud sync](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/configuration/gcloud_syncer.py): integration · Synchronizes data and artifacts with cloud storage · `hate/configuration/gcloud_syncer.py`
- [Model API](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/hate/ml/model.py): abstraction · Loads and serves trained model/tokenizer state · `hate/ml/model.py`
- [Logger](https://github.com/vikashishere/mlops-proj2---nlp-usecase/tree/master/hate/logger): cross-cutting · Shared logging utility across the pipeline · `hate/logger`
- [Exception](https://github.com/vikashishere/mlops-proj2---nlp-usecase/tree/master/hate/exception): cross-cutting · Centralized error handling for pipeline failures · `hate/exception`

### Ops

Packaging, container, and CI/CD

- [CircleCI](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/.circleci/config.yml): ci/cd · Build and delivery automation · `.circleci/config.yml`
- [Docker](https://github.com/vikashishere/mlops-proj2---nlp-usecase/tree/master/Dockerfile): container · Container build and runtime packaging · `Dockerfile`
- [Python app](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/setup.py): packaging · Project packaging and dependency definition · `setup.py`
- [Notebook](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/notebook/expriement.ipynb): experiment · Exploration and model prototyping workspace · `notebook/expriement.ipynb`
- [Dataset](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/data/dataset.zip): data · Packaged source data used by ingestion · `data/dataset.zip`
- [Download cache](https://github.com/vikashishere/mlops-proj2---nlp-usecase/blob/master/download/dataset.zip): data · Local synced copy of dataset artifacts · `download/dataset.zip`

## Connections

- App → Train pipeline: launches · Application starts the training flow
- App → Prediction pipeline: launches · Application starts the inference flow
- Train pipeline → Config: reads · Training pipeline builds step configuration
- Train pipeline → Artifacts: passes · Stages exchange typed artifacts
- Train pipeline → Ingestion: orchestrates · Begins with data ingestion
- Ingestion → GCloud sync: syncs · Pulls or pushes data via cloud storage
- Ingestion → Dataset: reads · Loads packaged dataset source
- Ingestion → Download cache: writes · Stores local synced copy
- Ingestion → Transform: outputs · Hands off ingested data for preprocessing
- Transform → Trainer: feeds · Prepared features go to model training
- Trainer → Evaluation: produces · Trained model is evaluated
- Evaluation → Pusher: approves · Accepted models are pushed onward
- Pusher → GCloud sync: syncs · Publishes approved artifacts to cloud storage
- Prediction pipeline → Model API: loads · Inference uses persisted model and tokenizer
- Prediction pipeline → Artifacts: consumes · Reads saved pipeline artifacts
- Model API → Prediction pipeline: serves · Provides prediction-time abstraction
- Logger → Train pipeline: supports · Shared logging for pipeline execution
- Exception → Train pipeline: supports · Shared failure handling for pipeline execution
- Logger → Prediction pipeline: supports · Shared logging for inference execution
- Exception → Prediction pipeline: supports · Shared failure handling for inference execution
- CircleCI → Docker: builds · CI drives containerized builds and delivery
- Docker → Python app: packages · Container image includes the Python application
- Notebook → Dataset: experiments with · Notebook uses raw and packaged data for prototyping
