A full-stack iGaming platform built with React + TypeScript frontend and Spring Boot backend, featuring JWT authentication, PostgreSQL database, and WebSocket live chat.
- Multiple Casino Games: Slots, Roulette, Blackjack, and Dice
- User Authentication: JWT-based authentication system
- Real-time Chat: WebSocket-powered live chat
- Game History: Track all your gaming sessions
- Balance Management: Virtual currency system (demo mode)
- Responsive Design: Modern UI with Tailwind CSS and animations
- React 18 with TypeScript
- Vite for build tooling
- Tailwind CSS for styling
- Radix UI components
- Framer Motion for animations
- WebSocket for real-time chat
- Spring Boot 3.2 with Java 17
- Spring Security with JWT authentication
- Spring Data JPA for database operations
- PostgreSQL database
- WebSocket for real-time communication
- Docker and Docker Compose for containerization
- Maven for Java dependency management
- npm for Node.js dependencies
- Docker and Docker Compose
- Java 17+ (for local development)
- Node.js 20+ and npm (for local development)
- Maven 3.9+ (for local development)
-
Clone and navigate to the project:
cd NexusCasino -
Create environment file (optional):
cp .env.example .env # Edit .env with your preferred settings -
Start all services:
docker-compose up -d
-
Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8080/api
- PostgreSQL: localhost:5432
-
Stop services:
docker-compose down
-
Navigate to backend directory:
cd backend -
Configure database in
src/main/resources/application.yml:spring: datasource: url: jdbc:postgresql://localhost:5432/nexus_casino username: casino_user password: casino_pass
-
Start PostgreSQL (or use Docker):
docker run -d --name postgres -e POSTGRES_DB=nexus_casino -e POSTGRES_USER=casino_user -e POSTGRES_PASSWORD=casino_pass -p 5432:5432 postgres:15-alpine
-
Build and run:
mvn clean install mvn spring-boot:run
Backend will run on http://localhost:8080
-
Navigate to frontend directory:
cd frontend -
Install dependencies:
npm install
-
Create
.envfile:VITE_API_BASE_URL=http://localhost:8080/api VITE_WS_URL=ws://localhost:8080/ws
-
Start development server:
npm run dev
Frontend will run on http://localhost:5173
NexusCasino/
├── frontend/ # React + TypeScript frontend
│ ├── src/
│ │ ├── app/ # Main app components
│ │ ├── components/ # Reusable components
│ │ │ ├── chat/ # Live chat component
│ │ │ └── ui/ # UI components (Radix UI)
│ │ └── lib/ # Utilities and API client
│ ├── package.json
│ ├── tsconfig.json
│ └── Dockerfile
│
├── backend/ # Spring Boot backend
│ ├── src/main/java/com/nexus/casino/
│ │ ├── config/ # Configuration classes
│ │ ├── controller/ # REST controllers
│ │ ├── dto/ # Data Transfer Objects
│ │ ├── entity/ # JPA entities
│ │ ├── repository/ # JPA repositories
│ │ ├── security/ # JWT security
│ │ ├── service/ # Business logic
│ │ └── websocket/ # WebSocket handlers
│ ├── src/main/resources/
│ │ └── application.yml # Application configuration
│ ├── pom.xml
│ └── Dockerfile
│
├── docker-compose.yml # Docker Compose configuration
└── README.md
POST /api/auth/register- Register new user{ "username": "player1", "email": "player@example.com", "password": "password123" }POST /api/auth/login- Login user{ "email": "player@example.com", "password": "password123" }GET /api/auth/me- Get current user (requires JWT token)POST /api/auth/password-reset/request- Request password resetPOST /api/auth/password-reset/confirm- Confirm password reset with token
POST /api/games/play- Play a game (requires auth){ "gameType": "slots", "bet": 10.00 }GET /api/games/history- Get game history (requires auth)DELETE /api/games/history- Clear game history (requires auth)
GET /api/users/balance- Get user balance (requires auth)PUT /api/users/balance- Update balance (requires auth){ "amount": 500.00 }POST /api/users/balance/reset- Reset balance to $1000 (requires auth)
- Connect to:
ws://localhost:8080/ws?token=<JWT_TOKEN> - Send messages:
{ "type": "CHAT_MESSAGE", "payload": { "message": "Hello everyone!" } }
The application runs in demo mode by default. Users start with $1000 virtual currency.
- Register a new account or login
- JWT token is stored in localStorage
- Token is automatically included in API requests
- WebSocket connection uses token for authentication
- Use "Forgot Password" to reset your password if needed
- Select a game from the tabs (Slots, Roulette, Blackjack, Dice)
- Set your bet amount
- Play the game
- Results are saved to your game history
- Balance is updated automatically
- Use "Reset" button to reset balance to $1000 (clears game history)
- Click the chat button (bottom right)
- Messages are broadcast to all connected users
- System messages notify when users join/leave
- Chat window appears above all other content
- JWT tokens with configurable expiration
- Password encryption using BCrypt
- CORS configuration for frontend access
- WebSocket authentication via JWT token
- SQL injection protection via JPA
Create a .env file in the root directory:
# Database
DB_NAME=nexus_casino
DB_USER=casino_user
DB_PASSWORD=casino_pass
# JWT
JWT_SECRET=your-256-bit-secret-key-change-this-in-production-minimum-32-characters
JWT_EXPIRATION=86400000
# CORS
CORS_ORIGINS=http://localhost:5173,http://localhost:3000
# Frontend
VITE_API_BASE_URL=http://localhost:8080/api
VITE_WS_URL=ws://localhost:8080/ws- Check PostgreSQL is running
- Verify database credentials in
application.yml - Check port 8080 is not in use
- View logs:
docker-compose logs backend
- Verify
VITE_API_BASE_URLin.envor environment variables - Check CORS configuration in backend
- Ensure backend is running on port 8080
- Check browser console for errors
- Verify JWT token is valid
- Check
VITE_WS_URLin environment variables - Ensure WebSocket handler is configured correctly
- Check backend logs for WebSocket errors
- Verify PostgreSQL is running:
docker-compose ps - Check connection string in
application.yml - Ensure database exists
- View database logs:
docker-compose logs postgres
- Check backend logs for authentication errors
- Verify JWT secret is set in environment variables
- Ensure password meets requirements (min 6 characters)
- Check email format is valid
- Backend uses Spring Boot 3.2 with Java 17
- Frontend uses React 18 with TypeScript strict mode
- Database schema is auto-generated via JPA
- All game logic is server-side for security
- WebSocket reconnects automatically on disconnect
- Password reset tokens expire after 1 hour
- Currency values are formatted to 2 decimal places
Testing setup is skipped for now (as per requirements). To add testing later:
- Backend: JUnit 5 + Mockito
- Frontend: Vitest + React Testing Library
- E2E: Playwright or Cypress
This is a demo project for educational purposes.
This is a private project. For questions or issues, please contact the development team.