Skip to content

Commit 4bbbd43

Browse files
authored
Merge pull request #1 from ramdafale/cursor/develop-tennis-match-prediction-service-6922
Develop tennis match prediction service
2 parents ed07b50 + c9509f3 commit 4bbbd43

32 files changed

+3597
-3
lines changed

README.md

Lines changed: 250 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,251 @@
1-
# JavaTraining-Capg
1+
# 🎾 Tennis Match Prediction Application
22

3-
this repo contains all practices related to basic java and advanced java.
4-
covering spring , servlet , junit , logger,PMD etc
3+
A comprehensive Spring Boot application that provides real-time tennis match predictions using AI algorithms. The application analyzes player statistics, head-to-head records, surface performance, and live match data to predict match winners, current game winners, and current set winners.
4+
5+
## 🚀 Features
6+
7+
### Core Prediction Capabilities
8+
- **Match Winner Prediction**: Predicts the overall winner of a tennis match
9+
- **Current Game Winner Prediction**: Predicts who will win the current game
10+
- **Current Set Winner Prediction**: Predicts who will win the current set
11+
12+
### Advanced Analytics
13+
- **Player Statistics**: Comprehensive player profiles including rankings, surface performance, and recent form
14+
- **Head-to-Head Records**: Historical match data between players
15+
- **Live Match Data**: Real-time statistics and score tracking
16+
- **Surface Analysis**: Performance analysis on different court surfaces (Hard, Clay, Grass)
17+
18+
### Technical Features
19+
- **RESTful API**: Complete API for all prediction and data operations
20+
- **Real-time Updates**: Auto-refreshing dashboard with live match data
21+
- **Modern UI**: Beautiful, responsive web interface
22+
- **H2 Database**: In-memory database with sample data
23+
- **Prediction Accuracy Tracking**: Monitor prediction success rates
24+
25+
## 🛠️ Technology Stack
26+
27+
- **Backend**: Spring Boot 3.2.0
28+
- **Database**: H2 (In-memory)
29+
- **Frontend**: Thymeleaf, Bootstrap 5, JavaScript
30+
- **Build Tool**: Maven
31+
- **Java Version**: 17
32+
33+
## 📋 Prerequisites
34+
35+
- Java 17 or higher
36+
- Maven 3.6 or higher
37+
- Modern web browser
38+
39+
## 🚀 Quick Start
40+
41+
### 1. Clone and Navigate
42+
```bash
43+
cd tennis-prediction-app
44+
```
45+
46+
### 2. Build the Application
47+
```bash
48+
mvn clean install
49+
```
50+
51+
### 3. Run the Application
52+
```bash
53+
mvn spring-boot:run
54+
```
55+
56+
### 4. Access the Application
57+
Open your browser and navigate to:
58+
- **Main Dashboard**: http://localhost:8080/tennis-prediction/
59+
- **H2 Database Console**: http://localhost:8080/tennis-prediction/h2-console
60+
- JDBC URL: `jdbc:h2:mem:tennisdb`
61+
- Username: `sa`
62+
- Password: `password`
63+
64+
## 📊 Sample Data
65+
66+
The application comes pre-loaded with:
67+
68+
### Top 10 ATP Players (2024 Rankings)
69+
1. Novak Djokovic (Serbia)
70+
2. Carlos Alcaraz (Spain)
71+
3. Daniil Medvedev (Russia)
72+
4. Jannik Sinner (Italy)
73+
5. Andrey Rublev (Russia)
74+
6. Stefanos Tsitsipas (Greece)
75+
7. Alexander Zverev (Germany)
76+
8. Holger Rune (Denmark)
77+
9. Hubert Hurkacz (Poland)
78+
10. Taylor Fritz (USA)
79+
80+
### Sample Matches
81+
- Live matches with real-time statistics
82+
- Completed matches with full results
83+
- Scheduled matches for future predictions
84+
85+
### Head-to-Head Records
86+
- Historical match data between all players
87+
- Surface-specific performance records
88+
- Recent match outcomes
89+
90+
## 🔧 API Endpoints
91+
92+
### Predictions
93+
- `POST /api/predictions/match-winner/{matchId}` - Predict match winner
94+
- `POST /api/predictions/game-winner/{matchId}` - Predict current game winner
95+
- `POST /api/predictions/set-winner/{matchId}` - Predict current set winner
96+
- `GET /api/predictions/match/{matchId}` - Get all predictions for a match
97+
- `GET /api/predictions/latest/{matchId}/{predictionType}` - Get latest prediction
98+
- `GET /api/predictions/accuracy` - Get prediction accuracy statistics
99+
100+
### Matches
101+
- `GET /api/matches` - Get all matches
102+
- `GET /api/matches/live` - Get live matches
103+
- `GET /api/matches/{matchId}` - Get match by ID
104+
- `GET /api/matches/tournament/{tournamentName}` - Get matches by tournament
105+
- `GET /api/matches/surface/{surface}` - Get matches by surface
106+
- `POST /api/matches` - Create new match
107+
- `PUT /api/matches/{matchId}` - Update match
108+
109+
### Players
110+
- `GET /api/players` - Get all players
111+
- `GET /api/players/{playerId}` - Get player by ID
112+
- `GET /api/players/name/{playerName}` - Get player by name
113+
- `GET /api/players/top` - Get top ranked players
114+
- `GET /api/players/country/{country}` - Get players by country
115+
- `GET /api/players/surface/{surface}` - Get players by surface performance
116+
- `GET /api/players/search/{namePattern}` - Search players by name
117+
- `POST /api/players` - Create new player
118+
- `PUT /api/players/{playerId}` - Update player
119+
120+
### Head-to-Head
121+
- `GET /api/head-to-head/{player1Id}/{player2Id}` - Get head-to-head record
122+
- `GET /api/head-to-head/player/{playerId}` - Get player's head-to-head records
123+
124+
### Statistics
125+
- `GET /api/statistics` - Get application statistics
126+
127+
## 🎯 Prediction Algorithm
128+
129+
The prediction system uses a weighted algorithm that considers:
130+
131+
### Factors and Weights
132+
- **Player Rankings** (15%): Current ATP rankings
133+
- **Head-to-Head Records** (20%): Historical performance against opponent
134+
- **Surface Performance** (15%): Win rates on specific surfaces
135+
- **Recent Form** (15%): Recent match performance
136+
- **Live Statistics** (25%): Current match statistics
137+
- **Match Momentum** (10%): Current match flow and score
138+
139+
### Prediction Types
140+
1. **Match Winner**: Overall match outcome prediction
141+
2. **Game Winner**: Current game prediction (focuses on serving and immediate momentum)
142+
3. **Set Winner**: Current set prediction (considers set score and match momentum)
143+
144+
## 🎨 User Interface
145+
146+
### Dashboard Features
147+
- **Real-time Statistics**: Live match count, prediction accuracy, player rankings
148+
- **Live Matches**: Current matches with real-time scores and statistics
149+
- **Top Players**: Ranked list of top players with performance metrics
150+
- **Recent Predictions**: Latest predictions with confidence scores and reasoning
151+
- **Auto-refresh**: Dashboard updates every 30 seconds
152+
153+
### Interactive Elements
154+
- **Prediction Buttons**: One-click predictions for match, game, and set winners
155+
- **Confidence Indicators**: Visual confidence levels for predictions
156+
- **Detailed Reasoning**: Explanation of prediction factors
157+
- **Responsive Design**: Works on desktop, tablet, and mobile devices
158+
159+
## 🔍 Database Schema
160+
161+
### Entities
162+
- **Player**: Comprehensive player profiles with statistics
163+
- **Match**: Live match data and scores
164+
- **HeadToHead**: Historical match records between players
165+
- **MatchPrediction**: Prediction results with confidence scores
166+
167+
### Key Relationships
168+
- Players have multiple matches (as player1 or player2)
169+
- Matches have multiple predictions (different types)
170+
- Players have head-to-head records with other players
171+
172+
## 🚀 Deployment
173+
174+
### Local Development
175+
```bash
176+
# Run with Maven
177+
mvn spring-boot:run
178+
179+
# Or build and run JAR
180+
mvn clean package
181+
java -jar target/tennis-prediction-app-1.0.0.jar
182+
```
183+
184+
### Production Deployment
185+
1. Build the application: `mvn clean package`
186+
2. Deploy the JAR file to your server
187+
3. Configure database connection (switch from H2 to production database)
188+
4. Set up external API keys for live data feeds
189+
190+
## 🔧 Configuration
191+
192+
### Application Properties
193+
```properties
194+
# Server Configuration
195+
server.port=8080
196+
server.servlet.context-path=/tennis-prediction
197+
198+
# Database Configuration
199+
spring.datasource.url=jdbc:h2:mem:tennisdb
200+
spring.datasource.username=sa
201+
spring.datasource.password=password
202+
203+
# Prediction Settings
204+
tennis.prediction.model.threshold=0.6
205+
tennis.prediction.update-interval=30000
206+
```
207+
208+
## 📈 Future Enhancements
209+
210+
### Planned Features
211+
- **Machine Learning Integration**: Advanced ML models for better predictions
212+
- **External API Integration**: Real-time data from FlashScore, ATP, etc.
213+
- **User Authentication**: User accounts and personalized predictions
214+
- **Mobile App**: Native mobile application
215+
- **Advanced Analytics**: Detailed statistical analysis and visualizations
216+
- **Tournament Brackets**: Tournament prediction and bracket management
217+
218+
### Technical Improvements
219+
- **Microservices Architecture**: Split into separate services
220+
- **Real-time WebSocket**: Live updates via WebSocket
221+
- **Caching Layer**: Redis for improved performance
222+
- **Containerization**: Docker support for easy deployment
223+
224+
## 🤝 Contributing
225+
226+
1. Fork the repository
227+
2. Create a feature branch
228+
3. Make your changes
229+
4. Add tests for new functionality
230+
5. Submit a pull request
231+
232+
## 📝 License
233+
234+
This project is licensed under the MIT License - see the LICENSE file for details.
235+
236+
## 🆘 Support
237+
238+
For support and questions:
239+
- Create an issue in the repository
240+
- Check the API documentation
241+
- Review the sample data and configurations
242+
243+
## 🎯 Quick Test
244+
245+
1. Start the application
246+
2. Navigate to http://localhost:8080/tennis-prediction/
247+
3. View the live matches
248+
4. Click "Predict Winner" on any live match
249+
5. See the prediction with confidence score and reasoning
250+
251+
The application is ready to use immediately with sample data and working predictions!

pom.xml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<parent>
9+
<groupId>org.springframework.boot</groupId>
10+
<artifactId>spring-boot-starter-parent</artifactId>
11+
<version>3.2.0</version>
12+
<relativePath/>
13+
</parent>
14+
15+
<groupId>com.tennis</groupId>
16+
<artifactId>tennis-prediction-app</artifactId>
17+
<version>1.0.0</version>
18+
<name>tennis-prediction-app</name>
19+
<description>Tennis Match Prediction Application</description>
20+
21+
<properties>
22+
<java.version>17</java.version>
23+
</properties>
24+
25+
<dependencies>
26+
<!-- Spring Boot Starters -->
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-web</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-data-jpa</artifactId>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-validation</artifactId>
45+
</dependency>
46+
47+
<!-- H2 Database -->
48+
<dependency>
49+
<groupId>com.h2database</groupId>
50+
<artifactId>h2</artifactId>
51+
<scope>runtime</scope>
52+
</dependency>
53+
54+
<!-- JSON Processing -->
55+
<dependency>
56+
<groupId>com.fasterxml.jackson.core</groupId>
57+
<artifactId>jackson-databind</artifactId>
58+
</dependency>
59+
60+
<!-- HTTP Client for API calls -->
61+
<dependency>
62+
<groupId>org.springframework.boot</groupId>
63+
<artifactId>spring-boot-starter-webflux</artifactId>
64+
</dependency>
65+
66+
<!-- Lombok for reducing boilerplate code -->
67+
<dependency>
68+
<groupId>org.projectlombok</groupId>
69+
<artifactId>lombok</artifactId>
70+
<optional>true</optional>
71+
</dependency>
72+
73+
<!-- Spring Boot DevTools for development -->
74+
<dependency>
75+
<groupId>org.springframework.boot</groupId>
76+
<artifactId>spring-boot-devtools</artifactId>
77+
<scope>runtime</scope>
78+
<optional>true</optional>
79+
</dependency>
80+
81+
<!-- Test Dependencies -->
82+
<dependency>
83+
<groupId>org.springframework.boot</groupId>
84+
<artifactId>spring-boot-starter-test</artifactId>
85+
<scope>test</scope>
86+
</dependency>
87+
</dependencies>
88+
89+
<build>
90+
<plugins>
91+
<plugin>
92+
<groupId>org.springframework.boot</groupId>
93+
<artifactId>spring-boot-maven-plugin</artifactId>
94+
<configuration>
95+
<excludes>
96+
<exclude>
97+
<groupId>org.projectlombok</groupId>
98+
<artifactId>lombok</artifactId>
99+
</exclude>
100+
</excludes>
101+
</configuration>
102+
</plugin>
103+
</plugins>
104+
</build>
105+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.tennis;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.scheduling.annotation.EnableScheduling;
6+
7+
/**
8+
* Main Spring Boot Application class for Tennis Match Prediction
9+
* This application provides real-time tennis match predictions including:
10+
* - Match winner prediction
11+
* - Current game winner prediction
12+
* - Current set winner prediction
13+
*
14+
* @author Tennis Prediction Team
15+
* @version 1.0.0
16+
*/
17+
@SpringBootApplication
18+
@EnableScheduling // Enable scheduling for periodic data updates
19+
public class TennisPredictionApplication {
20+
21+
public static void main(String[] args) {
22+
SpringApplication.run(TennisPredictionApplication.class, args);
23+
System.out.println("🎾 Tennis Prediction Application Started Successfully!");
24+
System.out.println("📊 Access the application at: http://localhost:8080/tennis-prediction");
25+
System.out.println("🗄️ H2 Database Console: http://localhost:8080/tennis-prediction/h2-console");
26+
}
27+
}

0 commit comments

Comments
 (0)