# tanishka-lab/switchguardai architecture

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

- Interactive diagram: https://gitdiagram.com/tanishka-lab/switchguardai
- Repository: https://github.com/tanishka-lab/switchguardai

## Overview

SwitchGuardAI is a railway switch-machine predictive-maintenance application. Its main workflow generates or loads sensor data, prepares and engineers features, trains a fault classifier, then presents predictions and maintenance guidance to engineers. The optional rebuild runner coordinates dataset generation, analysis, preprocessing, feature engineering, training, evaluation, and SHAP explainability; the Streamlit dashboard exposes prediction, performance, explainability, and PDF reporting. Some implementation files were not sampled, so unsampled subsystem links are limited to workflows documented in the README and runner.

Main entry points: [`run_pipeline.py`](https://github.com/tanishka-lab/switchguardai/blob/main/run_pipeline.py) (Pipeline Runner), [`feature_pipeline.py`](https://github.com/tanishka-lab/switchguardai/blob/main/feature_pipeline.py) (Feature Pipeline), [`preprocess_data.py`](https://github.com/tanishka-lab/switchguardai/blob/main/preprocess_data.py) (Data Preprocessing), [`dashboard/app.py`](https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/app.py) (Streamlit Application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Synthetic Data"]
  node_generator["Dataset Generator<br/>[data_generator.py]"]
  node_simmodels["Asset Simulation Models"]
  node_rawdata["Raw Sensor Dataset"]
end

subgraph group_ml["Model Pipeline"]
  node_runner["Pipeline Runner<br/>[run_pipeline.py]"]
  node_eda["Exploratory Analysis<br/>[eda.py]"]
  node_preprocess["Data Preprocessing<br/>[preprocess_data.py]"]
  node_validator["Dataset Validation<br/>[data_validator.py]"]
  node_cleaner["Dataset Cleaning<br/>[data_cleaner.py]"]
  node_clean_data["Clean Dataset"]
  node_features["Feature Pipeline"]
  node_feature_builder["Physics Features<br/>[feature_builder.py]"]
  node_rolling["Rolling Features"]
  node_temporal["Temporal Features"]
  node_feature_data["Engineered Dataset"]
  node_split["Train Test Split<br/>[data_split.py]"]
  node_train["Random Forest Training<br/>[train_model.py]"]
  node_model["Saved Classifier<br/>[random_forest.pkl]"]
  node_evaluate["Model Evaluation<br/>[evaluate_model.py]"]
  node_explain["SHAP Explainability<br/>[explain_model.py]"]
  node_results["Model Results"]
  node_predict["Prediction Service<br/>[predict.py]"]
end

subgraph group_dashboard["Dashboard"]
  node_app["Streamlit Application<br/>[app.py]"]
  node_prediction_page["Prediction Page<br/>[prediction.py]"]
  node_performance_page["Performance Page<br/>[performance.py]"]
  node_explain_page["Explainability Page<br/>[explainability.py]"]
  node_report_page["Report Page<br/>[report.py]"]
end

subgraph group_reporting["Maintenance Outputs"]
  node_report_generator["PDF Report Generator"]
  node_recommendations["Maintenance Recommendations"]
end

node_engineer(("Maintenance Engineer"))

node_runner -->|"dispatches"| node_generator
node_generator -->|"uses"| node_simmodels
node_generator -->|"writes"| node_rawdata
node_runner -->|"dispatches"| node_eda
node_eda -->|"reads"| node_rawdata
node_runner -->|"dispatches"| node_preprocess
node_preprocess -->|"validates"| node_validator
node_preprocess -->|"cleans"| node_cleaner
node_preprocess -->|"reads"| node_rawdata
node_preprocess -->|"writes"| node_clean_data
node_runner -->|"dispatches"| node_features
node_features -->|"reads"| node_clean_data
node_features -->|"calls"| node_feature_builder
node_features -->|"calls"| node_rolling
node_features -->|"calls"| node_temporal
node_features -->|"writes"| node_feature_data
node_runner -->|"dispatches"| node_split
node_split -->|"reads"| node_feature_data
node_runner -->|"dispatches"| node_train
node_train -->|"writes"| node_model
node_runner -->|"dispatches"| node_evaluate
node_evaluate -->|"loads"| node_model
node_evaluate -->|"writes"| node_results
node_runner -->|"dispatches"| node_explain
node_explain -->|"explains"| node_model
node_engineer -->|"uses"| node_app
node_app -->|"routes"| node_prediction_page
node_app -->|"routes"| node_performance_page
node_app -->|"routes"| node_explain_page
node_app -->|"routes"| node_report_page
node_prediction_page -->|"calls"| node_predict
node_predict -->|"loads"| node_model
node_performance_page -->|"presents"| node_results
node_explain_page -->|"presents"| node_results
node_report_page -->|"generates"| node_report_generator
node_report_generator -->|"calls"| node_recommendations

click node_runner "https://github.com/tanishka-lab/switchguardai/blob/main/run_pipeline.py"
click node_generator "https://github.com/tanishka-lab/switchguardai/blob/main/simulation/data_generator.py"
click node_simmodels "https://github.com/tanishka-lab/switchguardai/tree/main/simulation"
click node_rawdata "https://github.com/tanishka-lab/switchguardai/blob/main/data/raw/switch_machine_dataset.csv"
click node_eda "https://github.com/tanishka-lab/switchguardai/blob/main/analysis/eda.py"
click node_preprocess "https://github.com/tanishka-lab/switchguardai/blob/main/preprocess_data.py"
click node_validator "https://github.com/tanishka-lab/switchguardai/blob/main/preprocessing/data_validator.py"
click node_cleaner "https://github.com/tanishka-lab/switchguardai/blob/main/preprocessing/data_cleaner.py"
click node_clean_data "https://github.com/tanishka-lab/switchguardai/blob/main/data/processed/switch_machine_dataset_clean.csv"
click node_features "https://github.com/tanishka-lab/switchguardai/blob/main/feature_pipeline.py"
click node_feature_builder "https://github.com/tanishka-lab/switchguardai/blob/main/feature_engineering/feature_builder.py"
click node_rolling "https://github.com/tanishka-lab/switchguardai/blob/main/feature_engineering/rolling_features.py"
click node_temporal "https://github.com/tanishka-lab/switchguardai/blob/main/feature_engineering/temporal_features.py"
click node_feature_data "https://github.com/tanishka-lab/switchguardai/blob/main/data/processed/switch_machine_dataset_features.csv"
click node_split "https://github.com/tanishka-lab/switchguardai/blob/main/models/data_split.py"
click node_train "https://github.com/tanishka-lab/switchguardai/blob/main/models/train_model.py"
click node_model "https://github.com/tanishka-lab/switchguardai/blob/main/saved_models/random_forest.pkl"
click node_evaluate "https://github.com/tanishka-lab/switchguardai/blob/main/models/evaluate_model.py"
click node_explain "https://github.com/tanishka-lab/switchguardai/blob/main/models/explain_model.py"
click node_results "https://github.com/tanishka-lab/switchguardai/tree/main/results"
click node_app "https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/app.py"
click node_prediction_page "https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/prediction.py"
click node_predict "https://github.com/tanishka-lab/switchguardai/blob/main/models/predict.py"
click node_performance_page "https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/performance.py"
click node_explain_page "https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/explainability.py"
click node_report_page "https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/report.py"
click node_report_generator "https://github.com/tanishka-lab/switchguardai/blob/main/reporting/report_generator.py"
click node_recommendations "https://github.com/tanishka-lab/switchguardai/blob/main/reporting/maintenance_recommendation.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_generator,node_simmodels,node_rawdata toneBlue
class node_runner,node_eda,node_preprocess,node_validator,node_cleaner,node_clean_data,node_features,node_feature_builder,node_rolling,node_temporal,node_feature_data,node_split,node_train,node_model,node_evaluate,node_explain,node_results,node_predict toneAmber
class node_app,node_prediction_page,node_performance_page,node_explain_page,node_report_page toneMint
class node_report_generator,node_recommendations toneRose
class node_engineer toneIndigo
```

## Components

### Synthetic Data

- [Dataset Generator](https://github.com/tanishka-lab/switchguardai/blob/main/simulation/data_generator.py): `simulation/data_generator.py`
- [Asset Simulation Models](https://github.com/tanishka-lab/switchguardai/tree/main/simulation): `simulation`
- [Raw Sensor Dataset](https://github.com/tanishka-lab/switchguardai/blob/main/data/raw/switch_machine_dataset.csv): `data/raw/switch_machine_dataset.csv`

### Model Pipeline

- [Pipeline Runner](https://github.com/tanishka-lab/switchguardai/blob/main/run_pipeline.py): `run_pipeline.py`
- [Exploratory Analysis](https://github.com/tanishka-lab/switchguardai/blob/main/analysis/eda.py): `analysis/eda.py`
- [Data Preprocessing](https://github.com/tanishka-lab/switchguardai/blob/main/preprocess_data.py): `preprocess_data.py`
- [Dataset Validation](https://github.com/tanishka-lab/switchguardai/blob/main/preprocessing/data_validator.py): `preprocessing/data_validator.py`
- [Dataset Cleaning](https://github.com/tanishka-lab/switchguardai/blob/main/preprocessing/data_cleaner.py): `preprocessing/data_cleaner.py`
- [Clean Dataset](https://github.com/tanishka-lab/switchguardai/blob/main/data/processed/switch_machine_dataset_clean.csv): `data/processed/switch_machine_dataset_clean.csv`
- [Feature Pipeline](https://github.com/tanishka-lab/switchguardai/blob/main/feature_pipeline.py): `feature_pipeline.py`
- [Physics Features](https://github.com/tanishka-lab/switchguardai/blob/main/feature_engineering/feature_builder.py): `feature_engineering/feature_builder.py`
- [Rolling Features](https://github.com/tanishka-lab/switchguardai/blob/main/feature_engineering/rolling_features.py): `feature_engineering/rolling_features.py`
- [Temporal Features](https://github.com/tanishka-lab/switchguardai/blob/main/feature_engineering/temporal_features.py): `feature_engineering/temporal_features.py`
- [Engineered Dataset](https://github.com/tanishka-lab/switchguardai/blob/main/data/processed/switch_machine_dataset_features.csv): `data/processed/switch_machine_dataset_features.csv`
- [Train Test Split](https://github.com/tanishka-lab/switchguardai/blob/main/models/data_split.py): `models/data_split.py`
- [Random Forest Training](https://github.com/tanishka-lab/switchguardai/blob/main/models/train_model.py): `models/train_model.py`
- [Saved Classifier](https://github.com/tanishka-lab/switchguardai/blob/main/saved_models/random_forest.pkl): `saved_models/random_forest.pkl`
- [Model Evaluation](https://github.com/tanishka-lab/switchguardai/blob/main/models/evaluate_model.py): `models/evaluate_model.py`
- [SHAP Explainability](https://github.com/tanishka-lab/switchguardai/blob/main/models/explain_model.py): `models/explain_model.py`
- [Model Results](https://github.com/tanishka-lab/switchguardai/tree/main/results): `results`
- [Prediction Service](https://github.com/tanishka-lab/switchguardai/blob/main/models/predict.py): `models/predict.py`

### Dashboard

- [Streamlit Application](https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/app.py): `dashboard/app.py`
- [Prediction Page](https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/prediction.py): `dashboard/components/prediction.py`
- [Performance Page](https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/performance.py): `dashboard/components/performance.py`
- [Explainability Page](https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/explainability.py): `dashboard/components/explainability.py`
- [Report Page](https://github.com/tanishka-lab/switchguardai/blob/main/dashboard/components/report.py): `dashboard/components/report.py`

### Maintenance Outputs

- [PDF Report Generator](https://github.com/tanishka-lab/switchguardai/blob/main/reporting/report_generator.py): `reporting/report_generator.py`
- [Maintenance Recommendations](https://github.com/tanishka-lab/switchguardai/blob/main/reporting/maintenance_recommendation.py): `reporting/maintenance_recommendation.py`

### Other components

- **Maintenance Engineer**

## Connections

- Pipeline Runner → Dataset Generator: dispatches
- Dataset Generator → Asset Simulation Models: uses
- Dataset Generator → Raw Sensor Dataset: writes
- Pipeline Runner → Exploratory Analysis: dispatches
- Exploratory Analysis → Raw Sensor Dataset: reads
- Pipeline Runner → Data Preprocessing: dispatches
- Data Preprocessing → Dataset Validation: validates
- Data Preprocessing → Dataset Cleaning: cleans
- Data Preprocessing → Raw Sensor Dataset: reads
- Data Preprocessing → Clean Dataset: writes
- Pipeline Runner → Feature Pipeline: dispatches
- Feature Pipeline → Clean Dataset: reads
- Feature Pipeline → Physics Features: calls
- Feature Pipeline → Rolling Features: calls
- Feature Pipeline → Temporal Features: calls
- Feature Pipeline → Engineered Dataset: writes
- Pipeline Runner → Train Test Split: dispatches
- Train Test Split → Engineered Dataset: reads
- Pipeline Runner → Random Forest Training: dispatches
- Random Forest Training → Saved Classifier: writes
- Pipeline Runner → Model Evaluation: dispatches
- Model Evaluation → Saved Classifier: loads
- Model Evaluation → Model Results: writes
- Pipeline Runner → SHAP Explainability: dispatches
- SHAP Explainability → Saved Classifier: explains
- Maintenance Engineer → Streamlit Application: uses
- Streamlit Application → Prediction Page: routes
- Streamlit Application → Performance Page: routes
- Streamlit Application → Explainability Page: routes
- Streamlit Application → Report Page: routes
- Prediction Page → Prediction Service: calls
- Prediction Service → Saved Classifier: loads
- Performance Page → Model Results: presents
- Explainability Page → Model Results: presents
- Report Page → PDF Report Generator: generates
- PDF Report Generator → Maintenance Recommendations: calls
