How asim-shoaib/fantasypredictorserver works
DraftGenius turns a selected PSL matchup into player profiles and three fantasy-team recommendations, with live genetic-algorithm progress delivered to the browser. Its main runtime path runs from the React match and results screens through Flask routes, profile construction, form/Elo scoring, and team optimization. A separate data-preparation workflow ingests Cricsheet matches and produces the Elo dataset used by the app. The README documents the SSE experience and major capabilities; some route-to-frontend and unsampled subsystem details are therefore shown only where documented, not inferred from names.
Main entry points: data_cache.py Runtime data cache · app.py Flask application · pipeline.py Match scoring pipeline · player_service.py Player profiles
Components 33
Fantasy web app
- Match selection
frontend/src/pages/Home.tsx - App routing
frontend/src/App.tsx - Match workspace
frontend/src/pages/Match.tsx - Team results
frontend/src/pages/Results.tsx - Generation stream
frontend/src/hooks/useGenerate.ts - API client
frontend/src/api/client.ts - GA evolution view
frontend/src/components/evolution/EvolutionDashboard.tsx
Flask API
- Flask application
backend/app.py - Player endpoints
backend/routes/players.py - Team generation endpoints
backend/routes/teams.py - Constraint endpoints
backend/routes/constraints.py - Roster controls
backend/routes/roster.py - Franchise listing
backend/routes/match.py
Player analytics
- Runtime data cache
backend/data_cache.py - Player profiles
backend/services/player_service.py - Form prediction
backend/core/hmm/predictor.py - Player HMM
backend/core/hmm/short_term_hmm.py - General HMM
backend/core/hmm/general_hmm.py - Fantasy credits
backend/services/credit_engine.py - Elo ratings
backend/core/elo_engine.py - Form features
backend/core/form_features.py - Headshot fetching
backend/services/profile_fetcher.py
Team optimization
- Genetic optimizer
backend/services/team_generator.py
Data preparation
- Match scoring pipeline
backend/jobs/pipeline.py - Match file loader
backend/jobs/match_loader.py - Match parser
backend/jobs/match_parser.py - Parsed match cache
backend/utils/smart_cache.py - Role resolution
backend/services/role_resolver.py - Fantasy point scoring
backend/core/scoring.py - Pipeline CLI
backend/cli.py - Cricsheet updater
backend/jobs/data_updater.py
Other components
- Fantasy user
- ESPN profile service
Connections 44
- Fantasy user → Match selection: selects matchup
README.md - Match selection → App routing: selects matchup
frontend/src/App.tsx - App routing → Match workspace: routes to
frontend/src/App.tsx - App routing → Team results: routes to
frontend/src/App.tsx - Match workspace → API client: requests data
- Team results → Generation stream: starts generation
- Generation stream → API client: uses API
- API client → Flask application: HTTP and SSE
README.md - Flask application → Player endpoints: registers
backend/app.py - Flask application → Team generation endpoints: registers
backend/app.py - Flask application → Constraint endpoints: registers
backend/app.py - Flask application → Roster controls: registers
backend/app.py - Flask application → Franchise listing: registers
backend/app.py - Player endpoints → Player profiles: builds profiles
backend/routes/players.py - Player endpoints → Runtime data cache: reads cache
backend/routes/players.py - Team generation endpoints → Player profiles: builds profiles
backend/routes/teams.py - Team generation endpoints → Genetic optimizer: generates teams
backend/routes/teams.py - Team generation endpoints → Runtime data cache: uses runtime data
backend/routes/teams.py - Constraint endpoints → Genetic optimizer: reads constraints
backend/routes/constraints.py - Constraint endpoints → Runtime data cache: uses cache
backend/routes/constraints.py - Roster controls → Runtime data cache: updates overrides
backend/routes/roster.py - Franchise listing → Runtime data cache: reads franchises
backend/routes/match.py - Player profiles → Runtime data cache: reads player data
backend/services/player_service.py - Player profiles → Form prediction: predicts form
backend/services/player_service.py - Player profiles → Fantasy credits: computes credits
backend/services/player_service.py - Runtime data cache → Form prediction: initializes predictor
backend/data_cache.py - Form prediction → General HMM: uses model
backend/core/hmm/predictor.py - Form prediction → Player HMM: uses model
backend/core/hmm/predictor.py - Genetic optimizer → Team results: returns recommendations
README.md - Generation stream → GA evolution view: streams progress
README.md - Pipeline CLI → Match scoring pipeline: runs pipeline
backend/cli.py - Pipeline CLI → Cricsheet updater: updates source data
backend/cli.py - Match scoring pipeline → Match file loader: iterates matches
backend/jobs/pipeline.py - Match scoring pipeline → Parsed match cache: gets cached records
backend/jobs/pipeline.py - Match scoring pipeline → Role resolution: resolves roles
backend/jobs/pipeline.py - Match scoring pipeline → Fantasy point scoring: scores records
backend/jobs/pipeline.py - Parsed match cache → Match parser: parses uncached files
backend/utils/smart_cache.py - Match parser → Fantasy point scoring: produces match records
- Pipeline CLI → Elo ratings: applies ratings
backend/cli.py - Pipeline CLI → Headshot fetching: fetches photos
backend/cli.py - Player endpoints → Headshot fetching: fetches roster photos
backend/routes/players.py - Headshot fetching → ESPN profile service: fetches headshots
backend/services/profile_fetcher.py - Elo ratings → Runtime data cache: supplies Elo dataset
- Form features → Form prediction: supports prediction