3.6 KiB
3.6 KiB
MTG Online Backend - Context for Continuation
Current State
I just completed fixing 10 issues with the MTG Online backend codebase. All fixes are in place but have not yet been deployed or tested.
What Was Fixed
Files Modified/Created:
app/routers/interactions.py- NEW - Comprehensive interaction search endpointsapp/main.py- REWRITTEN - Fixed router mounting and loggingapp/routers/__init__.py- REWRITTEN - Added all router exportsDockerfile- REWRITTEN - Added scripts directory and permissions
Key Changes:
- All 8 routers now properly mounted in FastAPI
- Interaction endpoints: synergies, counters, evolutions, recommendations, search, stats
- Verbose logging with debug support
- Consistent async database usage
- Redis caching for performance
- Proper error handling throughout
Next Steps - Execute These Commands
Step 1: Stop all containers
cd /home/wall-o/projects/mtgonline
docker compose down -v
Step 2: Build the backend
cd /home/wall-o/projects/mtgonline
docker compose build backend
Step 3: Deploy the stack
cd /home/wall-o/projects/mtgonline
docker compose up -d
Step 4: Wait for containers to start
# Watch logs in real-time
docker compose logs -f backend
Step 5: Verify health
# Check all containers
docker compose ps
# Test health endpoint
curl -s http://localhost:5555/health | python -m json.tool
# Check API docs are accessible
curl -s http://localhost:5555/docs | head -20
Step 6: Verify interaction endpoints
# List all registered routes
curl -s http://localhost:5555/openapi.json | python -m json.tool | grep -E '"path":|"/(interactions|cards|auth|users|decks|rooms|games|admin)"'
# Test interaction search endpoint
curl -s "http://localhost:5555/interactions/search/synergies?limit=5" | python -m json.tool
Expected Success Indicators
- All containers show
healthystatus /healthreturns{"status": "healthy", "version": "0.2.0"}/docsreturns OpenAPI JSON- All routers appear in
/openapi.json - No Python import errors in logs
- Database connections successful
- Redis connection successful
Troubleshooting
If container fails to start:
# Check exit codes
docker compose ps
# View recent logs
docker compose logs --tail=100 backend
# Check if port 5555 is in use
sudo lsof -i :5555
Common Issues:
- Import errors: Check that all router files exist and have proper syntax
- Database connection: Verify
.envhas correct database URLs - Port conflicts: Ensure no other service uses port 5555
- Permission issues: Dockerfile should run as
appusernot root
To view database state:
# Connect to card database
docker exec -it mtgonline_db_card psql -U mtgonline -d mtgdata -c "\dt"
# Check tables
docker exec -it mtgonline_db_card psql -U mtgonline -d mtgdata -c "SELECT count(*) FROM mtg_cards;"
Important Context
- Backend port: 5555 (not 8000!)
- Two PostgreSQL containers:
mtgdataandusers - Redis for caching
- All code runs as
wall-ouser (UID 1001) - Python venv at
/home/wall-o/workspace/venv
Files to Review if Issues Arise
/home/wall-o/projects/mtgonline/backend/app/main.py- Router mounting/home/wall-o/projects/mtgonline/backend/app/routers/interactions.py- New endpoints/home/wall-o/projects/mtgonline/backend/app/routers/__init__.py- Exports/home/wall-o/projects/mtgonline/backend/Dockerfile- Container setup/home/wall-o/projects/mtgonline/.env- Configuration/home/wall-o/projects/mtgonline/docker-compose.yml- Stack definition