Spaces:
Paused
Paused
Rishabh Shenoy commited on
Commit Β·
ab1e1af
1
Parent(s): 29fd274
Added files to root
Browse filesThis view is limited to 50 files because it contains too many changes. Β See raw diff
- backend/.env.example β .env.example +0 -0
- backend/.gitignore β .gitignore +0 -0
- backend/Dockerfile β Dockerfile +0 -0
- README.md +63 -13
- backend/app.py β app.py +0 -0
- {backend/app β app}/__init__.py +0 -0
- {backend/app β app}/ai/__init__.py +0 -0
- {backend/app β app}/ai/graph.py +0 -0
- {backend/app β app}/api.py +0 -0
- {backend/app β app}/config.py +0 -0
- {backend/app β app}/data/__init__.py +0 -0
- {backend/app β app}/data/knowledge/cricket_rules_and_laws.txt +0 -0
- {backend/app β app}/data/knowledge/t20_analytics_and_chasing_dynamics.txt +0 -0
- {backend/app β app}/data/matches/.gitkeep +0 -0
- {backend/app β app}/data/matches/1082591.json +0 -0
- {backend/app β app}/data/matches/1082592.json +0 -0
- {backend/app β app}/data/matches/1082593.json +0 -0
- {backend/app β app}/data/matches/1082594.json +0 -0
- {backend/app β app}/data/matches/1082595.json +0 -0
- {backend/app β app}/data/matches/1082596.json +0 -0
- {backend/app β app}/data/matches/1082597.json +0 -0
- {backend/app β app}/data/matches/1082598.json +0 -0
- {backend/app β app}/data/matches/1082599.json +0 -0
- {backend/app β app}/data/matches/1082600.json +0 -0
- {backend/app β app}/data/matches/1082601.json +0 -0
- {backend/app β app}/data/matches/1082602.json +0 -0
- {backend/app β app}/data/matches/__init__.py +0 -0
- {backend/app β app}/fine_tuning/__init__.py +0 -0
- {backend/app β app}/fine_tuning/data/intent_examples.jsonl +0 -0
- {backend/app β app}/fine_tuning/evaluate.py +0 -0
- {backend/app β app}/fine_tuning/train.py +0 -0
- {backend/app β app}/main.py +0 -0
- {backend/app β app}/models.py +0 -0
- {backend/app β app}/rag/__init__.py +0 -0
- {backend/app β app}/rag/ingestion.py +0 -0
- {backend/app β app}/services/__init__.py +0 -0
- {backend/app β app}/services/cricket.py +0 -0
- {backend/app β app}/services/gemini.py +0 -0
- {backend/app β app}/services/intent.py +0 -0
- {backend/app β app}/services/match_data.py +0 -0
- {backend/app β app}/services/rag.py +0 -0
- {backend/app β app}/services/sample_data.py +0 -0
- {backend/app β app}/services/stories.py +0 -0
- {backend/app β app}/services/workflow.py +0 -0
- backend/README.md +0 -63
- backend/recent.zip β recent.zip +0 -0
- backend/requirements.txt β requirements.txt +0 -0
- {backend/scripts β scripts}/check_qdrant.py +0 -0
- {backend/scripts β scripts}/download_cricsheet.py +0 -0
- {backend/scripts β scripts}/ingest_knowledge.py +0 -0
backend/.env.example β .env.example
RENAMED
|
File without changes
|
backend/.gitignore β .gitignore
RENAMED
|
File without changes
|
backend/Dockerfile β Dockerfile
RENAMED
|
File without changes
|
README.md
CHANGED
|
@@ -1,13 +1,63 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MatchLens backend
|
| 2 |
+
|
| 3 |
+
This FastAPI service powers the existing React replay UI. The initial data mode is
|
| 4 |
+
explicitly a **historical replay**, not a live feed. Cricsheet JSON files can be
|
| 5 |
+
placed in `app/data/matches`; the normalized parser loads them at startup.
|
| 6 |
+
|
| 7 |
+
## Load multiple real matches
|
| 8 |
+
|
| 9 |
+
The backend does not scrape an HTML scoreboard. It uses Cricsheet's structured,
|
| 10 |
+
historical ball-by-ball JSON source, which is more reliable for replay and
|
| 11 |
+
statistics. From the `backend` directory, download a bounded set of recent
|
| 12 |
+
men's T20 matches:
|
| 13 |
+
|
| 14 |
+
```powershell
|
| 15 |
+
python scripts\download_cricsheet.py --count 12
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
Restart Uvicorn after downloading. `GET /api/matches` will then expose the
|
| 19 |
+
downloaded matches alongside the bundled fallback. The downloader is
|
| 20 |
+
repeatable and only stores selected JSON files locally; do not commit the
|
| 21 |
+
downloaded match data unless your distribution policy permits it.
|
| 22 |
+
|
| 23 |
+
## Run locally
|
| 24 |
+
|
| 25 |
+
```powershell
|
| 26 |
+
cd backend
|
| 27 |
+
python -m venv .venv
|
| 28 |
+
.venv\Scripts\Activate.ps1
|
| 29 |
+
pip install -r requirements.txt
|
| 30 |
+
Copy-Item .env.example .env
|
| 31 |
+
uvicorn app.main:app --reload
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
OpenAPI is available at `http://localhost:8000/docs`. Configure `GEMINI_API_KEY`
|
| 35 |
+
for grounded natural-language explanations. Without it, the API returns a
|
| 36 |
+
deterministic evidence-based fallback and explicitly warns that Gemini is not
|
| 37 |
+
configured. Configure Qdrant before running the ingestion tooling; rule
|
| 38 |
+
documents are never used to store changing match scores.
|
| 39 |
+
|
| 40 |
+
## Frontend
|
| 41 |
+
|
| 42 |
+
Use the real API by setting:
|
| 43 |
+
|
| 44 |
+
```env
|
| 45 |
+
VITE_DEMO_MODE=false
|
| 46 |
+
VITE_API_BASE_URL=http://localhost:8000
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
The frontend then calls `/api/matches`, `/api/matches/{id}/state`,
|
| 50 |
+
`/api/matches/{id}/timeline`, replay, catch-up, and assistant routes. Demo
|
| 51 |
+
fixtures remain available when `VITE_DEMO_MODE` is not `false`.
|
| 52 |
+
|
| 53 |
+
## Offline experiments and deployment
|
| 54 |
+
|
| 55 |
+
`app/fine_tuning/train.py` contains the PEFT/LoRA training entry point and
|
| 56 |
+
`evaluate.py` reports measured accuracy, macro-F1, and a confusion matrix.
|
| 57 |
+
Training is intentionally offline and the API does not train at startup.
|
| 58 |
+
`app/rag/ingestion.py` prepares idempotent document chunks for Qdrant.
|
| 59 |
+
|
| 60 |
+
Build the Cloud Run image with `docker build -t matchlens-api backend` and pass
|
| 61 |
+
secrets as environment variables. Netlify should use the same
|
| 62 |
+
`VITE_API_BASE_URL` setting and an SPA fallback for `index.html`. Render can
|
| 63 |
+
run the same Docker image with the configured `PORT`.
|
backend/app.py β app.py
RENAMED
|
File without changes
|
{backend/app β app}/__init__.py
RENAMED
|
File without changes
|
{backend/app β app}/ai/__init__.py
RENAMED
|
File without changes
|
{backend/app β app}/ai/graph.py
RENAMED
|
File without changes
|
{backend/app β app}/api.py
RENAMED
|
File without changes
|
{backend/app β app}/config.py
RENAMED
|
File without changes
|
{backend/app β app}/data/__init__.py
RENAMED
|
File without changes
|
{backend/app β app}/data/knowledge/cricket_rules_and_laws.txt
RENAMED
|
File without changes
|
{backend/app β app}/data/knowledge/t20_analytics_and_chasing_dynamics.txt
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/.gitkeep
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082591.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082592.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082593.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082594.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082595.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082596.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082597.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082598.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082599.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082600.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082601.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/1082602.json
RENAMED
|
File without changes
|
{backend/app β app}/data/matches/__init__.py
RENAMED
|
File without changes
|
{backend/app β app}/fine_tuning/__init__.py
RENAMED
|
File without changes
|
{backend/app β app}/fine_tuning/data/intent_examples.jsonl
RENAMED
|
File without changes
|
{backend/app β app}/fine_tuning/evaluate.py
RENAMED
|
File without changes
|
{backend/app β app}/fine_tuning/train.py
RENAMED
|
File without changes
|
{backend/app β app}/main.py
RENAMED
|
File without changes
|
{backend/app β app}/models.py
RENAMED
|
File without changes
|
{backend/app β app}/rag/__init__.py
RENAMED
|
File without changes
|
{backend/app β app}/rag/ingestion.py
RENAMED
|
File without changes
|
{backend/app β app}/services/__init__.py
RENAMED
|
File without changes
|
{backend/app β app}/services/cricket.py
RENAMED
|
File without changes
|
{backend/app β app}/services/gemini.py
RENAMED
|
File without changes
|
{backend/app β app}/services/intent.py
RENAMED
|
File without changes
|
{backend/app β app}/services/match_data.py
RENAMED
|
File without changes
|
{backend/app β app}/services/rag.py
RENAMED
|
File without changes
|
{backend/app β app}/services/sample_data.py
RENAMED
|
File without changes
|
{backend/app β app}/services/stories.py
RENAMED
|
File without changes
|
{backend/app β app}/services/workflow.py
RENAMED
|
File without changes
|
backend/README.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
| 1 |
-
# MatchLens backend
|
| 2 |
-
|
| 3 |
-
This FastAPI service powers the existing React replay UI. The initial data mode is
|
| 4 |
-
explicitly a **historical replay**, not a live feed. Cricsheet JSON files can be
|
| 5 |
-
placed in `app/data/matches`; the normalized parser loads them at startup.
|
| 6 |
-
|
| 7 |
-
## Load multiple real matches
|
| 8 |
-
|
| 9 |
-
The backend does not scrape an HTML scoreboard. It uses Cricsheet's structured,
|
| 10 |
-
historical ball-by-ball JSON source, which is more reliable for replay and
|
| 11 |
-
statistics. From the `backend` directory, download a bounded set of recent
|
| 12 |
-
men's T20 matches:
|
| 13 |
-
|
| 14 |
-
```powershell
|
| 15 |
-
python scripts\download_cricsheet.py --count 12
|
| 16 |
-
```
|
| 17 |
-
|
| 18 |
-
Restart Uvicorn after downloading. `GET /api/matches` will then expose the
|
| 19 |
-
downloaded matches alongside the bundled fallback. The downloader is
|
| 20 |
-
repeatable and only stores selected JSON files locally; do not commit the
|
| 21 |
-
downloaded match data unless your distribution policy permits it.
|
| 22 |
-
|
| 23 |
-
## Run locally
|
| 24 |
-
|
| 25 |
-
```powershell
|
| 26 |
-
cd backend
|
| 27 |
-
python -m venv .venv
|
| 28 |
-
.venv\Scripts\Activate.ps1
|
| 29 |
-
pip install -r requirements.txt
|
| 30 |
-
Copy-Item .env.example .env
|
| 31 |
-
uvicorn app.main:app --reload
|
| 32 |
-
```
|
| 33 |
-
|
| 34 |
-
OpenAPI is available at `http://localhost:8000/docs`. Configure `GEMINI_API_KEY`
|
| 35 |
-
for grounded natural-language explanations. Without it, the API returns a
|
| 36 |
-
deterministic evidence-based fallback and explicitly warns that Gemini is not
|
| 37 |
-
configured. Configure Qdrant before running the ingestion tooling; rule
|
| 38 |
-
documents are never used to store changing match scores.
|
| 39 |
-
|
| 40 |
-
## Frontend
|
| 41 |
-
|
| 42 |
-
Use the real API by setting:
|
| 43 |
-
|
| 44 |
-
```env
|
| 45 |
-
VITE_DEMO_MODE=false
|
| 46 |
-
VITE_API_BASE_URL=http://localhost:8000
|
| 47 |
-
```
|
| 48 |
-
|
| 49 |
-
The frontend then calls `/api/matches`, `/api/matches/{id}/state`,
|
| 50 |
-
`/api/matches/{id}/timeline`, replay, catch-up, and assistant routes. Demo
|
| 51 |
-
fixtures remain available when `VITE_DEMO_MODE` is not `false`.
|
| 52 |
-
|
| 53 |
-
## Offline experiments and deployment
|
| 54 |
-
|
| 55 |
-
`app/fine_tuning/train.py` contains the PEFT/LoRA training entry point and
|
| 56 |
-
`evaluate.py` reports measured accuracy, macro-F1, and a confusion matrix.
|
| 57 |
-
Training is intentionally offline and the API does not train at startup.
|
| 58 |
-
`app/rag/ingestion.py` prepares idempotent document chunks for Qdrant.
|
| 59 |
-
|
| 60 |
-
Build the Cloud Run image with `docker build -t matchlens-api backend` and pass
|
| 61 |
-
secrets as environment variables. Netlify should use the same
|
| 62 |
-
`VITE_API_BASE_URL` setting and an SPA fallback for `index.html`. Render can
|
| 63 |
-
run the same Docker image with the configured `PORT`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend/recent.zip β recent.zip
RENAMED
|
File without changes
|
backend/requirements.txt β requirements.txt
RENAMED
|
File without changes
|
{backend/scripts β scripts}/check_qdrant.py
RENAMED
|
File without changes
|
{backend/scripts β scripts}/download_cricsheet.py
RENAMED
|
File without changes
|
{backend/scripts β scripts}/ingest_knowledge.py
RENAMED
|
File without changes
|