A comprehensive Spring Boot application for managing cricket teams, players, matches, and statistics. This RESTful API provides complete functionality for cricket team management with features like player registration, match scheduling, statistics tracking, and email notifications.
- Player Management: Register and manage cricket players with detailed profiles
- Team Management: Create and manage cricket teams with rankings and ICC points
- Match Management: Schedule and track cricket matches between teams
- Statistics Tracking: Maintain detailed player statistics (batting, bowling averages)
- Email Notifications: Automatic email notifications for player registrations
- RESTful API: Complete REST API with proper HTTP status codes
- Database Integration: MySQL database with JPA/Hibernate ORM
- Email Service: SMTP email integration for notifications
- Exception Handling: Custom exception handling with proper error responses
- API Documentation: Swagger/OpenAPI documentation
- Data Validation: Request/Response DTOs with proper validation
- Framework: Spring Boot 3.3.5
- Language: Java 21
- Database: MySQL 8.0
- ORM: Spring Data JPA with Hibernate
- Build Tool: Maven
- Documentation: SpringDoc OpenAPI 2.6.0
- Email: Spring Boot Mail Starter
- Utilities: Lombok for boilerplate reduction
Before running this application, ensure you have:
- Java 21 or higher
- MySQL 8.0 or higher
- Maven 3.6 or higher
- Git (for cloning the repository)
git clone <repository-url>
cd CricBuzz- Create a MySQL database named
cricbuzzDB - Update database credentials in
src/main/resources/application.propertiesif needed:spring.datasource.username=root spring.datasource.password=admin
mvn spring-boot:run./mvnw spring-boot:runmvn clean package
java -jar target/CricBuzz-0.0.1-SNAPSHOT.jar- Application: http://localhost:8080
- API Documentation: http://localhost:8080/swagger-ui.html
http://localhost:8080/api/v1
POST /player
Content-Type: application/json
{
"name": "Virat Kohli",
"age": 34,
"gender": "MALE",
"speciality": "BATTER",
"email": "virat.kohli@example.com"
}GET /player?player-id=1GET /player/gender/MALEGET /player/gender/MALE/speciality/BATTERPOST /team
Content-Type: application/json
{
"teamName": "India",
"ranking": 1,
"iccPoints": 120
}POST /match?teamA-id=1&teamB-id=2
Content-Type: application/json
{
"title": "India vs Australia",
"matchType": "ODI",
"overs": 50,
"place": "Melbourne Cricket Ground"
}POST /stats?player-id=1
Content-Type: application/json
{
"runsScored": 12000,
"wicketsTaken": 0,
"battingAverage": 59.07,
"bowlingAverage": 0.0
}id(Primary Key)name(String)age(Integer)gender(Enum: MALE, FEMALE)speciality(Enum: BATTER, BOWLER, ALL_ROUNDER)email(String)team_id(Foreign Key)
id(Primary Key)team_name(String)ranking(Integer)icc_points(Integer)
id(Primary Key)title(String)match_type(Enum: ODI, T20, TEST)overs(Integer)place(String)started_at(Timestamp)
id(Primary Key)runs_scored(Integer)wickets_taken(Integer)batting_average(Double)bowling_average(Double)player_id(Foreign Key)
The application uses the following key configurations:
# Database Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/cricbuzzDB
spring.datasource.username=root
spring.datasource.password=admin
spring.jpa.hibernate.ddl-auto=update
# Email Configuration
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=acciojobspring@gmail.com
spring.mail.password=imrprnqgfrgfarvisrc/main/java/com/acciojob/CricBuzz/
βββ controller/ # REST API Controllers
β βββ PlayerController.java
β βββ TeamController.java
β βββ MatchController.java
β βββ StatsController.java
βββ service/ # Business Logic Layer
β βββ PlayerService.java
β βββ TeamService.java
β βββ MatchService.java
β βββ StatsService.java
βββ repository/ # Data Access Layer
β βββ PlayerRepository.java
β βββ TeamRepository.java
βββ model/ # Entity Classes
β βββ Player.java
β βββ Team.java
β βββ CricketMatch.java
β βββ Stats.java
β βββ Enum/
β βββ Gender.java
β βββ Speciality.java
β βββ MatchType.java
βββ dto/ # Data Transfer Objects
β βββ request/
β βββ response/
βββ converter/ # Entity-DTO Converters
βββ exception/ # Custom Exceptions
βββ CricBuzzApplication.java
Run the test suite using Maven:
mvn test{
"id": 1,
"name": "Virat Kohli",
"age": 34,
"gender": "MALE",
"speciality": "BATTER",
"email": "virat.kohli@example.com"
}{
"title": "India vs Australia",
"matchType": "ODI",
"overs": 50,
"place": "Melbourne Cricket Ground",
"startedAt": "2024-01-15T10:00:00.000+00:00",
"teams": [
{
"teamName": "India",
"ranking": 1
},
{
"teamName": "Australia",
"ranking": 2
}
]
}The application includes comprehensive error handling:
- PlayerNotFoundException: When player ID is invalid
- TeamNotFoundException: When team ID is invalid
- HTTP 400: Bad Request for invalid data
- HTTP 201: Created for successful resource creation
The application automatically sends email notifications when:
- A new player is registered successfully
Email configuration uses Gmail SMTP with the following settings:
- Host: smtp.gmail.com
- Port: 587
- Authentication: Required
- TLS: Enabled
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Spring Boot team for the excellent framework
- MySQL team for the database
- Lombok team for reducing boilerplate code
Note: This is a Spring Boot application for cricket team management. Make sure to have MySQL running and properly configured before starting the application.