● Core / Config ● Data / Supabase ● API Endpoints ● ML Pipeline ● Schemas ● Scripts
epl_predictor/# project root
├──.env# SUPABASE_URL, SUPABASE_KEY
├──.env.example
├──requirements.txt
├──.gitignore
├──README.md
├──data/
│   ├──raw/seasons/# 1011.csv … 2425.csv (15 seasons)
│   ├──processed/# feature-engineered parquet cache
│   ├──splits/# train / val / holdout
│   └──supabase_schema.sql# run once in Supabase SQL editor
├──app/
│   ├──main.py# FastAPI app, CORS, router mounts
│   ├──core/
│   │   ├──config.py# pydantic-settings, reads .env
│   │   └──supabase_client.py# singleton Supabase client
│   ├──schemas/
│   │   ├──match.py# MatchCreate, MatchOut pydantic models
│   │   └──prediction.py# PredictionRequest, PredictionResponse
│   ├──services/
│   │   ├──ingest_service.py# fetch CSVs → clean → upsert Supabase
│   │   └──feature_service.py# rolling features, Elo, matchweek
│   ├──ml/
│   │   ├──features/
│   │   │   └──feature_columns.py# FEATURE_COLS single source of truth
│   │   ├──models/
│   │   │   └──random_forest_model.py# train(), load_model(), predict_match()
│   │   └──evaluation/
│   │      └──metrics.py# accuracy, classification report, confusion matrix
│   └──api/v1/endpoints/
│       ├──matches.py# GET /matches, GET /matches/seasons
│       ├──predict.py# POST /predict
│       └──pipeline.py# POST /pipeline/ingest, /pipeline/train
├──scripts/
│   ├──ingest_seasons.py# CLI: load all CSVs → Supabase
│   ├──train_model.py# CLI: train + save RF model
│   └──validate_csv.py# CLI: validate local CSVs before upload
├──models/saved/# rf_epl_model.joblib (git-ignored)
├──tests/
│   ├──unit/
│   │   ├──test_feature_service.py
│   │   └──test_ingest_service.py
│   └──integration/# API endpoint integration tests
├──notebooks/
│   └──01_eda.ipynb# exploratory data analysis
└──logs/# runtime logs (git-ignored)

Data Flow

CSV files → ingest_service.py cleans & time-weights → upsert to Supabase match_results table → feature_service.py engineers rolling features + Elo.

ML Pipeline

Feature columns defined once in feature_columns.py. Training uses TimeSeriesSplit + RandomizedSearchCV. Model saved as rf_epl_model.joblib.

API Endpoints

POST /api/v1/predict — real-time prediction.
POST /api/v1/pipeline/ingest — background ingestion.
POST /api/v1/pipeline/train — retrain model.

Supabase Table

Run data/supabase_schema.sql once in your Supabase SQL editor. UNIQUE constraint on (season, date, home_team, away_team) prevents duplicates on re-ingest.

Quick Start

1cp .env.example .envFill Supabase credentials
2pip install -r requirements.txt
3python scripts/validate_csv.py data/raw/seasons/Check your CSVs
4python scripts/ingest_seasons.pyLoad all 15 seasons → Supabase
5python scripts/train_model.pyTrain RF model
6uvicorn app.main:app --reloadStart API → localhost:8000/docs