# vikashishere/circleci-gcp-mlops-ner-project architecture

> Architecture diagram of the GitHub repository vikashishere/circleci-gcp-mlops-ner-project, 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/circleci-gcp-mlops-ner-project
- Repository: https://github.com/vikashishere/circleci-gcp-mlops-ner-project

## Overview

1. **What this repo is**
   - A Python-based NER pipeline project organized around MLOps-style stages: ingest data, transform it, train/evaluate a model, and publish the best artifact for later inference.
   - The codebase is split into a reusable `ner` package plus a few top-level entry scripts and deployment/CI assets.

2. **Main execution entry points**
   - `train.py` is the training entry script and likely orchestrates the end-to-end training pipeline.
   - `app.py` and `demo.py` are separate top-level runtime entry points for running the application or a demo/inference flow.
   - These scripts depend on the reusable pipeline classes under `ner/pipeline`.

3. **Core pipeline boundary**
   - `ner/pipeline/train_pipeline.py` and `ner/pipeline/prediction_pipeline.py` are the two main orchestration boundaries.
   - Training pipeline coordinates ingestion → transformation → training → evaluation → pushing.
   - Prediction pipeline is the inference-side boundary and likely loads the exported tokenizer/model artifacts to produce entity predictions.

4. **Data and model lifecycle**
   - Raw and intermediate assets live under `data/` and `gcp_download/`, including `archive.zip` and `ner.csv`.
   - Serialized inference artifacts at the repo root, `tokenizer.pkl` and `ids_to_labels.pkl`, indicate the model’s preprocessing and label decoding are persisted separately from the model itself.
   - This separation matters for the architecture diagram: inference depends on both the trained model and these supporting artifacts.

5. **Pipeline components**
   - `ner/components/data_ingestion.py` handles bringing dataset files into the project and/or cloud storage.
   - `ner/components/data_transforamation.py` performs preprocessing and token/label preparation for NER training.
   - `ner/components/model_trainer.py` trains the model.
   - `ner/components/model_evaluation.py` compares trained output against expected metrics or baseline criteria.
   - `ner/components/model_pusher.py` publishes the approved model artifact to the deployment/storage target.

6. **Configuration and typed contracts**
   - `ner/entity/config_entity.py` and `ner/entity/artifact_entity.py` define the structured objects passed between stages.
   - This is the repo’s main internal contract layer: components should not pass raw dictionaries around; they exchange typed config/artifact objects.
   - `ner/constants` likely holds shared names/paths/keys used across the pipeline.

7. **Cloud integration**
   - `ner/configuration/gcloud.py` suggests direct Google Cloud integration for bucket or storage access.
   - The README and file layout indicate GCP is used for data/model storage and deployment support.
   - `gcp_download/` and the model-pushing component point to a workflow where artifacts are staged in cloud storage before deployment.

8. **Cross-cutting support code**
   - `ner/exception` and `ner/logger` provide centralized error handling and logging across the pipeline.
   - `ner/utils/utils.py` likely contains shared helpers for file I/O, serialization, path handling, or cloud interactions.
   - These modules are infrastructure for observability and robustness, not business logic.

9. **Packaging and runtime environment**
   - `setup.py`, `requirements.txt`, and `template.py` indicate the repo is meant to be installable as a Python package and runnable in repeatable environments.
   - `Dockerfile` and `.dockerignore` show containerized execution is part of the architecture, probably for both training and serving.
   - The project is therefore designed to run locally, in containers, and in cloud-backed environments.

10. **CI/CD and infrastructure automation**
   - `.circleci/config.yml` provides the CI/CD boundary for build/test/deploy automation.
   - `scripts/VM-machine-setup.sh` is a provisioning script for setting up a machine or VM environment.
   - Together with Docker and GCP, this indicates the delivery path is automated rather than manual.

11. **Experimentation and documentation artifacts**
   - `notebooks/NER_using_BERT.ipynb` is the experimentation workspace where the modeling approach was likely developed.
   - `flowchart/` and `projectflow.txt` appear to document the intended pipeline and are useful as architectural references.
   - These are not runtime dependencies, but they explain how the model and pipeline were designed.

12. **Likely end-to-end flow for the diagram**
   - Dataset source or downloaded archive → ingestion stage → transformation/preprocessing stage → model training → evaluation gate → model push/store.
   - Inference path: application/demo entry point → prediction pipeline → load tokenizer/label map/model artifact → return entity labels for input text.
   - CI/CD and Docker wrap both flows, while GCP serves as the external storage/deployment backbone.

Main entry points: [`ner/pipeline/train_pipeline.py`](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/pipeline/train_pipeline.py) (Train pipeline), [`ner/pipeline/prediction_pipeline.py`](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/pipeline/prediction_pipeline.py) (Predict pipeline), [`Dockerfile`](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/Dockerfile) (Docker), [`ner/components/data_ingestion.py`](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/data_ingestion.py) (Ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime entrypoints"]
  node_node_train_py["train.py<br/>entry script<br/>[train.py]"]
  node_node_app_py["app.py<br/>entry script<br/>[app.py]"]
  node_node_demo_py["demo.py<br/>entry script<br/>[demo.py]"]
end

subgraph group_group_pipeline["Pipelines"]
  node_node_train_pipeline["Train pipeline<br/>orchestrator<br/>[train_pipeline.py]"]
  node_node_prediction_pipeline["Predict pipeline<br/>orchestrator"]
end

subgraph group_group_components["Core components"]
  node_node_data_ingestion["Ingestion<br/>[data_ingestion.py]"]
  node_node_data_transform["Transform"]
  node_node_model_trainer["Trainer<br/>[model_trainer.py]"]
  node_node_model_evaluation["Evaluation"]
  node_node_model_pusher["Pusher<br/>[model_pusher.py]"]
end

subgraph group_group_contracts["Contracts"]
  node_node_config_entity["Config entities<br/>typed contracts<br/>[config_entity.py]"]
  node_node_artifact_entity["Artifact entities<br/>typed contracts<br/>[artifact_entity.py]"]
end

subgraph group_group_support["Support code"]
  node_node_gcloud["GCloud config<br/>cloud adapter<br/>[gcloud.py]"]
  node_node_utils["Utilities<br/>shared helpers<br/>[utils.py]"]
  node_node_logger(("Logger<br/>observability"))
  node_node_exception(("Exceptions<br/>error handling"))
end

subgraph group_group_ops["Ops and delivery"]
  node_node_docker{{"Docker<br/>container build"}}
  node_node_circleci["CircleCI<br/>ci/cd<br/>[config.yml]"]
  node_node_vm_setup["VM setup<br/>provisioning"]
  node_node_package["Packaging<br/>[setup.py]"]
end

subgraph group_group_artifacts["Data and artifacts"]
  node_node_data[("Data files<br/>dataset")]
  node_node_gcp_download[("GCP download<br/>staged data")]
  node_node_tokenizer["Tokenizer<br/>serialized artifact<br/>[tokenizer.pkl]"]
  node_node_labels["Label map<br/>serialized artifact<br/>[ids_to_labels.pkl]"]
end

node_node_train_py -->|"starts"| node_node_train_pipeline
node_node_app_py -->|"runs"| node_node_prediction_pipeline
node_node_demo_py -->|"runs"| node_node_prediction_pipeline
node_node_train_pipeline -->|"ingests"| node_node_data_ingestion
node_node_train_pipeline -->|"transforms"| node_node_data_transform
node_node_train_pipeline -->|"trains"| node_node_model_trainer
node_node_train_pipeline -->|"evaluates"| node_node_model_evaluation
node_node_train_pipeline -->|"publishes"| node_node_model_pusher
node_node_prediction_pipeline -->|"loads"| node_node_tokenizer
node_node_prediction_pipeline -->|"loads"| node_node_labels
node_node_prediction_pipeline -->|"reads"| node_node_gcp_download
node_node_data_ingestion -->|"reads/writes"| node_node_data
node_node_data_ingestion -->|"uses"| node_node_gcloud
node_node_data_transform -->|"uses"| node_node_config_entity
node_node_model_trainer -->|"uses"| node_node_artifact_entity
node_node_model_evaluation -->|"uses"| node_node_artifact_entity
node_node_model_pusher -->|"pushes to"| node_node_gcloud
node_node_train_pipeline -->|"logs"| node_node_logger
node_node_train_pipeline -->|"handles"| node_node_exception
node_node_prediction_pipeline -->|"uses"| node_node_utils
node_node_train_py -.->|"depends on"| node_node_package
node_node_docker -.->|"runs"| node_node_train_py
node_node_docker -.->|"runs"| node_node_app_py
node_node_circleci -.->|"builds"| node_node_docker
node_node_vm_setup -.->|"prepares"| node_node_docker

click node_node_train_py "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/train.py"
click node_node_app_py "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/app.py"
click node_node_demo_py "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/demo.py"
click node_node_train_pipeline "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/pipeline/train_pipeline.py"
click node_node_prediction_pipeline "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/pipeline/prediction_pipeline.py"
click node_node_data_ingestion "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/data_ingestion.py"
click node_node_data_transform "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/data_transforamation.py"
click node_node_model_trainer "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/model_trainer.py"
click node_node_model_evaluation "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/model_evaluation.py"
click node_node_model_pusher "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/model_pusher.py"
click node_node_config_entity "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/entity/config_entity.py"
click node_node_artifact_entity "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/entity/artifact_entity.py"
click node_node_gcloud "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/configuration/gcloud.py"
click node_node_utils "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/utils/utils.py"
click node_node_logger "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/ner/logger"
click node_node_exception "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/ner/exception"
click node_node_data "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/data"
click node_node_gcp_download "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/gcp_download"
click node_node_tokenizer "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/tokenizer.pkl"
click node_node_labels "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ids_to_labels.pkl"
click node_node_docker "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/Dockerfile"
click node_node_circleci "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/.circleci/config.yml"
click node_node_vm_setup "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/scripts/VM-machine-setup.sh"
click node_node_package "https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/setup.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_node_train_py,node_node_app_py,node_node_demo_py,node_node_data,node_node_gcp_download,node_node_tokenizer,node_node_labels toneBlue
class node_node_train_pipeline,node_node_prediction_pipeline toneAmber
class node_node_data_ingestion,node_node_data_transform,node_node_model_trainer,node_node_model_evaluation,node_node_model_pusher toneMint
class node_node_config_entity,node_node_artifact_entity toneRose
class node_node_gcloud,node_node_utils,node_node_logger,node_node_exception toneIndigo
class node_node_docker,node_node_circleci,node_node_vm_setup,node_node_package toneTeal
```

## Components

### Runtime entrypoints

Top-level scripts that launch training or inference flows.

- [train.py](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/train.py): entry script · Training entry point that launches the end-to-end pipeline. · `train.py`
- [app.py](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/app.py): entry script · Application entry point for runtime use. · `app.py`
- [demo.py](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/demo.py): entry script · Demo or inference entry point. · `demo.py`

### Pipelines

Orchestration boundaries for training and prediction.

- [Train pipeline](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/pipeline/train_pipeline.py): orchestrator · Coordinates ingestion, transformation, training, evaluation, and push. · `ner/pipeline/train_pipeline.py`
- [Predict pipeline](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/pipeline/prediction_pipeline.py): orchestrator · Loads persisted artifacts and produces entity predictions. · `ner/pipeline/prediction_pipeline.py`

### Core components

Reusable stage implementations used by the pipelines.

- [Ingestion](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/data_ingestion.py): Brings dataset into local or cloud storage. · `ner/components/data_ingestion.py`
- [Transform](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/data_transforamation.py): Prepares text and labels for NER training. · `ner/components/data_transforamation.py`
- [Trainer](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/model_trainer.py): Fits the NER model from transformed data. · `ner/components/model_trainer.py`
- [Evaluation](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/model_evaluation.py): Checks trained model quality against criteria. · `ner/components/model_evaluation.py`
- [Pusher](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/components/model_pusher.py): Publishes the approved model artifact for deployment or storage. · `ner/components/model_pusher.py`

### Contracts

Typed entities and shared constants passed across stages.

- [Config entities](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/entity/config_entity.py): typed contracts · Structured configuration objects shared across stages. · `ner/entity/config_entity.py`
- [Artifact entities](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/entity/artifact_entity.py): typed contracts · Structured artifact objects handed between pipeline stages. · `ner/entity/artifact_entity.py`

### Support code

Logging, exceptions, utilities, and cloud configuration.

- [GCloud config](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/configuration/gcloud.py): cloud adapter · Google Cloud integration for storage and deployment support. · `ner/configuration/gcloud.py`
- [Utilities](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ner/utils/utils.py): shared helpers · Common file, serialization, and path helpers. · `ner/utils/utils.py`
- [Logger](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/ner/logger): observability · Centralized logging used across the repo. · `ner/logger`
- [Exceptions](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/ner/exception): error handling · Shared exception handling layer. · `ner/exception`

### Ops and delivery

Container, CI/CD, and environment automation.

- [Docker](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/Dockerfile): container build · Containerization for repeatable execution. · `Dockerfile`
- [CircleCI](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/.circleci/config.yml): ci/cd · Automation boundary for build and delivery. · `.circleci/config.yml`
- [VM setup](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/scripts/VM-machine-setup.sh): provisioning · Script for machine or VM environment setup. · `scripts/VM-machine-setup.sh`
- [Packaging](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/setup.py): python packaging · Install and dependency metadata for the project. · `setup.py`

### Data and artifacts

Datasets, downloaded inputs, and persisted inference assets.

- [Data files](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/data): dataset · Local dataset inputs and downloaded archives. · `data`
- [GCP download](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/tree/main/gcp_download): staged data · Downloaded archive staged from cloud storage. · `gcp_download`
- [Tokenizer](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/tokenizer.pkl): serialized artifact · Persisted preprocessing artifact used for inference. · `tokenizer.pkl`
- [Label map](https://github.com/vikashishere/circleci-gcp-mlops-ner-project/blob/main/ids_to_labels.pkl): serialized artifact · Persisted id-to-label mapping used for decoding predictions. · `ids_to_labels.pkl`

## Connections

- train.py → Train pipeline: starts · Training script launches the main orchestration pipeline.
- app.py → Predict pipeline: runs · Application entry point uses the inference pipeline.
- demo.py → Predict pipeline: runs · Demo entry point uses the inference pipeline.
- Train pipeline → Ingestion: ingests · The training flow begins by collecting data.
- Train pipeline → Transform: transforms · Training flow prepares NER inputs and labels.
- Train pipeline → Trainer: trains · Training flow fits the model.
- Train pipeline → Evaluation: evaluates · Training flow checks model quality.
- Train pipeline → Pusher: publishes · Approved artifacts are pushed for later use.
- Predict pipeline → Tokenizer: loads · Inference uses the persisted tokenizer.
- Predict pipeline → Label map: loads · Inference uses the label decoder mapping.
- Predict pipeline → GCP download: reads · Inference may read staged artifacts or inputs from cloud downloads.
- Ingestion → Data files: reads/writes · Ingestion moves dataset files in and out of local storage.
- Ingestion → GCloud config: uses · Ingestion depends on cloud access configuration.
- Transform → Config entities: uses · Transformation is configured through typed entities.
- Trainer → Artifact entities: uses · Trainer exchanges structured artifacts with other stages.
- Evaluation → Artifact entities: uses · Evaluation consumes and emits artifact metadata.
- Pusher → GCloud config: pushes to · Model pusher interacts with cloud storage or deployment targets.
- Train pipeline → Logger: logs · Pipeline stages emit logs through the shared logger.
- Train pipeline → Exceptions: handles · Pipeline errors flow through centralized exception handling.
- Predict pipeline → Utilities: uses · Inference helpers likely rely on shared utility functions.
- train.py → Packaging: depends on · Entry scripts rely on installable project packaging.
- Docker → train.py: runs · Container image can execute the training entry point.
- Docker → app.py: runs · Container image can execute the application entry point.
- CircleCI → Docker: builds · CI/CD likely builds and validates the container image.
- VM setup → Docker: prepares · Provisioning supports container or environment setup.
