# chaithanya1904/ipl-victory-predictor architecture

> Architecture diagram of the GitHub repository chaithanya1904/ipl-victory-predictor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chaithanya1904/ipl-victory-predictor
- Repository: https://github.com/chaithanya1904/ipl-victory-predictor

## Overview

##### Project Type & Purpose
- This is a **full-stack ML web application** built with Flask (Python) that performs real-time inference to predict the winner of an IPL match.
- It exposes a web UI (HTML/CSS via Jinja templates) that collects match conditions and displays prediction results computed by a pre-trained model.

##### File Structure
Top-level directories and files:
- `app.py` – the Flask application entry point (defines routes, loads the model, handles requests).
- `model.joblib` – serialized Random Forest model used at runtime.
- `requirements.txt` – Python dependencies (Flask, scikit-learn, pandas, numpy, etc.).
- `templates/` – Jinja2 HTML templates (`index.html`).
- `static/` – CSS, client-side assets (if any).
- `Datasets/` (offline) – raw CSVs used for model training (not part of runtime).
- `IPL_Predictor_Notebook.ipynb` – exploratory notebook for feature engineering and training.

##### README for Insights
- **Tech Stack**: Frontend: HTML/CSS via Flask templates; Backend: Python + Flask; ML & Data: scikit-learn, pandas, numpy; Deployment: Render
- **ML Workflow**: Data ingestion → One-Hot Encoding → Model training (Random Forest, Logistic Regression) → Model export (`.joblib`)
- **Runtime Workflow**: Load model.joblib → Preprocess user input → Predict → Render result

##### Main Components & Their Relationships
a. User (Browser)
b. Frontend Layer
- HTML form in `index.html`
- CSS/JS in `static/`
c. Web Server / Backend (Flask in `app.py`)
- HTTP listener (Render or local)
- Request router (`/`, `/predict`)
- Data preprocessing module (One-Hot Encoding logic)
- Model inference module (loads `model.joblib`)
d. ML Model Artifact (`model.joblib`)
e. Offline Training Pipeline (outside runtime)
- `Datasets/` + `IPL_Predictor_Notebook.ipynb`
f. Deployment Environment (Render)
- WSGI server (Gunicorn or default Flask server)
- Container/VM

##### Architectural Patterns & Principles
- **MVC-like Separation**:
- Model = `model.joblib` + preprocessing code
- View = Jinja templates + static assets
- Controller = Flask routes in `app.py`
- **Single Responsibility**:
- `app.py` orchestrates only request handling and prediction
- Training code confined to Jupyter Notebook / offline process
- **Stateless Inference Service**:
- No persistent database; each prediction is independent
- **Modularization**:
- Potential to extract preprocessing into its own module

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    Browser["User Browser"]:::ui

    %% Frontend Layer
    subgraph "Frontend Layer"
        Templates["Jinja Templates"]:::ui
        Static["Static Assets"]:::ui
    end

    %% Backend Layer
    subgraph "Backend Layer"
        FlaskApp["Flask App<br/>(app.py)"]:::backend
        Preprocessor["Data Preprocessor"]:::backend
        ModelArtifact["ML Model Artifact<br/>(model.joblib)"]:::model
    end

    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        Datasets["Raw Datasets<br/>(Datasets/)"]:::offline
        Notebook["Training Notebook<br/>(IPL_Predictor_Notebook.ipynb)"]:::offline
        Export["Model Export<br/>(model.joblib)"]:::offline
    end

    %% Deployment Environment
    subgraph "Deployment Environment"
        Render["Render Platform<br/>WSGI Server"]:::infra
    end

    %% Runtime Data Flow
    Browser -->|GET /| Templates
    Browser -->|GET / static assets| Static
    Browser -->|POST /predict<br/>form-data| FlaskApp
    FlaskApp -->|preprocess input| Preprocessor
    Preprocessor -->|features| ModelArtifact
    ModelArtifact -->|prediction| FlaskApp
    FlaskApp -->|render result| Templates
    Templates -->|HTML response| Browser

    %% Offline Flow
    Datasets -->|ingest data| Notebook
    Notebook -->|train model| Export
    Export -->|artifact| ModelArtifact

    %% Deployment Connection
    Render -->|hosts| FlaskApp
    Render -->|serves| Static
    Render -->|serves| Templates

    %% Click Events
    click FlaskApp "https://github.com/chaithanya1904/ipl-victory-predictor/blob/main/app.py"
    click Templates "https://github.com/chaithanya1904/ipl-victory-predictor/blob/main/templates/index.html"
    click Static "https://github.com/chaithanya1904/ipl-victory-predictor/tree/main/static/"
    click ModelArtifact "https://github.com/chaithanya1904/ipl-victory-predictor/blob/main/model.joblib"
    click Datasets "https://github.com/chaithanya1904/ipl-victory-predictor/tree/main/Datasets/"
    click Notebook "https://github.com/chaithanya1904/ipl-victory-predictor/blob/main/IPL_Predictor_Notebook.ipynb"
    click Export "https://github.com/chaithanya1904/ipl-victory-predictor/blob/main/model.joblib"
    click FlaskApp "https://github.com/chaithanya1904/ipl-victory-predictor/blob/main/requirements.txt"
    click FlaskApp "https://github.com/chaithanya1904/ipl-victory-predictor/blob/main/README.md"

    %% Styles
    classDef ui fill:#2196f3,stroke:#0b3d91,color:#ffffff;
    classDef backend fill:#4caf50,stroke:#1b5e20,color:#ffffff;
    classDef model fill:#ff9800,stroke:#e65100,color:#ffffff;
    classDef offline fill:#9e9e9e,stroke:#616161,color:#ffffff;
    classDef infra fill:#ffeb3b,stroke:#f57f17,color:#000000;
```
