https://github.com/jerynmathew/thurup
Real-time multiplayer web implementation of the 28/56 card game with WebSocket support, bot players, and team-based scoring
https://github.com/jerynmathew/thurup
fastapi python react vitejs websockets
Last synced: about 2 months ago
JSON representation
Real-time multiplayer web implementation of the 28/56 card game with WebSocket support, bot players, and team-based scoring
- Host: GitHub
- URL: https://github.com/jerynmathew/thurup
- Owner: jerynmathew
- License: mit
- Created: 2025-10-22T10:25:30.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-10-22T12:52:30.000Z (8 months ago)
- Last Synced: 2025-10-22T13:10:00.010Z (8 months ago)
- Topics: fastapi, python, react, vitejs, websockets
- Language: Python
- Homepage:
- Size: 511 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Thurup - 28/56 Card Game
A modern, real-time multiplayer implementation of the classic 28/56 card game.
## ๐ฎ Features
- **Real-time Multiplayer**: Play with friends via WebSocket connections
- **Bot AI**: Add computer opponents with configurable difficulty
- **Game History**: Review past games with complete replay functionality
- **Admin Dashboard**: Monitor server health and manage active games
- **Persistent State**: Automatic game state saving and recovery
- **Modern UI**: Beautiful, responsive interface built with React and TailwindCSS
## ๐ Quick Start
**New to Thurup?** Follow the [Quickstart Guide](./docs/getting-started/QUICKSTART.md) to get running in 5 minutes.
**Detailed setup?** See the [Installation Guide](./docs/getting-started/INSTALLATION.md).
### Quick Commands
**Backend:**
```bash
cd backend
uv sync # Install dependencies
uv run alembic upgrade head # Run migrations
uv run uvicorn app.main:app --reload --port 18081
```
**Frontend:**
```bash
cd frontend
npm install # Install dependencies
npm run dev # Start dev server
```
**Access the app**: http://localhost:5173
## ๐ Documentation
Complete documentation is organized in the [`docs/`](./docs/) folder:
### Getting Started
- **[Quickstart Guide](./docs/getting-started/QUICKSTART.md)** - Get up and running in 5 minutes
- **[Installation Guide](./docs/getting-started/INSTALLATION.md)** - Comprehensive setup instructions
- **[Deployment Guide](./docs/getting-started/DEPLOYMENT.md)** - Production deployment strategies
### Development
- **[Developer Guide](./docs/development/DEVELOPER_GUIDE.md)** - Development workflow and best practices
- **[Architecture](./docs/development/ARCHITECTURE.md)** - System design and structure
- **[API Reference](./docs/development/API_REFERENCE.md)** - Complete backend API documentation
- **[Contributing](./docs/development/CONTRIBUTING.md)** - How to contribute to the project
### Testing
- **[Testing Guide](./docs/testing/TESTING_GUIDE.md)** - Comprehensive testing documentation
- **[Running Tests](./docs/testing/RUNNING_TESTS.md)** - Quick command reference
### Planning & Implementation
- **[Requirements](./docs/planning/REQUIREMENTS.md)** - Feature requirements and specifications
- **[Roadmap](./docs/planning/ROADMAP.md)** - Development roadmap and milestones
- **[Technical Debt](./docs/planning/TECHNICAL_DEBT_TODO.md)** - Known issues and improvements
- **[Known Bugs](./docs/planning/KNOWN_BUGS.md)** - Bug tracking and status
- **[Technical Review](./docs/planning/TECHNICAL_REVIEW.md)** - Code review and priorities
- **[Round History Implementation](./docs/implementation/ROUND_HISTORY_IMPLEMENTATION.md)** - Game history system
### Component Logs (for Claude Code)
- **[backend/CLAUDE.md](./backend/CLAUDE.md)** - Backend development log with technical details
- **[frontend/CLAUDE.md](./frontend/CLAUDE.md)** - Frontend development log with UI/UX changes
## ๐๏ธ Project Structure
```
thurup/
โโโ backend/ # FastAPI backend with WebSocket support
โ โโโ app/
โ โ โโโ api/v1/ # Modular API endpoints
โ โ โ โโโ router.py # Main router and shared state
โ โ โ โโโ rest.py # REST endpoints
โ โ โ โโโ websocket.py # WebSocket handler
โ โ โ โโโ broadcast.py # State broadcasting
โ โ โ โโโ bot_runner.py # Bot AI orchestration
โ โ โ โโโ connection_manager.py # WebSocket connections
โ โ โ โโโ persistence_integration.py # Database integration
โ โ โ โโโ history.py # Game history endpoints
โ โ โ โโโ admin.py # Admin endpoints
โ โ โโโ game/ # Game logic and state management
โ โ โโโ db/ # Database models and persistence
โ โโโ tests/ # Unit, integration, and E2E tests
โ โโโ alembic/ # Database migrations
โ
โโโ frontend/ # React + TypeScript frontend
โ โโโ src/
โ โ โโโ api/ # API service layer
โ โ โโโ components/ # React components
โ โ โโโ pages/ # Page components
โ โ โโโ stores/ # Zustand state management
โ โ โโโ types/ # TypeScript type definitions
โ โโโ tests/e2e/ # Playwright E2E tests
โ
โโโ docs/ # Organized documentation
โ โโโ getting-started/ # Setup and installation
โ โโโ development/ # Architecture, API, contributing
โ โโโ testing/ # Testing strategies
โ โโโ planning/ # Roadmap, requirements, technical debt
โ โโโ implementation/ # Feature implementation guides
โ
โโโ docker-compose.yml # Container orchestration
```
## ๐ Development Status
**Backend**: โ
Complete (331 tests, 76% coverage)
- Core game logic and rules
- Database persistence with SQLite + Alembic
- REST API and WebSocket communication
- Admin endpoints with authentication
- Round history and replay system
- Comprehensive testing
**Frontend**: โ
Production Ready (253 tests, 26.8% coverage)
- โ
Project setup and infrastructure
- โ
Type system and state management
- โ
API integration layer
- โ
Complete UI component library
- โ
Game board and gameplay UI (fully responsive)
- โ
Real-time WebSocket communication
- โ
Session persistence and recovery
- โ
Game history and replay viewer
- โ
Admin dashboard
- โ
E2E testing with Playwright (13 scenarios, 77% pass rate)
## ๐งช Testing
**Backend:**
```bash
cd backend
uv run pytest # All tests (331 tests)
uv run pytest tests/unit/ # Unit tests (32 tests)
uv run pytest tests/integration/ # Integration tests (24 tests)
uv run pytest --cov=app # With coverage report
```
**Frontend:**
```bash
cd frontend
npm test # Unit/component tests (253 tests)
npm run test:coverage # With coverage report
npm run test:e2e # E2E tests (requires backend running)
npm run test:e2e:ui # E2E in interactive mode
```
See [Running Tests](./docs/testing/RUNNING_TESTS.md) for more commands.
## ๐ฏ Game Rules
Thurup is a trick-taking card game for 4-6 players:
- **28 Mode**: 32 cards (7-A), 4 players, 2 teams
- **56 Mode**: 64 cards (2 decks), 4-6 players, 2-3 teams
- Bidding phase to determine trump suit
- Trick-taking with trump and suit following rules
- Points awarded based on card values and tricks won
See [Requirements](./docs/planning/REQUIREMENTS.md) for detailed game rules.
## ๐ค Contributing
We welcome contributions! Here's how to get started:
1. Review the [Architecture](./docs/development/ARCHITECTURE.md) to understand the system design
2. Check [Contributing Guide](./docs/development/CONTRIBUTING.md) for guidelines
3. Follow [Developer Guide](./docs/development/DEVELOPER_GUIDE.md) for setup instructions
4. Add tests for new features
5. Update documentation as needed
See [Contributing Guide](./docs/development/CONTRIBUTING.md) for detailed contribution guidelines.
## ๐ License
[Add your license here]
## ๐ Acknowledgments
Built with modern technologies:
- [FastAPI](https://fastapi.tiangolo.com/) - Backend framework
- [React](https://react.dev/) - Frontend framework
- [SQLModel](https://sqlmodel.tiangolo.com/) - Database ORM
- [Zustand](https://zustand-demo.pmnd.rs/) - State management
- [TailwindCSS](https://tailwindcss.com/) - Styling
- [Playwright](https://playwright.dev/) - E2E testing
---
**Last Updated**: 2025-10-22
**Status**: Production Ready
**Version**: 0.2.0
## ๐ Recent Changes
### 2025-10-22: Documentation Reorganization
- โ
Restructured all documentation into organized subdirectories
- โ
Eliminated duplicate documentation (6 files merged)
- โ
Created comprehensive guides: Quickstart, Installation, Contributing
- โ
Added quick reference for running tests
- โ
Updated navigation with task-based "I want to..." guide
- โ
Single source of truth for all documentation topics
### Week 7: Critical Bug Fixes (2025-10-15)
- โ
Fixed multiplayer hand visibility (WebSocket re-identification)
- โ
Fixed dealer rotation to follow official 28 rules
- โ
Improved trick card display with actual card images
- โ
Enhanced visual spacing and layout
### Week 6: Round History Persistence (2025-10-14)
- โ
Implemented comprehensive round history database persistence
- โ
Created admin game history browser with round-by-round playback
- โ
Fixed player name persistence bug
- โ
Added "Start Next Round" button for multi-round gameplay
- โ
Enhanced admin panel with short code display
### Week 5: Session Management & Visual Enhancements (2025-10-13)
- โ
Frontend LocalStorage persistence for player sessions
- โ
Modal-based join flow consistent across all entry points
- โ
Page refresh recovery with automatic session restoration
- โ
WebSocket short code resolution bug fix (critical)
- โ
Playing card images from Deck of Cards API
- โ
Responsive GameBoard layout with percentage-based positioning
- โ
Team-based scoring display with bid targets
- โ
Lead suit indicator and last trick display
- โ
Context-aware trump reveal feedback
---
For detailed technical documentation and development logs, see:
- [Backend Development Log](./backend/CLAUDE.md)
- [Frontend Development Log](./frontend/CLAUDE.md)
- [Documentation Hub](./docs/README.md)