feat: Feature 1.2 (NBA stats FastAPI service) + Feature 1.4 (database schema)

Feature 1.2: Python FastAPI microservice wrapping nba_api
- GET /stats/season-avg, /stats/last-n, /stats/splits, /players/search
- Redis caching (24hr/1hr/6hr/7day), 0.6s rate limiting, PRA derived stat
- 27 Python tests passing

Feature 1.4: Complete Supabase database schema
- 6 tables: users, picks, scan_sessions, bets, outcomes, performance
- RLS enabled on all tables with auth.uid() policies
- 3 triggers: auto-create user, updated_at, scan count reset
- 37 schema validation tests passing
- Migration SQL ready, pending manual apply (WSL2 DNS blocker)

Total: 92 tests (65 Node.js + 27 Python), all passing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kev
2026-03-21 10:58:58 -04:00
parent 00409fd6cd
commit 3da1b4242c
27 changed files with 2360 additions and 16 deletions
+39 -4
View File
@@ -16,14 +16,35 @@ Phase 1 — Foundation
- Quota tracking via response headers, 429 when exhausted
- Query filters: stat_type, player (partial match), book
- 28 tests passing (18 unit, 10 integration)
- Known limitation: player-to-team assignment deferred to Feature 1.2 (uses home_team/away_team instead of team/opponent)
- Known limitation: player-to-team assignment deferred to Feature 1.2
### Feature 1.2 — NBA_API Stats Wrapper (COMPLETE)
- FastAPI microservice in nba-service/ on port 8000
- GET /stats/season-avg — season averages (24hr cache)
- GET /stats/last-n — last N game averages (1hr cache)
- GET /stats/splits — home/away, B2B/rest days, vs-team (6hr cache)
- GET /players/search — partial name to player ID (7-day cache)
- PRA computed as derived stat
- 0.6s rate limiting between nba_api calls with retry
- 27 tests passing (16 unit, 11 integration)
- Startup script: scripts/start.sh runs both Node + Python services
### Feature 1.4 — Database Schema (CODE COMPLETE — pending Supabase apply)
- Migration SQL: supabase/migrations/001_initial_schema.sql
- 6 tables: users, picks, scan_sessions, bets, outcomes, performance
- RLS enabled on all tables with auth.uid() policies
- 3 triggers: auto-create user, updated_at, scan count reset
- All constraints, indexes, and FKs defined
- 37 schema validation tests passing
- BLOCKED: WSL2 cannot resolve *.supabase.co — needs manual apply via SQL Editor
## What's Next
Feature 1.2 — NBA_API Stats Wrapper (no dependencies, can build now)
Feature 1.4 — Database Schema (no dependencies, can build parallel)
- Apply Feature 1.4 migration to Supabase (manual via SQL Editor)
- Run verify-schema.js to confirm tables exist
- Feature 1.3 — Prop Analysis Engine (depends: 1.1 + 1.2)
## Active Blockers
See BLOCKERS.md
- BLOCKER-003: WSL2 DNS cannot resolve *.supabase.co (see BLOCKERS.md)
## Session Log
@@ -34,3 +55,17 @@ See BLOCKERS.md
- Logged DECISION-001 (API response format) and DECISION-002 (credit conservation)
- Spec updated: home_team/away_team replaces team/opponent (API limitation)
- Credits used: 2 of 500 (498 remaining)
### Session 2 — 2026-03-21
- Built Feature 1.2: FastAPI microservice wrapping nba_api
- stats.py, player_map.py, cache.py, main.py, config.py
- 27 Python tests, all passing
- Built Feature 1.4: Full database schema SQL
- 6 tables, RLS, triggers, indexes, constraints
- 37 schema validation tests, all passing
- Could not apply to Supabase (DNS blocker)
- Logged DECISION-003 (Python microservice) and DECISION-004 (Supabase Auth)
- Created startup script (scripts/start.sh) for both services
- Created Supabase client module (src/utils/supabase.js)
- Created schema verification script (scripts/verify-schema.js)
- Total tests: 92 (65 Node.js + 27 Python), all passing