# satheeshkumar147/ai_agent_for_ipl architecture

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

- Interactive diagram: https://gitdiagram.com/satheeshkumar147/ai_agent_for_ipl
- Repository: https://github.com/satheeshkumar147/ai_agent_for_ipl

## Overview

This repository is an IPL cricket-data question-answering app. A user submits a question in the Streamlit interface; the compiled LangGraph workflow turns it into SQL, runs that SQL against MySQL, and uses the result to produce a displayed answer. A second, separate ReAct agent offers tool-based SQL analysis, while load_data.py imports the deliveries CSV into MySQL. The README is empty, so capabilities and links here are based on the sampled source; the tool agent’s runtime flow is only partly visible.

Main entry points: [`agent.py`](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py) (SQL generation), [`graph_agent.py`](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/graph_agent.py) (Tool-based agent), [`app.py`](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/app.py) (Streamlit chat), [`load_data.py`](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/load_data.py) (CSV loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_streamlit["Streamlit chat<br/>[app.py]"]
end

subgraph group_agents["Question answering"]
  node_workflow["Compiled workflow<br/>[agent.py]"]
  node_sql_writer["SQL generation<br/>[agent.py]"]
  node_query_runner["SQL execution<br/>[agent.py]"]
  node_answer_writer["Answer generation<br/>[agent.py]"]
  node_react_agent["Tool-based agent<br/>[graph_agent.py]"]
  node_sql_toolkit["SQL tools<br/>[graph_agent.py]"]
end

subgraph group_data["IPL data"]
  node_mysql[("MySQL database")]
  node_loader["CSV loader<br/>[load_data.py]"]
  node_deliveries_csv["Deliveries CSV<br/>[deliveries.csv]"]
end

node_user(("User"))
node_gemini{{"Gemini model"}}

node_user -->|"asks question"| node_streamlit
node_streamlit -->|"invokes"| node_workflow
node_workflow -->|"starts at"| node_sql_writer
node_sql_writer -->|"passes SQL"| node_query_runner
node_query_runner -->|"passes result"| node_answer_writer
node_answer_writer -->|"returns answer"| node_workflow
node_streamlit -->|"displays answer"| node_user
node_sql_writer -->|"reads schema"| node_mysql
node_query_runner -->|"runs SQL"| node_mysql
node_sql_writer -->|"requests SQL"| node_gemini
node_answer_writer -->|"requests answer"| node_gemini
node_react_agent -->|"builds database connection"| node_mysql
node_react_agent -->|"configures model"| node_gemini
node_react_agent -->|"gets tools"| node_sql_toolkit
node_sql_toolkit -->|"creates database tools"| node_mysql
node_loader -->|"reads"| node_deliveries_csv
node_loader -->|"loads deliveries"| node_mysql

click node_streamlit "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/app.py"
click node_workflow "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py"
click node_sql_writer "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py"
click node_query_runner "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py"
click node_answer_writer "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py"
click node_react_agent "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/graph_agent.py"
click node_sql_toolkit "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/graph_agent.py"
click node_loader "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/load_data.py"
click node_deliveries_csv "https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/deliveries.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_streamlit,node_user toneBlue
class node_workflow,node_sql_writer,node_query_runner,node_answer_writer,node_react_agent,node_sql_toolkit toneAmber
class node_mysql,node_loader,node_deliveries_csv toneMint
class node_gemini toneIndigo
```

## Components

### Chat interface

- [Streamlit chat](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/app.py): `app.py`

### Question answering

- [Compiled workflow](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py): `agent.py`
- [SQL generation](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py): `agent.py`
- [SQL execution](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py): `agent.py`
- [Answer generation](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/agent.py): `agent.py`
- [Tool-based agent](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/graph_agent.py): `graph_agent.py`
- [SQL tools](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/graph_agent.py): `graph_agent.py`

### IPL data

- **MySQL database**
- [CSV loader](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/load_data.py): `load_data.py`
- [Deliveries CSV](https://github.com/satheeshkumar147/ai_agent_for_ipl/blob/main/deliveries.csv): `deliveries.csv`

### Other components

- **User**
- **Gemini model**

## Connections

- User → Streamlit chat: asks question (evidence: `app.py`)
- Streamlit chat → Compiled workflow: invokes (evidence: `app.py`)
- Compiled workflow → SQL generation: starts at (evidence: `agent.py`)
- SQL generation → SQL execution: passes SQL (evidence: `agent.py`)
- SQL execution → Answer generation: passes result (evidence: `agent.py`)
- Answer generation → Compiled workflow: returns answer (evidence: `agent.py`)
- Streamlit chat → User: displays answer (evidence: `app.py`)
- SQL generation → MySQL database: reads schema (evidence: `agent.py`)
- SQL execution → MySQL database: runs SQL (evidence: `agent.py`)
- SQL generation → Gemini model: requests SQL (evidence: `agent.py`)
- Answer generation → Gemini model: requests answer (evidence: `agent.py`)
- Tool-based agent → MySQL database: builds database connection (evidence: `graph_agent.py`)
- Tool-based agent → Gemini model: configures model (evidence: `graph_agent.py`)
- Tool-based agent → SQL tools: gets tools (evidence: `graph_agent.py`)
- SQL tools → MySQL database: creates database tools (evidence: `graph_agent.py`)
- CSV loader → Deliveries CSV: reads (evidence: `load_data.py`)
- CSV loader → MySQL database: loads deliveries (evidence: `load_data.py`)
