A professional recreation of the popular online casino game "crash" with accurate casino odds. Built with modern web technologies and best practices.
- User Authentication - Secure login and registration system with password hashing
- Real-time Betting - Live betting system with instant updates via WebSocket
- Accurate Odds - Crash values generated using casino algorithms with a 3% house edge
- Live Bet Tracker - See all active bets and cashouts in real-time
- Game History - View the last 25 crash values with streak tracking
- Chat System - Real-time chat for logged-in users
- Live Visualization - Interactive line graph showing multiplier progression
- Auto Cashout - Set automatic payout multipliers for hands-free betting
- Professional Architecture - Modular, maintainable codebase with proper separation of concerns
- React.js - Modern UI framework
- Socket.io Client - Real-time communication
- Chart.js - Data visualization
- React Toastify - User notifications
- Axios - HTTP client
- Node.js - Runtime environment
- Express.js - Web framework and API
- Socket.io - Real-time bidirectional communication
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- Passport.js - Authentication middleware
- bcrypt.js - Password hashing
- Node.js (v14 or higher)
- MongoDB (v4 or higher)
- npm or yarn
git clone https://github.com/wbrandon25/Online-Crash-Gambling-Simulator
cd Crash-Gambling-Simulatorcd backend
# Install dependencies
npm install
# Create .env file and configure environment variables
# See backend/.env.example for referenceBackend Environment Variables:
MONGOOSE_DB_LINK=mongodb://localhost:27017/crash-game
PASSPORT_SECRET=your-secret-key-change-this-in-production
PORT=4000
SOCKET_PORT=3001
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000
GAME_LOOP_ID=62b7e66b1da7901bfc65df0dStart the backend server:
# Development mode (with nodemon)
npm start
# Production mode
NODE_ENV=production node server.jscd ../client
# Install dependencies
npm install
# Optional: Create .env file
# REACT_APP_API_BASE_URL=http://localhost:4000
# REACT_APP_SOCKET_URL=http://localhost:3001Start the frontend:
# Development mode
npm start
# Production build
npm run buildCrash-Gambling-Simulator/
├── backend/
│ ├── config/ # Configuration files
│ ├── controllers/ # Request handlers
│ ├── middleware/ # Express middleware
│ ├── models/ # MongoDB models
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ └── server.js # Server entry point
├── client/
│ ├── public/ # Static files
│ └── src/
│ ├── components/ # React components
│ ├── config/ # Configuration
│ ├── hooks/ # Custom React hooks
│ ├── services/ # API services
│ └── utils/ # Utility functions
└── README.md
- Start MongoDB on your local machine
- Start the backend server (runs on port 4000)
- Start the frontend client (runs on port 3000)
- Navigate to
http://localhost:3000 - Register a new account or login
- Start placing bets!
- Password hashing with bcrypt
- Session-based authentication
- Input validation and sanitization
- CORS configuration
- Error handling and logging
- Environment variable protection
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/user- Get current userGET /api/auth/logout- Logout user
POST /api/game/bet- Place a betGET /api/game/manual-cashout- Manual cashoutGET /api/game/auto-cashout- Auto cashoutGET /api/game/status- Get game statusPOST /api/game/chat- Send chat messageGET /api/game/chat- Get chat history
Note: Legacy endpoints are also supported for backward compatibility
This project has been refactored with professional best practices:
- ✅ Modular folder structure (routes, controllers, services, middleware)
- ✅ Proper error handling and logging
- ✅ Input validation and sanitization
- ✅ Environment configuration management
- ✅ Security improvements (CORS, session management)
- ✅ JSDoc documentation
- ✅ Graceful shutdown handling
- ✅ Component-based architecture
- ✅ Custom React hooks for reusable logic
- ✅ API service layer
- ✅ Error boundaries
- ✅ Loading states
- ✅ Improved error handling
- ✅ PropTypes validation
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License.
This is a simulation for educational purposes only. Gambling can be addictive. Please gamble responsibly.
| Platform | Link |
|---|---|
| 📱 Telegram | t.me/novustch |
| wa.me/14105015750 | |
| 💬 Discord | discordapp.com/users/985432160498491473 |
Feel free to reach out for implementation assistance or integration support.
