# ishaan2008-op/toss-it architecture

> Architecture diagram of the GitHub repository ishaan2008-op/toss-it, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ishaan2008-op/toss-it
- Repository: https://github.com/ishaan2008-op/toss-it

## Overview

#### Purpose and Entry Points
“Toss It” is a Python/HTML full-stack IPL match prediction application. It uses historical IPL match data and toss/environment inputs to produce outcome-oriented analysis.

Primary runtime entry point:
- `flask/app.py` — Flask web server and likely HTTP/UI integration point.
- `templates/frontend.html` — browser-facing application interface.
- `ipl_matches_data.csv` — historical match dataset consumed by backend analysis.

#### Web Application Boundary
Flask separates browser interaction from prediction logic:
- `flask/app.py` receives requests, renders or serves the frontend, and invokes backend logic.
- `templates/frontend.html` collects/display inputs and prediction results.
- `static/` holds browser assets if required by the template.

The browser should not access or process the CSV directly; server-side Python owns dataset access and analytical execution.

#### Prediction / Application Orchestration
Application-level coordination is concentrated in:
- `backend/applogic.py`
- `flask/app.py`

`backend/applogic.py` is the likely service boundary between HTTP handlers and analytical code: it should normalize user selections, select the relevant analysis operation, and return result-ready data rather than Flask response objects.

#### Historical Data Analysis
The analytics layer is centered on:
- `backend/analyze_teams.py`
- `ipl_matches_data.csv`

`backend/analyze_teams.py` likely loads and filters IPL history by teams, toss outcomes/decisions, and match context. This is the core data-processing stage from raw CSV records to statistics or prediction signals.

The CSV is a local, file-backed data dependency; no database, model-serving platform, or remote prediction service is indicated.

#### Primary Control and Data Flow
1. A user opens the Flask-served UI in `templates/frontend.html`.
2. The UI submits match/toss/environment selections to `flask/app.py`.
3. Flask delegates prediction-oriented work to `backend/applogic.py`.
4. Application logic calls `backend/analyze_teams.py` to query/aggregate `ipl_matches_data.csv`.
5. Computed historical signals or predicted outcomes return through Flask to the UI for display.

#### Runtime and Infrastructure
- **Backend runtime:** Python.
- **Web framework:** Flask, rooted at `flask/app.py`.
- **Frontend runtime:** static HTML rendered/served through Flask templates.
- **Data storage:** repository-local CSV file, `ipl_matches_data.csv`.
- **External services:** none are evidenced in the repository tree or README.

Main entry points: [`flask/app.py`](https://github.com/ishaan2008-op/toss-it/blob/main/flask/app.py) (Flask server), [`backend/applogic.py`](https://github.com/ishaan2008-op/toss-it/blob/main/backend/applogic.py) (Application logic), [`templates/frontend.html`](https://github.com/ishaan2008-op/toss-it/blob/main/templates/frontend.html) (Prediction interface), [`backend/analyze_teams.py`](https://github.com/ishaan2008-op/toss-it/blob/main/backend/analyze_teams.py) (Team analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_browser(("User browser<br/>browser client"))
  node_frontend["Prediction interface<br/>HTML template<br/>[frontend.html]"]
  node_assets["Browser assets<br/>static assets"]
  node_flask_app["Flask server<br/>Flask entry point<br/>[app.py]"]
end

subgraph group_backend["Prediction backend"]
  node_app_logic["Application logic<br/>prediction orchestration<br/>[applogic.py]"]
  node_team_analysis["Team analysis<br/>historical analytics<br/>[analyze_teams.py]"]
  node_match_data[("IPL match history<br/>local CSV dataset")]
end

node_browser -->|"HTTP requests"| node_flask_app
node_flask_app -->|"renders"| node_frontend
node_frontend -->|"loads"| node_assets
node_browser -->|"submits selections"| node_flask_app
node_flask_app -->|"delegates prediction"| node_app_logic
node_app_logic -->|"requests analysis"| node_team_analysis
node_team_analysis -->|"loads and filters"| node_match_data
node_app_logic -->|"returns results"| node_flask_app
node_flask_app -->|"prediction response"| node_browser

click node_frontend "https://github.com/ishaan2008-op/toss-it/blob/main/templates/frontend.html"
click node_assets "https://github.com/ishaan2008-op/toss-it/tree/main/static"
click node_flask_app "https://github.com/ishaan2008-op/toss-it/blob/main/flask/app.py"
click node_app_logic "https://github.com/ishaan2008-op/toss-it/blob/main/backend/applogic.py"
click node_team_analysis "https://github.com/ishaan2008-op/toss-it/blob/main/backend/analyze_teams.py"
click node_match_data "https://github.com/ishaan2008-op/toss-it/blob/main/ipl_matches_data.csv"

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_browser,node_frontend,node_assets,node_flask_app toneBlue
class node_app_logic,node_team_analysis,node_match_data toneAmber
```

## Components

### Web application

- **User browser**: browser client
- [Prediction interface](https://github.com/ishaan2008-op/toss-it/blob/main/templates/frontend.html): HTML template · Collects match, toss, and environment selections and displays results. · `templates/frontend.html`
- [Browser assets](https://github.com/ishaan2008-op/toss-it/tree/main/static): static assets · `static`
- [Flask server](https://github.com/ishaan2008-op/toss-it/blob/main/flask/app.py): Flask entry point · Owns HTTP handling, template delivery, and response rendering. · `flask/app.py`

### Prediction backend

- [Application logic](https://github.com/ishaan2008-op/toss-it/blob/main/backend/applogic.py): prediction orchestration · Normalizes selections and returns result-ready prediction data. · `backend/applogic.py`
- [Team analysis](https://github.com/ishaan2008-op/toss-it/blob/main/backend/analyze_teams.py): historical analytics · Filters and aggregates IPL history into prediction signals. · `backend/analyze_teams.py`
- [IPL match history](https://github.com/ishaan2008-op/toss-it/blob/main/ipl_matches_data.csv): local CSV dataset · File-backed historical IPL match records. · `ipl_matches_data.csv`

## Connections

- User browser → Flask server: HTTP requests
- Flask server → Prediction interface: renders
- Prediction interface → Browser assets: loads
- User browser → Flask server: submits selections
- Flask server → Application logic: delegates prediction
- Application logic → Team analysis: requests analysis
- Team analysis → IPL match history: loads and filters
- Application logic → Flask server: returns results
- Flask server → User browser: prediction response
