# IPL Cricket Statistics Dashboard

Cricket statistics dashboard powered by DuckDB, connected to a PostgreSQL database with Cricsheet.org ball-by-ball data. Features AI chat assistant with text and voice interaction.

## Links
- App: https://ipl.rbicc.net
- GitHub (FastAPI Backend): https://github.com/amararun/shared-rexc-cricket-fastapi
- GitHub (DuckDB Backend): https://github.com/amararun/shared-duckdb-dashboards-backend

## Tags
database-ai, dashboards, duckdb, cricket, fastapi

## Architecture

```
JavaScript Frontend → FastAPI Backend → PostgreSQL (Cricsheet ODI data)
                   → DuckDB Backend  → DuckDB (analytics)
```

### Frontend
Single-page HTML/CSS/JavaScript app. Deployable to Vercel, Netlify, or any static host.

### FastAPI Backend (shared-rexc-cricket-fastapi)
Simple FastAPI server connecting to a fixed PostgreSQL database. Uses the `/sqlquery/` endpoint to execute SQL queries against pre-configured database connections.

Setup:
```bash
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port $PORT
```

Environment variables: Database connection credentials (host, database, user, password) for the target database. Uses the same connector pattern as the DATS-4 analyzer backend.

### DuckDB Backend (shared-duckdb-dashboards-backend)
FastAPI server for querying DuckDB/Parquet files with caching, rate limiting, and admin endpoints.

Key endpoints:
- `POST /api/query/{filename}` - Read-only SQL (API_KEY auth)
- `GET /api/admin/files` - List files (ADMIN_API_KEY auth)
- `POST /api/admin/files/upload` - Upload file
- `GET /api/admin/cache/stats` - Cache statistics

### Data Source
Cricsheet.org ball-by-ball ODI data (2003-2024). Raw data at https://cricsheet.org/downloads/#experimental. Process with the Cricsheet Processor app (csv-processor on tigzig.com).

## Features
- AI chat assistant for real-time cricket data analysis
- Voice interaction via ElevenLabs
- Python-powered statistical processing and charts
- Google Docs integration for pushing query results
- Connects to any database via credentials
