A comprehensive Python project for ATP tennis rankings data collection, analysis, and visualization. Features include web scraping, database management, interactive web interface, and AI integration via Model Context Protocol (MCP).
- π Data Collection: Automated scraping from atptour.com
- ποΈ Database: 2,600+ weeks of historical ATP rankings (1973-2025)
- π Web Interface: Modern FastAPI application with interactive charts
- π CLI Analysis: Command-line tools for player statistics and comparisons
- π€ AI Integration: MCP server for AI assistant access
- π¨ Visualizations: Matplotlib (CLI) and Chart.js (web) graphs
- π§ͺ Testing: Comprehensive test suite with pytest
-
Clone the repository
git clone https://github.com/Jupiterian/ATP-Rankings-Data-Visualization.git cd ATP-Rankings-Data-Visualization -
Install dependencies
pip install -r requirements.txt
-
Run the web application
uvicorn src.main:app --reload
Open your browser to
http://localhost:8000
To get the latest rankings data:
python scripts/filler.pyATP-Rankings-Data-Visualization/
βββ src/ # Core application code
β βββ main.py # FastAPI web application
β βββ services.py # Business logic layer
β βββ mcp_router.py # MCP API endpoints
β βββ mcp_manifest.json # MCP schema definition
βββ scripts/ # Utility scripts
β βββ generate.py # Regenerate entire database
β βββ filler.py # Update database with latest data
β βββ analyze.py # CLI data analysis tool
β βββ debug.py # Database debugging utility
β βββ test_mcp.sh # Quick MCP endpoint tests
β βββ test_render_mcp.py # Production deployment tests
β βββ keep_alive.py # Render free tier keep-alive
β βββ deploy.sh # Deployment helper
βββ docs/ # Documentation
β βββ MCP_README.md # MCP server documentation
β βββ MCP_DEPLOYMENT.md # Deployment guide
β βββ MCP_IMPLEMENTATION_SUMMARY.md
β βββ MCP_QUICK_REFERENCE.md
βββ templates/ # HTML templates (Jinja2)
β βββ index.html # Home page
β βββ week.html # Weekly rankings
β βββ comparison.html # Player comparison
β βββ weeks_at_no1.html # Histogram visualization
β βββ api_docs.html # API documentation
βββ tests/ # Test suite
β βββ test_mcp.py # MCP endpoint tests
βββ Examples/ # Example visualizations
βββ rankings.db # SQLite database (2,600+ tables)
βββ Dockerfile # Container image
βββ docker-compose.yml # Docker Compose config
βββ Procfile # Render/Heroku deployment
βββ runtime.txt # Python version
βββ requirements.txt # Python dependencies
- Browse Rankings: View all 2,600+ weeks organized by year
- Player Search: Autocomplete search across all players
- Player Comparison: Side-by-side statistics with career graphs
- Weeks at #1: Interactive histogram of world #1 rankings
- API Access: RESTful API with comprehensive documentation
- Keyboard Navigation: Arrow keys to navigate between weeks
uvicorn src.main:app --reloadAccess at http://localhost:8000
GET /- Home pageGET /week/{week_id}- Weekly rankingsGET /comparison- Player comparison toolGET /weeks-at-no1- Weeks at #1 histogramGET /api-docs- API documentationGET /api/weeks- List all available weeksGET /api/week/{week_id}- Get week dataGET /api/search-players?q={query}- Search playersPOST /api/player-factfile- Player statisticsPOST /api/player-career- Career time-series data
The MCP server allows AI assistants like Claude to query ATP rankings data.
Base URL: http://localhost:8000/mcp
GET /mcp/health- Health checkGET /mcp/manifest- Server capabilitiesPOST /mcp/tools/search_players- Search for playersPOST /mcp/tools/get_player_factfile- Player statisticsPOST /mcp/tools/get_player_career- Career historyGET /mcp/tools/get_weeks_at_no1- Weeks at #1 leaderboardGET /mcp/tools/get_all_weeks- Available weeks listPOST /mcp/tools/get_week_rankings- Specific week data
# Run test suite
pytest tests/test_mcp.py -v
# Quick smoke test
bash scripts/test_mcp.sh
# Test production deployment
python scripts/test_render_mcp.py https://your-app.onrender.comFull Documentation: See docs/MCP_README.md
Analyze player data and generate matplotlib visualizations.
# Show player statistics
python scripts/analyze.py -f Roger_Federer
# Plot ranking history
python scripts/analyze.py -r Roger_Federer Rafael_Nadal
# Plot points history
python scripts/analyze.py -p Novak_Djokovic
# Weeks at #1 histogram
python scripts/analyze.py -nOptions:
-h- Show help menu-f- Player factfile (statistics)-r- Ranking history plot-p- Points history plot-n- Weeks at #1 bar graph
Examples: See Examples/Examples.md
Add latest rankings data:
python scripts/filler.pyComplete database rebuild (takes ~1 hour):
python scripts/generate.pyFind and fix problematic tables:
python scripts/debug.pyRecommended GUI tool: DB Browser for SQLite
-
Push to GitHub
git add . git commit -m "Deploy ATP Rankings" git push origin main
-
Connect to Render
- Go to render.com
- Click "New Web Service"
- Connect your GitHub repository
- Render auto-detects settings from
Procfile
-
Deploy
- Click "Create Web Service"
- Wait 2-3 minutes for deployment
-
Keep Alive (Optional)
python scripts/keep_alive.py https://your-app.onrender.com
Full Guide: See docs/MCP_DEPLOYMENT.md for Railway, Fly.io, Heroku, Docker, and VPS options.
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src --cov-report=html
# Test specific module
pytest tests/test_mcp.py::TestMCPHealth -vBackend:
- Python 3.12
- FastAPI (web framework)
- SQLite3 (database)
- Uvicorn (ASGI server)
- Pydantic (validation)
Frontend:
- Jinja2 (templates)
- Chart.js (interactive charts)
- HTML5/CSS3
Scraping & Analysis:
- BeautifulSoup4 (web scraping)
- Matplotlib (static visualizations)
Testing & Deployment:
- Pytest (testing framework)
- Docker (containerization)
- Render/Railway/Fly.io (hosting)
See LICENSE file for details.
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
For questions or issues, please open a GitHub issue.
β If you find this project useful, please star the repository!
