Skip to content

Novus-Tech-LLC/Crash-Gambling-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crash Gambling Simulator

A professional recreation of the popular online casino game "crash" with accurate casino odds. Built with modern web technologies and best practices.

showcase

🚀 Features

  • 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

🛠️ Technologies

Frontend

  • React.js - Modern UI framework
  • Socket.io Client - Real-time communication
  • Chart.js - Data visualization
  • React Toastify - User notifications
  • Axios - HTTP client

Backend

  • 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

📋 Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (v4 or higher)
  • npm or yarn

🔧 Installation

1. Clone the repository

git clone https://github.com/wbrandon25/Online-Crash-Gambling-Simulator
cd Crash-Gambling-Simulator

2. Backend Setup

cd backend

# Install dependencies
npm install

# Create .env file and configure environment variables
# See backend/.env.example for reference

Backend 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=62b7e66b1da7901bfc65df0d

Start the backend server:

# Development mode (with nodemon)
npm start

# Production mode
NODE_ENV=production node server.js

3. Frontend Setup

cd ../client

# Install dependencies
npm install

# Optional: Create .env file
# REACT_APP_API_BASE_URL=http://localhost:4000
# REACT_APP_SOCKET_URL=http://localhost:3001

Start the frontend:

# Development mode
npm start

# Production build
npm run build

📁 Project Structure

Crash-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

🎮 Usage

  1. Start MongoDB on your local machine
  2. Start the backend server (runs on port 4000)
  3. Start the frontend client (runs on port 3000)
  4. Navigate to http://localhost:3000
  5. Register a new account or login
  6. Start placing bets!

🔒 Security Features

  • Password hashing with bcrypt
  • Session-based authentication
  • Input validation and sanitization
  • CORS configuration
  • Error handling and logging
  • Environment variable protection

📝 API Documentation

Authentication Endpoints

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/user - Get current user
  • GET /api/auth/logout - Logout user

Game Endpoints

  • POST /api/game/bet - Place a bet
  • GET /api/game/manual-cashout - Manual cashout
  • GET /api/game/auto-cashout - Auto cashout
  • GET /api/game/status - Get game status
  • POST /api/game/chat - Send chat message
  • GET /api/game/chat - Get chat history

Note: Legacy endpoints are also supported for backward compatibility

🏗️ Architecture Improvements

This project has been refactored with professional best practices:

Backend

  • ✅ 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

Frontend

  • ✅ Component-based architecture
  • ✅ Custom React hooks for reusable logic
  • ✅ API service layer
  • ✅ Error boundaries
  • ✅ Loading states
  • ✅ Improved error handling
  • ✅ PropTypes validation

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the ISC License.

⚠️ Disclaimer

This is a simulation for educational purposes only. Gambling can be addictive. Please gamble responsibly.

👋 Contact

Platform Link
📱 Telegram t.me/novustch
📲 WhatsApp wa.me/14105015750
💬 Discord discordapp.com/users/985432160498491473
Telegram WhatsApp Discord

Feel free to reach out for implementation assistance or integration support.