# rishirxt/offshoremodel architecture

> Architecture diagram of the GitHub repository rishirxt/offshoremodel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishirxt/offshoremodel
- Repository: https://github.com/rishirxt/offshoremodel

## Overview

This repository is a batch PPE-violation attribution model: it trains an XGBoost classifier, evaluates it, and ranks expanded candidate records before applying safety rules to produce a named or group alert. The documented workflow starts from prepared CSV data; the sampled code does not show camera, wearable, or roster data ingestion. Training, evaluation, and prediction are separate script entry points, with shared feature and path configuration. Edges are limited to calls and data flows shown in excerpts or explicitly documented in the README.

Main entry points: [`src/predict.py`](https://github.com/rishirxt/offshoremodel/blob/main/src/predict.py) (Candidate inference), [`src/evaluate.py`](https://github.com/rishirxt/offshoremodel/blob/main/src/evaluate.py) (Model evaluation), [`src/train.py`](https://github.com/rishirxt/offshoremodel/blob/main/src/train.py) (Model training), [`src/config.py`](https://github.com/rishirxt/offshoremodel/blob/main/src/config.py) (Model configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_modeling["Modeling"]
  node_train_data["Training features"]
  node_training["Model training<br/>[train.py]"]
  node_config["Model configuration<br/>[config.py]"]
  node_model[("Trained model")]
end

subgraph group_attribution["Attribution"]
  node_candidate_data["Expanded candidates"]
  node_prediction["Candidate inference<br/>[predict.py]"]
  node_rules["Safety rule engine<br/>[rules.py]"]
  node_decision["Ranked alert decision"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["Model evaluation<br/>[evaluate.py]"]
  node_evaluation_outputs["Evaluation artifacts"]
end

node_operator(("Operator"))

node_operator -->|"runs training"| node_training
node_operator -->|"runs evaluation"| node_evaluation
node_operator -->|"runs prediction"| node_prediction
node_training -->|"loads settings"| node_config
node_training -->|"reads features"| node_train_data
node_training -->|"saves model"| node_model
node_prediction -->|"loads settings"| node_config
node_prediction -->|"reads candidates"| node_candidate_data
node_prediction -->|"loads model"| node_model
node_prediction -->|"applies rules"| node_rules
node_prediction -->|"ranks decisions"| node_decision
node_evaluation -->|"loads settings"| node_config
node_evaluation -->|"reads test data"| node_train_data
node_evaluation -->|"loads model"| node_model
node_evaluation -->|"writes metrics"| node_evaluation_outputs

click node_train_data "https://github.com/rishirxt/offshoremodel/blob/main/data/training_features.csv"
click node_training "https://github.com/rishirxt/offshoremodel/blob/main/src/train.py"
click node_config "https://github.com/rishirxt/offshoremodel/blob/main/src/config.py"
click node_candidate_data "https://github.com/rishirxt/offshoremodel/blob/main/data/expanded_candidates.csv"
click node_prediction "https://github.com/rishirxt/offshoremodel/blob/main/src/predict.py"
click node_rules "https://github.com/rishirxt/offshoremodel/blob/main/src/rules.py"
click node_evaluation "https://github.com/rishirxt/offshoremodel/blob/main/src/evaluate.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_train_data,node_training,node_config,node_model toneBlue
class node_candidate_data,node_prediction,node_rules,node_decision toneAmber
class node_evaluation,node_evaluation_outputs toneMint
class node_operator toneIndigo
```

## Components

### Modeling

- [Training features](https://github.com/rishirxt/offshoremodel/blob/main/data/training_features.csv): `data/training_features.csv`
- [Model training](https://github.com/rishirxt/offshoremodel/blob/main/src/train.py): `src/train.py`
- [Model configuration](https://github.com/rishirxt/offshoremodel/blob/main/src/config.py): `src/config.py`
- **Trained model**

### Attribution

- [Expanded candidates](https://github.com/rishirxt/offshoremodel/blob/main/data/expanded_candidates.csv): `data/expanded_candidates.csv`
- [Candidate inference](https://github.com/rishirxt/offshoremodel/blob/main/src/predict.py): `src/predict.py`
- [Safety rule engine](https://github.com/rishirxt/offshoremodel/blob/main/src/rules.py): `src/rules.py`
- **Ranked alert decision**

### Evaluation

- [Model evaluation](https://github.com/rishirxt/offshoremodel/blob/main/src/evaluate.py): `src/evaluate.py`
- **Evaluation artifacts**

### Other components

- **Operator**

## Connections

- Operator → Model training: runs training (evidence: `readme.md`)
- Operator → Model evaluation: runs evaluation (evidence: `readme.md`)
- Operator → Candidate inference: runs prediction (evidence: `readme.md`)
- Model training → Model configuration: loads settings (evidence: `src/train.py`)
- Model training → Training features: reads features (evidence: `src/train.py`)
- Model training → Trained model: saves model (evidence: `src/train.py`)
- Candidate inference → Model configuration: loads settings (evidence: `src/predict.py`)
- Candidate inference → Expanded candidates: reads candidates (evidence: `src/predict.py`)
- Candidate inference → Trained model: loads model (evidence: `src/predict.py`)
- Candidate inference → Safety rule engine: applies rules (evidence: `src/predict.py`)
- Candidate inference → Ranked alert decision: ranks decisions (evidence: `src/predict.py`)
- Model evaluation → Model configuration: loads settings (evidence: `src/evaluate.py`)
- Model evaluation → Training features: reads test data (evidence: `src/evaluate.py`)
- Model evaluation → Trained model: loads model (evidence: `src/evaluate.py`)
- Model evaluation → Evaluation artifacts: writes metrics (evidence: `src/evaluate.py`)
