https://github.com/xoraus/livecricscore
API to fetch Live Cricket Score
https://github.com/xoraus/livecricscore
backend java jpa spring spring-w
Last synced: 2 months ago
JSON representation
API to fetch Live Cricket Score
- Host: GitHub
- URL: https://github.com/xoraus/livecricscore
- Owner: xoraus
- Created: 2024-01-23T13:46:14.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-23T14:55:25.000Z (over 2 years ago)
- Last Synced: 2025-03-03T13:25:05.265Z (over 1 year ago)
- Topics: backend, java, jpa, spring, spring-w
- Language: Java
- Homepage:
- Size: 8.45 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🏏 Live Cricket Score API - Spring Boot Backend 🚀
## 📋 Requirement
The Live Cricket Score API is a Spring Boot backend project designed to fulfill the need for real-time updates on cricket matches. The system provides information such as live scores, point tables for the CWC 2023, and details about all ongoing matches.
## Demo

## 🎨 Design
### Controllers
The primary controller, `CricketController`, handles various endpoints for fetching live match scores, CWC 2023 point tables, and a list of all matches.
```java
@RestController
@RequestMapping("/cricket")
@CrossOrigin("*")
public class CricketController {
// ... (controller methods)
}
```
### Entity
The `Match` entity encapsulates the details of a cricket match, including team information, scores, live text, match link, and status.
```java
@Entity
@Table(name = "cricket_match")
public class Match {
// ... (fields)
@Enumerated
private MatchStatus status;
private Date date = new Date();
// ... (methods)
}
```
### Enum
The `MatchStatus` enum defines the possible statuses of a cricket match - either completed or live.
```java
public enum MatchStatus {
COMPLETED, LIVE
}
```
### Repositories
The `MatchRepo` interface, extending `JpaRepository`, provides CRUD operations for the `Match` entity.
```java
public interface MatchRepo extends JpaRepository {
Optional findByTeamHeading(String teamHeading);
}
```
### Services
The `CricketService` interface outlines methods to retrieve live match scores, CWC 2023 point tables, and details of all matches.
```java
public interface CricketService {
List getLiveMatchScores();
List> getCWC2023PointTable();
List getAllMatches();
}
```
## 🚀 Implementation
### Get Live Match Scores 📊
```java
@GetMapping("/live")
public ResponseEntity> getLiveMatchScores() throws InterruptedException {
System.out.println("Getting live match");
return new ResponseEntity<>(this.cricketService.getLiveMatchScores(), HttpStatus.OK);
}
```
### Get CWC 2023 Point Table 🏆
```java
@GetMapping("/point-table")
public ResponseEntity> getCWC2023PointTable() {
return new ResponseEntity<>(this.cricketService.getCWC2023PointTable(), HttpStatus.OK);
}
```
### Get All Matches 📅
```java
@GetMapping
public ResponseEntity> getAllMatches() {
return new ResponseEntity<>(this.cricketService.getAllMatches(), HttpStatus.OK);
}
```
## 🌐 Cross-Origin Resource Sharing
The `@CrossOrigin("*")` annotation in the `CricketController` allows for cross-origin resource sharing.
Feel free to explore and integrate this API to meet the requirements of fetching live cricket scores and tournament statistics. Stay updated with real-time cricket action! 🏏✨