# himanshu-jadhav108/cricketvision_ai architecture

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

- Interactive diagram: https://gitdiagram.com/himanshu-jadhav108/cricketvision_ai
- Repository: https://github.com/himanshu-jadhav108/cricketvision_ai

## Overview

CricketVision AI classifies six cricket batting strokes from uploaded images, returning a confidence-qualified label and pose annotation. The inference path runs from the Gradio interface or FastAPI service through pose extraction, biomechanical feature construction, scaling, classification, and the confidence abstention guardrail. A separate model-development branch trains artifacts from curated feature data and evaluates model behavior. The inference internals and training script were sampled; API and evaluation implementation details were not, so those connections are documented only where the README supports them.

Main entry points: [`features/pose_extractor.py`](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/features/pose_extractor.py) (Pose Extraction), [`retrain.py`](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/retrain.py) (Model Retraining), [`app.py`](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/app.py) (Gradio App), [`predictor.py`](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/predictor.py) (Shot Classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_gradio["Gradio App<br/>[app.py]"]
  node_fastapi["FastAPI Service<br/>[api.py]"]
  node_result["Prediction and Annotation<br/>[app.py]"]
end

subgraph group_inference["Inference Pipeline"]
  node_pose["Pose Extraction<br/>[pose_extractor.py]"]
  node_features["Biomechanical Features<br/>[feature_builder.py]"]
  node_scaling["Feature Scaling<br/>[predictor.py]"]
  node_classifier["Shot Classifier<br/>[predictor.py]"]
  node_guardrail["Confidence Guardrail<br/>[predictor.py]"]
end

subgraph group_artifacts["Model Artifacts"]
  node_config["Runtime Configuration<br/>[config.py]"]
  node_model_files["Model Artifacts<br/>[xgboost_v1.pkl]"]
end

subgraph group_development["Model Development"]
  node_feature_data["Curated Feature Data<br/>[features_all.csv]"]
  node_retraining["Model Retraining<br/>[retrain.py]"]
  node_evaluation["Model Evaluation<br/>[evaluate_model.py]"]
  node_threshold_analysis["Threshold Analysis<br/>[threshold_sweep.py]"]
end

node_user(("Image Uploader"))

node_user -->|"uploads image"| node_gradio
node_user -->|"uploads image"| node_fastapi
node_gradio -->|"invokes inference"| node_pose
node_fastapi -->|"invokes inference"| node_pose
node_pose -->|"provides landmarks"| node_features
node_features -->|"provides feature vector"| node_scaling
node_scaling -->|"provides scaled features"| node_classifier
node_classifier -->|"checks confidence"| node_guardrail
node_guardrail -->|"returns outcome"| node_result
node_gradio -->|"renders results"| node_result
node_config -->|"sets threshold"| node_guardrail
node_config -->|"sets detection confidence"| node_pose
node_classifier -->|"loads classifier"| node_model_files
node_retraining -->|"reads training data"| node_feature_data
node_retraining -->|"uses feature names"| node_features
node_retraining -->|"writes model artifacts"| node_model_files
node_evaluation -.->|"evaluates holdout data"| node_feature_data
node_threshold_analysis -.->|"sweeps confidence thresholds"| node_model_files

click node_gradio "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/app.py"
click node_fastapi "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/api.py"
click node_pose "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/features/pose_extractor.py"
click node_features "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/features/feature_builder.py"
click node_scaling "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/predictor.py"
click node_classifier "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/predictor.py"
click node_guardrail "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/predictor.py"
click node_result "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/app.py"
click node_config "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/config.py"
click node_model_files "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/models/xgboost_v1.pkl"
click node_feature_data "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/data/features/features_all.csv"
click node_retraining "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/retrain.py"
click node_evaluation "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/evaluate_model.py"
click node_threshold_analysis "https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/threshold_sweep.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_gradio,node_fastapi,node_result toneBlue
class node_pose,node_features,node_scaling,node_classifier,node_guardrail toneAmber
class node_config,node_model_files toneMint
class node_feature_data,node_retraining,node_evaluation,node_threshold_analysis toneRose
class node_user toneIndigo
```

## Components

### User Interfaces

- [Gradio App](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/app.py): `app.py`
- [FastAPI Service](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/api.py): `api.py`
- [Prediction and Annotation](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/app.py): `app.py`

### Inference Pipeline

- [Pose Extraction](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/features/pose_extractor.py): `features/pose_extractor.py`
- [Biomechanical Features](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/features/feature_builder.py): `features/feature_builder.py`
- [Feature Scaling](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/predictor.py): `predictor.py`
- [Shot Classifier](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/predictor.py): `predictor.py`
- [Confidence Guardrail](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/predictor.py): `predictor.py`

### Model Artifacts

- [Runtime Configuration](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/config.py): `config.py`
- [Model Artifacts](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/models/xgboost_v1.pkl): `models/xgboost_v1.pkl`

### Model Development

- [Curated Feature Data](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/data/features/features_all.csv): `data/features/features_all.csv`
- [Model Retraining](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/retrain.py): `retrain.py`
- [Model Evaluation](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/evaluate_model.py): `evaluate_model.py`
- [Threshold Analysis](https://github.com/himanshu-jadhav108/cricketvision_ai/blob/main/threshold_sweep.py): `threshold_sweep.py`

### Other components

- **Image Uploader**

## Connections

- Image Uploader → Gradio App: uploads image (evidence: `README.md`)
- Image Uploader → FastAPI Service: uploads image (evidence: `README.md`)
- Gradio App → Pose Extraction: invokes inference (evidence: `app.py`)
- FastAPI Service → Pose Extraction: invokes inference (evidence: `README.md`)
- Pose Extraction → Biomechanical Features: provides landmarks (evidence: `predictor.py`)
- Biomechanical Features → Feature Scaling: provides feature vector (evidence: `predictor.py`)
- Feature Scaling → Shot Classifier: provides scaled features (evidence: `predictor.py`)
- Shot Classifier → Confidence Guardrail: checks confidence (evidence: `predictor.py`)
- Confidence Guardrail → Prediction and Annotation: returns outcome (evidence: `README.md`)
- Gradio App → Prediction and Annotation: renders results (evidence: `app.py`)
- Runtime Configuration → Confidence Guardrail: sets threshold (evidence: `predictor.py`)
- Runtime Configuration → Pose Extraction: sets detection confidence (evidence: `predictor.py`)
- Shot Classifier → Model Artifacts: loads classifier (evidence: `predictor.py`)
- Model Retraining → Curated Feature Data: reads training data (evidence: `retrain.py`)
- Model Retraining → Biomechanical Features: uses feature names (evidence: `retrain.py`)
- Model Retraining → Model Artifacts: writes model artifacts (evidence: `retrain.py`)
- Model Evaluation → Curated Feature Data: evaluates holdout data
- Threshold Analysis → Model Artifacts: sweeps confidence thresholds
