A backend system built with Spring Boot that manages game data.
- Tech Stack
- Project Structure
- Getting Started
- Configuration
- API Overview
- Data Model
- Swagger / OpenAPI
- Roadmap / Ideas
- License
- Spring Boot 3.5 (RESTful API architecture)
- PostgreSQL 17 with JPA / Hibernate ORM
- Layered design (Controller–Service–Repository)
- DTO mapping for input models
- Input validation and entity constraints
- Swagger / OpenAPI documentation
- Docker Compose for database containerization
- Logging and SQL formatting enabled
- Extensible modular structure for future features
- Java 25 (via Spring Boot parent)
- Spring Boot 3.5.7
spring-boot-starter-webspring-boot-starter-data-jpa- Validation via Hibernate Validator / Jakarta
- PostgreSQL 17
- springdoc-openapi (Swagger UI)
- Maven
See
pom.xmlfor exact versions.
src/
└─ main/
├─ java/com/dev/gamestats
│ ├─ controllers/ # REST controllers
│ ├─ model/ # Entities + DTOs (Game, Player, Match; GameIn, PlayerIn, MatchIn)
│ ├─ repo/ # Spring Data repositories (CrudRepository)
│ └─ services/ # Service layer
└─ resources/
└─ application.properties
Note: You also have a
docker-compose.ymlin the project root.
- JDK 25 (or compatible with Spring Boot 3.5.x)
- Maven 3.9+ (or use the provided
mvnwwrapper) - Docker (for running PostgreSQL)
-
Start PostgreSQL (see next section).
-
Update
src/main/resources/application.propertiesif needed (DB URL/credentials). -
Build & run the app:
./mvnw spring-boot:run # or mvn spring-boot:run -
The app will be available at http://localhost:8080.
A docker-compose.yml file is already included in the project root.
To start PostgreSQL:
docker-compose up -dThis launches a PostgreSQL 17 container on host port 5434 with persistent data stored in a named Docker volume.
To stop it:
docker-compose downDefault application properties (src/main/resources/application.properties):
spring.application.name=GameStats
# Database
spring.datasource.url=jdbc:postgresql://localhost:5434/gamestats
spring.datasource.username=gamestats
spring.datasource.password=gamestats
spring.datasource.driver-class-name=org.postgresql.Driver
# JPA / Hibernate
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialectFor production, switch
ddl-autotovalidateornoneand manage schema via migrations.
Base path: http://localhost:8080/api
Resource: /player
-
POST
/api/player{ "firstName": "Alice", "lastName": "Nguyen", "countryCode": "US" } -
GET
/api/player/ -
GET
/api/player/{playerId} -
PUT
/api/player/{playerId} -
DELETE
/api/player/{playerId}
Resource: /game
-
POST
/api/game{ "name": "Chess", "ruleSet": "Standard FIDE rules" } -
GET
/api/game/ -
GET
/api/game/{gameId} -
PUT
/api/game/{gameId} -
DELETE
/api/game/{gameId}
Resource: /match
-
POST
/api/match{ "game_id": 1, "player1_id": 10, "player2_id": 12, "winner_id": 12, "playedAt": "Home", "score1": 200, "score2": 280, "notes": "gg wp!" } -
GET
/api/match/ -
GET
/api/match/{matchId} -
PUT
/api/match/{matchId} -
DELETE
/api/match/{matchId}
Validation & Integrity
countryCodemust be ISO-2 format (e.g.,US,IL).- No self-matches:
player1_id≠player2_id.- Winner must be either
player1_idorplayer2_id.
These constraints are enforced at the DB level via@Check.
Entity Relationship Diagram — GameStats database.
If springdoc-openapi is included, the documentation is available at:
- Swagger UI: http://localhost:8080/swagger-ui.html
- OpenAPI JSON: http://localhost:8080/v3/api-docs
Tip: Add these URLs as bookmarks for faster testing.
- Add paging & filtering
- Add CLI client for demonstration
- Integrate JWT-based authentication
- Implement unit and integration tests
Developed by Daniel Katzman.
