strat-gameplay-webapp/QUICKSTART.md
Cal Corum fc7f53adf3 CLAUDE: Complete Phase 1 backend infrastructure setup
Implemented full FastAPI backend with WebSocket support, database models,
and comprehensive documentation for the Paper Dynasty game engine.

Backend Implementation:
- FastAPI application with Socket.io WebSocket server
- SQLAlchemy async database models (Game, Play, Lineup, GameSession)
- PostgreSQL connection to dev server (10.10.0.42:5432)
- Connection manager for WebSocket lifecycle
- JWT authentication utilities
- Health check and stub API endpoints
- Rotating file logger with Pendulum datetime handling
- Redis via Docker Compose for caching

Technical Details:
- Python 3.13 with updated package versions
- Pendulum 3.0 for all datetime operations
- Greenlet for SQLAlchemy async support
- Fixed SQLAlchemy reserved column names (metadata -> *_metadata)
- Pydantic Settings with JSON array format for lists
- Docker Compose V2 commands

Documentation:
- Updated backend/CLAUDE.md with environment-specific details
- Created .claude/ENVIRONMENT.md for gotchas and quirks
- Created QUICKSTART.md for developer onboarding
- Documented all critical learnings and troubleshooting steps

Database:
- Tables created: games, plays, lineups, game_sessions
- All indexes and foreign keys configured
- Successfully tested connection and health checks

Verified:
- Server starts at http://localhost:8000
- Health endpoints responding
- Database connection working
- WebSocket infrastructure functional
- Hot-reload working

🎯 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 19:46:16 -05:00

208 lines
4.2 KiB
Markdown

# Paper Dynasty - Quick Start Guide
**Last Updated**: 2025-10-21
## Prerequisites
- Python 3.13+
- Node.js 18+ (for frontends)
- Docker with Compose V2
- Access to PostgreSQL server (10.10.0.42:5432)
- Git
## Initial Setup (One-Time)
### 1. Clone and Navigate
```bash
cd /mnt/NV2/Development/strat-gameplay-webapp
```
### 2. Backend Setup
```bash
cd backend
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements-dev.txt
# Configure environment
cp .env.example .env
# Edit .env and set DATABASE_URL password
# Start Redis
docker compose up -d
# Verify setup
python -m app.main
# Server should start at http://localhost:8000
```
### 3. Database Setup (If Not Already Created)
Connect to your PostgreSQL server via Adminer or psql and run:
```sql
CREATE DATABASE paperdynasty_dev;
CREATE USER paperdynasty WITH PASSWORD 'your-secure-password';
GRANT ALL PRIVILEGES ON DATABASE paperdynasty_dev TO paperdynasty;
-- Connect to paperdynasty_dev
\c paperdynasty_dev
GRANT ALL ON SCHEMA public TO paperdynasty;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO paperdynasty;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO paperdynasty;
```
## Daily Development
### Starting the Backend
```bash
# Terminal 1: Start Redis (if not running)
cd backend
docker compose up -d
# Terminal 2: Run Backend
cd backend
source venv/bin/activate
python -m app.main
```
Backend will be available at:
- Main API: http://localhost:8000
- Swagger UI: http://localhost:8000/docs
- Health Check: http://localhost:8000/api/health
### Starting Frontends (When Available)
```bash
# Terminal 3: SBA League Frontend
cd frontend-sba
npm run dev
# Available at http://localhost:3000
# Terminal 4: PD League Frontend
cd frontend-pd
npm run dev
# Available at http://localhost:3001
```
## Useful Commands
### Backend
```bash
# Run tests
cd backend
source venv/bin/activate
pytest tests/ -v
# Format code
black app/ tests/
# Type checking
mypy app/
# Check logs
tail -f backend/logs/app_*.log
```
### Docker
```bash
# Check running containers
docker ps
# View Redis logs
cd backend
docker compose logs redis
# Stop Redis
docker compose down
```
### Database
```bash
# Connect to database
psql postgresql://paperdynasty:PASSWORD@10.10.0.42:5432/paperdynasty_dev
# Or use Adminer web interface
# (Running on same Docker host as PostgreSQL)
```
## Troubleshooting
### "docker-compose: command not found"
Use `docker compose` (with space) not `docker-compose`
### "greenlet library required"
```bash
pip install greenlet
```
### Import errors / Module not found
Ensure virtual environment is activated:
```bash
source venv/bin/activate
which python # Should show path to venv/bin/python
```
### Database connection errors
1. Check .env has correct DATABASE_URL with password
2. Verify database exists: `psql -h 10.10.0.42 -U paperdynasty -d paperdynasty_dev`
3. Ping database server: `ping 10.10.0.42`
### Server won't start
1. Check CORS_ORIGINS format in .env: `CORS_ORIGINS=["url1", "url2"]`
2. Ensure Redis is running: `docker ps | grep redis`
3. Check logs: `tail -f backend/logs/app_*.log`
## Project Status
**Phase 1: Core Infrastructure** - COMPLETE (2025-10-21)
- Backend FastAPI server running
- PostgreSQL database configured
- WebSocket support (Socket.io)
- Health check endpoints
- JWT authentication stubs
- Redis for caching
🚧 **Next Steps**:
- Discord OAuth integration
- Frontend setup (Nuxt 3)
- Phase 2: Game Engine Core
## Key Files
- **Backend Config**: `backend/.env`
- **Backend Code**: `backend/app/`
- **Database Models**: `backend/app/models/db_models.py`
- **API Routes**: `backend/app/api/routes/`
- **WebSocket**: `backend/app/websocket/`
- **Logs**: `backend/logs/`
## Documentation
- **Main README**: `README.md`
- **Backend Details**: `backend/CLAUDE.md`
- **Environment Notes**: `.claude/ENVIRONMENT.md`
- **Implementation Plan**: `.claude/implementation/01-infrastructure.md`
- **Full PRD**: `prd-web-scorecard-1.1.md`
## Support
For issues or questions:
1. Check `backend/CLAUDE.md` for backend-specific details
2. Check `.claude/ENVIRONMENT.md` for gotchas and environment quirks
3. Review implementation plans in `.claude/implementation/`
---
**Happy Coding! ⚾**