A comprehensive Spring Boot web application that simulates a Blackjack casino game with complete user management, credit card processing, email verification, and internationalization support. The application follows MVC architecture with Spring Security for authentication and authorization.
- Full Blackjack Game Logic - Complete implementation with standard Blackjack rules including:
- Hit, Stand, Double Down, Split, Surrender
- Insurance and Even Money options
- Dealer plays until soft 17
- Natural Blackjack payouts (2.5:1)
- Insurance pays 2:1
- Betting System - Minimum bet 10.00, maximum 1,000.00
- Game History - Track all played games with bet history
- Persistent Game State - Incomplete games are saved and can be resumed
- Registration System - New user registration with validation
- Email Verification - Account activation via email confirmation
- Password Reset - Forgot password functionality with email reset links
- Profile Management - User profiles with personal information
- Role-Based Access - REGULAR, MODERATOR, ADMIN roles
- Credit Card Registration - Store multiple credit cards (max 3 per user)
- Deposit Functionality - Add funds to user wallet
- Card Verification - Luhn algorithm validation, expiration date checking
- Supported Cards - Visa, Mastercard, American Express, Discover, Troy
- Spring Security - Comprehensive security configuration
- Remember Me - Persistent login functionality
- CSRF Protection - Enabled for all forms
- Password Encoding - BCrypt password hashing
- reCAPTCHA Integration - Google reCAPTCHA v2 for form protection
- Multi-Language Support - English and Bulgarian (български)
- Locale Switching - Cookie-based language preferences
- Dynamic Content - All user-facing text can be internationalized
- Registration Emails - Account activation links
- Password Reset Emails - Secure password reset tokens
- HTML Email Templates - Responsive email designs using Thymeleaf
- MailHog Integration - Email testing during development
- Framework: Spring Boot 3.2.9
- Security: Spring Security 6.x
- Database: MySQL with Hibernate JPA
- Migration: Liquibase for database version control
- Email: JavaMailSender with SMTP support
- Validation: Hibernate Validator with custom annotations
- Template Engine: Thymeleaf
- HTTP Client: RestTemplate and WebClient
- Templating: Thymeleaf with Spring Security integration
- CSS Framework: Custom CSS with responsive design
- JavaScript: Client-side form validation and AJAX calls
- reCAPTCHA: Google reCAPTCHA integration
- Build Tool: Gradle
- Containerization: Docker support for MySQL and MailHog
- Java Version: 17
- MVC Pattern - Clear separation of concerns (Controllers, Services, Repositories)
- Dependency Injection - Spring IoC container management
- Event-Driven - Application events for user registration and password reset
- DTO Pattern - Data transfer objects between layers
- Repository Pattern - Data access abstraction with Spring Data JPA
- Chain of Responsibility Pattern - Game logic engine
SecurityConfig- Spring Security configurationI18nConfig- Internationalization setupMailConfig- Email configurationRecaptchaConfig- Google reCAPTCHA settingsWebConfig- Web MVC configuration
GameService- Core game logic implementationUserService- User management operationsCreditCardService- Payment processingWalletService- Balance managementMailService- Email communicationsUserTokenService- Token generation and validationRecaptchaService- CAPTCHA verification
@UniqueEmail/@UniqueUsername- Duplicate checking@CustomCreditCardNumber- Card number validation@FutureExpirationDate- Expiry date validation@MinAge- Age restriction (18+)@FieldMatch- Password confirmation matching
users- User account informationroles- User roles for authorizationwallets- User balances and betting amountscredit_cards- Registered credit cardslast_games- Current incomplete game sessionsplayed_games- Game historybet_history- Betting recordsactivation_tokens- Email verification tokensreset_pass_tokens- Password reset tokens
/- Home page/auth/login- Login page/auth/register- Registration page/auth/reset- Password reset request/rules- Game rules/test/**- Testing endpoints
/play/**- Gameplay endpoints/credit-card/**- Credit card management/auth/activation- Account activation/auth/reset_pass- Password reset
- Java 17+
- Docker (optional, for MySQL/MailHog)
- MySQL database (if not using Docker)
cd /path/to/BJ
open -a docker
# Start MySQL and MailHog containers
docker-compose up -d
jenv global 17
# Run the Spring Boot application
./gradlew bootRun- Application: http://localhost:8080
- MailHog UI: http://localhost:8025 (for viewing emails)
- MySQL: localhost:3306
Key configuration options in application.properties:
# Database
spring.datasource.url=jdbc:mysql://localhost:3306/bjdb
# Email
mail.host=localhost
mail.port=1025
# reCAPTCHA
google.recaptcha.enabled=true
# Authentication
auth.register.auto-login=false
auth.login.remember-me-key=your-secret-key
# Token expiration
auth.activation-token.expires-after-minutes=60
auth.forgot-password-token.expires-after-minutes=30docker container rm -f $(docker container ls -aq)After registration, users need to confirm their email address before logging in (unless auto-login is enabled).
- Use MailHog UI (port 8025) to view all sent emails
- No real SMTP server required for development
- Minimum bet: $10
- Maximum bet: $1000
- Register a credit card before depositing funds
- Use test card numbers (follow Luhn algorithm)
- Passwords are BCrypt-encoded
- SQL injection prevention using JPA/Hibernate
- CSRF protection enabled
- XSS prevention through Thymeleaf auto-escaping
- Session fixation protection
- Secure remember-me token storage
Potential improvements:
- Multi-table Blackjack support
- Tournament mode
- Leaderboards and achievements
- Mobile-responsive design optimization
- WebSocket for real-time updates
- Caching for improved performance
- API documentation with Swagger/OpenAPI
- Unit and integration test coverage
This project is for educational purposes. Use responsibly.
This response is AI-generated and for reference purposes only.




