feat: Feature 1.5 — Bet Submission with 3 methods + performance tracking

Three submission methods:
- POST /api/bets/quickslip — structured bet entry
- POST /api/bets/screenshot — stub OCR with confirm flow
- POST /api/bets/sync — coming soon stub

Full bet lifecycle:
- PATCH /api/bets/:id/settle — settle with outcome, recalculates performance
- GET /api/bets — list with status/book/pagination filters
- GET /api/bets/performance — ROI, win rate, profit (weekly/monthly/all_time)

Payout calculator handles straight bets (American odds) and parlays
(multiplied leg payouts). Performance service recalculates on each
settlement and upserts into performance table.

33 new tests, 221 total (194 Node.js + 27 Python), all passing.
All backend features for Phase 1 + Phase 2 now complete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kev
2026-03-22 05:11:42 -04:00
parent 2366660f5e
commit ed6502a880
12 changed files with 1310 additions and 37 deletions
+38 -37
View File
@@ -1,10 +1,10 @@
# BetonBLK — Build State
## Last Updated
2026-03-21
2026-03-22
## Current Phase
Phase 2 — Core Product (COMPLETE)
Phase 2 — Core Product (COMPLETE). Ready for Phase 3.
## What Has Shipped
@@ -12,33 +12,36 @@ Phase 2 — Core Product (COMPLETE)
- Feature 1.1 — Odds API Integration
- Feature 1.2 — NBA_API Stats Wrapper (FastAPI microservice)
- Feature 1.3 — Prop Analysis Engine (6-step grading pipeline)
- Feature 1.4 — Database Schema (6 tables + 3 new tables, RLS, triggers)
- Feature 1.4 — Database Schema (9 tables, RLS, triggers)
- Feature 1.5 — Bet Submission (3 methods)
### Feature 2.1Parlay Scan (COMPLETE)
- POST /api/scan/parlay — full parlay analysis with auth
- 5 correlation types, parlay grading, scan count tracking
- Monetization: 5-scan free limit, personalized upgrade pitch at scan 5
### Phase 2 — Core Product (COMPLETE)
- Feature 2.1 — Parlay Scan (correlation detection, monetization)
- Feature 2.2 — Line Movement + Cascade Detection
### Feature 2.2 — Line Movement + Cascade Detection (COMPLETE)
- Line movement: baseline capture on first fetch, movement detection >= 0.5 points
- Sharp money heuristic (sharp_action/public_action/unknown)
- Cascade detection: scratch detection via props disappearing from 2+ books
- Re-grade affected parlays, create cascade_alerts for affected users
- GET /api/movements — today's line movements with filters
- GET /api/alerts — unread cascade alerts (Analyst/Desk only)
- PATCH /api/alerts/:id/read — mark alert as read
- Enhanced GET /api/odds/nba — movements included in live fetch response
- Zero extra Odds API credits — piggybacks on existing fetches
- Migration 002: line_baselines, line_movements, cascade_alerts tables
### Feature 1.5 — Bet Submission (COMPLETE)
- POST /api/bets/quickslip — structured bet entry with payout calculation
- POST /api/bets/screenshot — image upload (stub OCR, needs_confirmation flow)
- POST /api/bets/screenshot/confirm — save confirmed screenshot bet
- POST /api/bets/sync — stub (coming soon)
- PATCH /api/bets/:id/settle — settle bet with outcome, triggers performance recalc
- GET /api/bets — list bets with status/book/limit/offset filters
- GET /api/bets/performance — ROI, win rate, profit for weekly/monthly/all_time
- Payout calculator: straight (American odds) + parlay (multiplied legs)
- Performance service: recalculates on each settlement, upserts into performance table
- Scan session linking for analytics
## Test Summary
- Node.js: 161 tests passing (unit + integration)
- Node.js: 194 tests passing (unit + integration)
- Python: 27 tests passing
- Total: 188 tests, all green
- Total: 221 tests, all green
## What's Next
- Feature 1.5 — Bet Submission (3 methods: screenshot, quickslip, sync)
- Phase 3 — Web MVP (landing page, scan UI, bet tracker, Stripe)
- Phase 3 — Web MVP
- Feature 3.1Landing Page (Next.js)
- Feature 3.2 — Scan UI
- Feature 3.3 — Bet Tracker UI
- Feature 3.4 — Stripe Integration
## Active Blockers
- BLOCKER-003: WSL2 DNS cannot resolve *.supabase.co
@@ -46,19 +49,17 @@ Phase 2 — Core Product (COMPLETE)
## Session Log
### Sessions 1-4 — 2026-03-21
- Built Phase 1 (Features 1.1-1.4) + Feature 2.1 (Parlay Scan)
- 158 tests passing
### Sessions 1-5 — 2026-03-21
- Built Phase 1 (Features 1.1-1.4) + Phase 2 (Features 2.1-2.2)
- 188 tests passing
### Session 5 — 2026-03-21
- Built Feature 2.2: Line Movement + Cascade Detection
- lineMovementService.js (baseline, movement detection, sharp heuristic)
- cascadeService.js (scratch detection, affected user lookup, re-grade, alert creation)
- alertService.js (alert CRUD)
- routes: movements.js, alerts.js
- Migration 002: 3 new tables (line_baselines, line_movements, cascade_alerts)
- Integrated into oddsService.js (piggybacks on live fetch)
- Enhanced odds route with movements in response
- 30 new tests (unit + integration)
- Phase 2 Core Product is now COMPLETE
- Total: 188 tests (161 Node.js + 27 Python), all green
### Session 6 — 2026-03-22
- Built Feature 1.5: Bet Submission
- betService.js (create, settle, list bets)
- payoutCalculator.js (straight + parlay payout math)
- performanceService.js (ROI/win_rate/profit recalculation)
- ocrStub.js (MVP screenshot stub)
- routes/bets.js (7 endpoints)
- 33 new tests (unit + integration)
- All backend features for Phase 1 + Phase 2 now COMPLETE
- Total: 221 tests (194 Node.js + 27 Python), all green