A Fantasy Premier League squad optimization tool that helps users make informed decisions about transfers, captain choices, and team selections.
docker compose up -d
./scripts/check-bootstrap.shServices Available:
- π Frontend: http://localhost:3000
- π§ Backend API: http://localhost:8000
- π API Docs: http://localhost:8000/docs
# 1. Configure environment
nano .env backend/.env frontend/.env.local
# 2. Run setup
./scripts/setup-production.sh
# 3. Done!- Squad Analysis: Import and analyze your FPL team via official API
- Captain Recommendations: AI-powered suggestions based on form, fixtures, and ownership
- Transfer Suggestions: Optimized recommendations within budget constraints
- Player Explorer: Browse and filter top-performing players
- Automatic Gameweek Handling: Auto-syncs data when gameweeks transition
- Auto-Initialization: Bootstrap data syncs automatically on startup
- Background Scheduler: 4 scheduled jobs for data synchronization
- Hourly bootstrap sync
- Daily gameweek transition checks
- Match-day fixture updates
- Pre-deadline reminders
- Real-time Data: Direct integration with official FPL API
- Intelligent Caching: Redis-powered caching for optimal performance
- Rate Limiting: Respects FPL API limits with intelligent throttling
All scripts located in scripts/ directory:
./scripts/check-bootstrap.shShows: Events, Players, Teams count + Current Gameweek
./scripts/init-bootstrap.shUse this if automatic initialization fails.
./scripts/logs.sh backend # All backend logs
./scripts/logs.sh backend bootstrap # Filter for bootstrap
./scripts/logs.sh frontend # Frontend logs./scripts/debug-startup.shRuns comprehensive checks on Docker, containers, DB, Redis, FPL API, environment variables, bootstrap data, and scheduler.
./scripts/setup-production.shOne-command production deployment with diagnostics.
See scripts/README.md for detailed documentation.
fpl/
βββ backend/ # FastAPI backend with SQLAlchemy & Redis
β βββ app/
β β βββ api/ # API endpoints
β β βββ services/ # Business logic (scheduler, data sync)
β β βββ models/ # Database models
β β βββ startup.py # Auto-initialization logic
β β βββ main.py # FastAPI app
β βββ requirements.txt
βββ frontend/ # Next.js frontend with TypeScript
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Next.js pages
β β βββ lib/ # Utilities
β βββ package.json
βββ scripts/ # Helper scripts for deployment
β βββ check-bootstrap.sh
β βββ init-bootstrap.sh
β βββ debug-startup.sh
β βββ logs.sh
β βββ setup-production.sh
βββ docker compose.yml # Unified Docker Compose (dev + prod)
βββ .env # Docker environment (mode switching)
βββ DEPLOYMENT.md # Comprehensive deployment guide
# Development (default)
ENVIRONMENT=development
DEBUG=true
NEXT_PUBLIC_API_URL=http://localhost:8000
# Production (uncomment to use)
# ENVIRONMENT=production
# DEBUG=false
# NEXT_PUBLIC_API_URL=https://api.fpl.tonyalapatt.inDATABASE_URL=postgresql://fpl_user:password@db:5432/fpl_db
REDIS_URL=redis://redis:6379/0
DEBUG=false
SECRET_KEY=generate-secure-key
JWT_SECRET_KEY=generate-jwt-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-secret
FRONTEND_URL=https://fpl.tonyalapatt.in
CORS_ORIGINS=https://fpl.tonyalapatt.in
FPL_API_BASE_URL=https://fantasy.premierleague.com/apiNEXT_PUBLIC_API_URL=https://api.fpl.tonyalapatt.in
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-idSee DEPLOYMENT.md for comprehensive configuration guide.
GET /api/health/- Basic health checkGET /api/health/ready- Readiness check (DB, Redis, Bootstrap, Scheduler)GET /api/health/scheduler- Scheduler status with job details
POST /api/squad/fetch- Fetch user squad from FPL APIGET /api/squad/{team_id}- Get squad details and statisticsGET /api/recommendations/captain/{team_id}- Captain recommendationsGET /api/recommendations/transfers/{team_id}- Transfer suggestionsGET /api/recommendations/players/top- Top players for transfersPOST /api/sync/bootstrap- Manual bootstrap sync
Visit http://localhost:8000/docs for full Swagger UI documentation.
# Start services
docker compose up -d
# Stop services
docker compose down
# Rebuild
docker compose up -d --build
# View logs
docker compose logs backend
docker compose logs frontend
# Shell into container
docker compose exec backend bash
# Database shell
docker compose exec db psql -U fpl_user -d fpl_db- FastAPI - Modern Python web framework
- SQLAlchemy - Database ORM
- APScheduler - Background task scheduling
- Redis - Caching and session storage
- PostgreSQL - Primary database
- Pydantic - Data validation
- Next.js 14 - React framework
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS
- Axios - HTTP client
- Docker - Containerization
- Gunicorn + Uvicorn - Production server
# 1. Run diagnostics
./scripts/debug-startup.sh
# 2. Check logs
./scripts/logs.sh backend bootstrap
# 3. Manual trigger
./scripts/init-bootstrap.sh# Check if bootstrap initialized
./scripts/check-bootstrap.sh
# Verify backend health
curl http://localhost:8000/api/health/ready# Check scheduler status
curl http://localhost:8000/api/health/scheduler
# Restart backend
docker compose restart backendSee DEPLOYMENT.md for comprehensive troubleshooting guide.
After deployment, verify:
- β
./scripts/check-bootstrap.shshows data initialized - β
/api/health/readyreturns 200 OK - β
/api/health/schedulershows"running": true - β Frontend loads and Google Sign-In works
- β Squad data loads successfully
- DEPLOYMENT.md - Comprehensive deployment guide
- scripts/README.md - Helper scripts documentation
- CLAUDE.md - Application plan and architecture
- API Docs - http://localhost:8000/docs (when running)
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License.
- Caching Strategy: Bootstrap data cached 1 hour, user squads 10 minutes
- Rate Limiting: Respects FPL API limits (200 requests/hour)
- Auto-Sync: Background scheduler keeps data fresh automatically
- Database: Optimized queries with proper indexing
Last Updated: 2025-10-07 Maintainer: Tony Alapatt