Play, bet, and spin - AI-assisted roulette in your browser.
A sophisticated, interactive multiplayer roulette game featuring AI assistance, voice commands, and real-time gameplay. This project demonstrates full-stack development skills, system architecture design, and creative UX implementation.
This take-home project showcases:
- Full-Stack Architecture: React TypeScript frontend with FastAPI Python backend
- Interactive Gameplay: Multi-input betting system (mouse, keyboard, voice)
- AI Integration: Dual-layer AI system with OpenAI + backup parser
- Real-Time Features: Live multiplayer lobbies and game state synchronization
- Data Persistence: Comprehensive user/game data storage with Supabase
- Modern UX: Optimistic UI updates with backend verification
- ๐ฎ Interactive Roulette Table: Click to place bets on numbers, colors, and groups
- ๐ค Voice Betting: Use natural language commands like "bet 10 on red"
- ๐ค AI Assistant: Get help with rules, strategies, and automated bet parsing
- ๐ Real-time Analytics: Hot/cold numbers, recent spins, and leaderboards (Future)
- ๐ฅ Multiplayer: Join lobbies with other players (Future)
- ๐ฐ Balance Tracking: Start with $100, win or lose based on your bets
- ๐ Backup Systems: Fallback parsers ensure functionality without external APIs
- React 18 with TypeScript
- Vite for fast development
- Tailwind CSS for styling
- Zustand for state management
- Supabase for authentication
- Web Speech API for voice input
- FastAPI with Python
- Supabase (PostgreSQL + Auth)
- WebSockets for real-time updates
- OpenAI API (optional, with backup parser)
- Pydantic for data validation
- Frontend: Firebase/Netlify/Vercel
- Backend: Railway/Render
- Database: Supabase
- Node.js 18+
- Python 3.8+
- Supabase account (free tier works)
git clone https://github.com/yourusername/Ai-Roulette.git
cd Ai-Roulette- Create a new Supabase project at supabase.com
- Go to SQL Editor and run the schema from
docs/corrected-database-schema.sql - Note your project URL and anon key from Settings > API
cd backend
pip install -r requirements.txt
# Create environment file
echo "SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
OPENAI_API_KEY=your_openai_api_key" > .env
# Start the server
python main.pycd frontend
npm install
# Create environment file
echo "VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
VITE_API_URL=http://localhost:8000" > .env.local
# Start the development server
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
Backend (.env)
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
OPENAI_API_KEY=your_openai_api_key # OptionalFrontend (.env.local)
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
VITE_API_URL=http://localhost:8000- Straight (Single Number): 35:1
- Red/Black: 1:1
- Even/Odd: 1:1
- Low (1-18) / High (19-36): 1:1
- Dozens/Columns: 2:1
- Split (2 numbers): 17:1
- Street (3 numbers): 11:1
- Corner (4 numbers): 8:1
- Line (6 numbers): 5:1
- "Bet 10 on red"
- "Place 5 on black"
- "Put 25 on number 7"
- "Bet 15 on even"
Ask about rules, strategies, or get help with betting. The AI can also parse natural language betting commands automatically.
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ React Client โโโโโบโ FastAPI Server โโโโโบโ Supabase DB โ
โ (Frontend) โ โ (Backend) โ โ (PostgreSQL) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Web Speech API โ โ OpenAI API โ โ Auth Service โ
โ (Voice Commands)โ โ (AI Assistant) โ โ (JWT Tokens) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
Ai-Roulette/
โโโ frontend/ # React TypeScript app
โ โโโ src/
โ โ โโโ components/ # Reusable UI components
โ โ โโโ contexts/ # React state management
โ โ โโโ hooks/ # Custom React hooks
โ โ โโโ assets/ # Static assets
โ โ โโโ App.tsx # Main application
โ โโโ package.json # Dependencies & scripts
โ โโโ vite.config.ts # Build configuration
โโโ backend/ # FastAPI Python server
โ โโโ models/ # Pydantic data models
โ โ โโโ game.py # Game state models
โ โโโ services/ # Business logic layer
โ โ โโโ ai_service.py # AI integration
โ โ โโโ auth_service.py # Authentication
โ โ โโโ database.py # Database operations
โ โโโ utils/ # Utility functions
โ โ โโโ websocket_manager.py # Real-time updates
โ โโโ main.py # FastAPI application
โ โโโ requirements.txt # Python dependencies
โโโ docs/ # Project documentation
โ โโโ corrected-database-schema.sql # Database setup
โ โโโ AI-INTEGRATION.md # AI system documentation
โ โโโ SETUP.md # Detailed setup guide
โโโ README.md # This file
Frontend Architecture:
- Optimistic UI Updates: Immediate visual feedback with backend verification
- Context-based State: React contexts for game state, auth, and player data
- Component Composition: Modular, reusable components for maintainability
- TypeScript: Full type safety across the application
Backend Architecture:
- Service Layer Pattern: Separation of concerns with dedicated service classes
- Dual AI System: Primary OpenAI integration with JavaScript/TypeScript backup parser
- Database-First: Supabase as single source of truth for all game data
- RESTful API: Clear endpoint structure with automatic OpenAPI documentation
- Row Level Security (RLS) in Supabase
- JWT authentication
- Input validation and sanitization
- Rate limiting on API endpoints
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.