A web-based platform for playing Magic: The Gathering Commander games online with 4 players in real-time.
commander/
├── backend/ # Python FastAPI backend
├── frontend/ # React TypeScript frontend
├── docker-compose.yml # Local development services
└── README.md # This file
- Python 3.13 with uv package manager
- FastAPI - Modern web framework
- SQLAlchemy - Database ORM
- PostgreSQL - Primary database
- Redis - Caching and sessions
- python-socketio - Real-time communication
- Alembic - Database migrations
- React 19 with TypeScript
- Vite - Build tool
- React Router - Routing
- Zustand - State management
- Socket.IO Client - Real-time communication
- Python 3.13+
- uv (Python package manager)
- Docker and Docker Compose
- Node.js 18+ and npm
make dev-setup # Full setup (install deps + migrations)
make help # View all available commands
# Or individually:
make setup # Install all dependencies
make migrate # Run database migrations
make backend-dev # Start backend (terminal 1)
make frontend-dev # Start frontend (terminal 2)Start services:
- Docker:
docker compose up -d - Or local PostgreSQL + Redis
Run backend:
cd backend
cp .env.example .env
uv sync
uv run alembic upgrade head
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Run frontend:
cd frontend
npm install
npm run devThe application will be available at:
- Frontend:
http://localhost:5173 - Backend API:
http://localhost:8000 - API Docs:
http://localhost:8000/docs
curl -X POST http://localhost:8000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"username": "testuser",
"password": "SecurePassword123!"
}'Navigate to http://localhost:5173 and use the registration form.
curl -X POST http://localhost:8000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "SecurePassword123!"
}'This returns an access token and refresh token.
cd backend
uv run pytestcd frontend
npm run test # Watch mode
npm run test:run # Single run
npm run test:ui # UI modecd backend
# Create a new migration
uv run alembic revision --autogenerate -m "description"
# Apply migrations
uv run alembic upgrade head
# Rollback one migration
uv run alembic downgrade -1- ✅ Project setup with FastAPI, React, Socket.IO
- ✅ Card system with Scryfall API integration
- ✅ User authentication and deck management
- ✅ Basic game engine (turns, phases, zones)
- ✅ Game lobby
- ✅ Game board UI with drag-and-drop
- ✅ Card multi-selection drag-and-drop
- ✅ Game action logs
- ✅ Use socket.io for real-time game state synchronization during gameplay
- Stack/rearrange cards in battlefield
- Rearrange cards in hand
- Add counters to permanents
- Tokens creation
- Library management (shuffle, draw, mill, search, seek, reveal)
- ✅ Mana system
- ✅ Move validation
- ✅ Priority and turn/phases order system
- Combat system
- Stack system
- Targeting
- Complex abilities (keywords, activated/triggered)
- Commander damage rules
- AI opponent
- Games simulation for testing/balancing
- User profiles and stats
- Game replay
- Spectator mode
- Game chat and emotes
- Leaderboards
- Change card print (foil, alternate art, etc.)
See commander-roadmap.md for detailed milestones.
This project is for educational purposes only. Magic: The Gathering is property of Wizards of the Coast.