WebApp - Rock, Paper, Scissors
Overview
Welcome to your next Spring Boot project!
The goal of this project is to introduce you to the Spring Boot ecosystem by building a complete web application using modern Java development practices.
By the end of this project you will have built:
- A Spring Boot web application
- User registration and authentication
- Database persistence using Spring Data JPA
- Server-side rendered pages using Thymeleaf
- Game logic using Java
- Statistics tracking
- MVC architecture
This project is intentionally designed to resemble the structure of a real-world Spring Boot application while remaining approachable for developers who are new to Spring.
Learning Objectives
Upon completion, you should understand:
- What Spring Boot is and why it exists
- MVC (Model-View-Controller) architecture
- Spring Security fundamentals
- Spring Data JPA repositories
- Entity relationships and persistence
- Service layer design
- Thymeleaf template rendering
- Form submission and validation
- Application configuration
- Basic web application architecture
Technology Requirements
Your solution must use:
- Java 25
- Spring Boot 4
- Spring Web MVC
- Spring Security
- Spring Data JPA
- Thymeleaf
- H2 Database
- Maven
Project Requirements
Authentication
Users must be able to:
- Register an account
- Login
- Logout
Registration
A user must provide:
- Username
- Password
Validation
- Empty usernames
- Empty passwords
- Password and Re-Password comparison
- Duplicate usernames
Web Pages
Home Page
The home page should:
- Display a welcome message
- Show login/register links when not authenticated
- Show navigation links when authenticated
Registration Page
Users should be able to create an account.
Login Page
Users should be able to authenticate.
Profile Page
After login the user should see:
- Username
- Games Played
- Wins
- Losses
- Draws
- Current Win Streak
- Best Win Streak
This should act as the player's central hub.
Play Game Page
The user should be able to choose:
- Rock
- Paper
- Scissors
When submitted:
- The server generates a random computer choice.
- The result is calculated.
- Statistics are updated.
- The result is displayed to the user.
Example:
Player chose: Rock
Computer chose: Paper
Result: Loss
Statistics Tracking
The application must persist the following:
- Games Played
- Wins
- Losses
- Draws
- Current Win Streak
- Best Win Streak
Suggested Domain Model
These are suggestions, not requirements.
User
Suggested fields:
- id
- username
- password
PlayerStatistics
Suggested fields:
- id
- gamesPlayed
- wins
- losses
- draws
- currentStreak
- bestStreak
Relationship suggestion:
One User → One Statistics Record
Suggested Project Structure
controller/
- HomeController
- AuthController
- GameController service/
- UserService
- StatisticsService
- GameService repository/
- UserRepository
- StatisticsRepository entity/
- User
- PlayerStatistics config/
- SecurityConfiguration
Gameplay Rules
Rock beats Scissors
Paper beats Rock
Scissors beats Paper
Matching selections result in a draw.
The game logic should be isolated from the controller layer.
Controllers should not contain business logic.
UI Requirements
Use Thymeleaf templates.
Suggested pages:
- home.html
- login.html
- register.html
- dashboard.html
- play.html
Your application should have:
- Navigation bar
- Consistent layout
- User-friendly forms
- Responsive design
Visual appearance is less important than functionality and clean code.
Submission Requirements
- Source code committed to Git.
- README.md included.
- ARCHITECTURE.md included.
- Application builds successfully.
- Application runs without modification.
- No IDE-specific files committed unnecessarily.