A real-time multiplayer guessing game where players compete to crack secret color patterns. Features mobile-optimized interface, WebSocket support, and production-ready WSGI deployment.
- Python 3.8+
- PDM (Python Dependency Manager) or pip
- Modern web browser with JavaScript enabled
-
Install PDM
# macOS/Linux curl -sSL https://pdm-project.org/install-pdm.py | python3 - # Windows PowerShell (Invoke-WebRequest -Uri https://pdm-project.org/install-pdm.py -UseBasicParsing).Content | python - # Or with pip pip install --user pdm
-
Clone and setup
git clone https://github.com/yourusername/guessingGame.git cd guessingGame/flask_game pdm install -
Generate secret key
pdm run python generate_key.py
-
Run the application
pdm run python app.py
-
Clone the repository
git clone https://github.com/yourusername/guessingGame.git cd guessingGame/flask_game -
Create virtual environment
python -m venv .venv source .venv/bin/activate # Linux/Mac # or .venv\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
-
Generate secret key
python generate_key.py
-
Run the application
python app.py
Open your browser and navigate to http://localhost:5000
- Enter your name - Remembered for future sessions
- Join or create a game - Public lobby or private invite codes
- Wait for players - Host can start with any number of participants
- Crack the pattern - 7 colors: Black, White, Yellow, Red, Green, Blue, Pink
- Use the feedback - ✓ for correct position, ○ for correct color/wrong position
- Win by speed - First to solve wins, others can keep playing
- Track your progress - Wins and losses saved automatically
- Responsive design optimized for iPhone 12 (390px) and similar devices
- 4-column color grid on mobile for easy touch interaction
- Touch-friendly buttons with minimum 44px height
- Reorganized layout with colors above game area on mobile
- Confirmation dialogs for critical actions like forfeit
The application includes production-ready WSGI deployment:
# Test WSGI setup
python flask_game/test_wsgi.py
# Deploy with Gunicorn
cd flask_game
gunicorn --worker-class eventlet -w 1 --bind 0.0.0.0:5000 wsgi:application
# Or use the provided script
chmod +x start_wsgi.sh
./start_wsgi.shPORT: Server port (default: 5000)DEBUG: Enable debug mode (default: false for production)SECRET_KEY: Flask session encryption (generated by generate_key.py)scpIP: IP and directory to throw this into with the deploy script
- Backend: Flask with SocketIO for real-time features
- Database: SQLite with SQLAlchemy ORM
- Frontend: Vanilla JavaScript with modern CSS Grid/Flexbox
- Design: Custom glassmorphism theme with CSS variables
- Architecture: Session-based authentication, RESTful routes
- Real-time: WebSocket support for live game updates
- Deployment: WSGI-compatible with Gunicorn + eventlet
guessingGame/
├── flask_game/
│ ├── app.py # Main Flask application
│ ├── wsgi.py # WSGI entry point for production
│ ├── models.py # Database models (Player, Game, Guess, etc.)
│ ├── templates/ # HTML templates with mobile-responsive design
│ │ ├── base.html # Base template with CSS framework
│ │ ├── lobby.html # Game browser and stats
│ │ ├── game.html # Main game interface (mobile-optimized)
│ │ ├── waiting_room.html # Game lobby with real-time updates
│ │ └── results.html # Game results and leaderboard
│ ├── instance/
│ │ └── game.db # SQLite database (auto-created)
│ ├── requirements.txt # Python dependencies
│ ├── requirements-wsgi.txt # Production WSGI dependencies
│ ├── generate_key.py # Secret key generator
│ ├── start_wsgi.sh # Production startup script
│ └── test_wsgi.py # WSGI configuration test
├── deploy.py # Deployment script
└── README.md
SECRET_KEY: Flask session encryption (generated by generate_key.py)PORT: Server port (default: 5000)DEBUG: Enable debug mode (default: true for development)FLASK_ENV: Environment mode (development/production)
- Max Players: 15 (configurable in models.py)
- Guess Timeout: 5 minutes per turn
- Game Cleanup: Inactive games removed after 15 minutes
- Session Duration: Player names remembered for 30 days
- Pattern Colors: 7 colors (Black, White, Yellow, Red, Green, Blue, Pink)
# With PDM
pdm run python app.py
# With pip/venv
source .venv/bin/activate
python app.pypython test_wsgi.py- Fork the repository
- Create a feature branch
- Make your changes
- Test on both desktop and mobile
- Submit a pull request
MIT License - see LICENSE file for details