Spaces:
Paused
Paused
Added files to root
Browse files
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`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|