docs: update HANDOFF.md and ROADMAP.md with user data schema progress
- Handoff.md: document 16-table user data schema, Alembic migrations, and all API endpoints (replays, cards, groups, networks, preferences, activity) - Handoff.md: consolidate state.json reference to project root - Roadmap.md: restructure phases to reflect completed work Phase 1: Backend Foundation (complete) Phase 2: User Data Schema & API (complete) - 16 tables, 7 routers Phase 3: Frontend Development (complete) Phase 4: Testing & Deployment (pending)
This commit is contained in:
+106
-44
@@ -52,9 +52,11 @@ To build a fully-featured, open-source multiplayer Magic: The Gathering platform
|
||||
|
||||
All planned tasks have been completed:
|
||||
- ✅ Documentation created (root README.md + backend/README.md)
|
||||
- ✅ State.json updated
|
||||
- ✅ Commit pushed to Gitea (commit `46abfe5`)
|
||||
- ✅ State.json consolidated to project root
|
||||
- ✅ Commit pushed to Gitea (commit `c42d7ca`)
|
||||
- ✅ Docker cleanup completed (all containers, images, volumes removed)
|
||||
- ✅ **User data schema implemented** (16 tables with Alembic migrations)
|
||||
- ✅ **Comprehensive API endpoints created** (7 routers covering all user data features)
|
||||
|
||||
## Architecture Summary
|
||||
|
||||
@@ -72,13 +74,19 @@ mtgonline/
|
||||
├── backend/ # FastAPI application
|
||||
│ ├── app/
|
||||
│ │ ├── core/ # Settings, database engines, Redis client
|
||||
│ │ ├── models/ # SQLAlchemy ORM models
|
||||
│ │ ├── models/ # SQLAlchemy ORM models (user_data.py - 16 models)
|
||||
│ │ ├── routers/ # API route modules (auth, users, decks, rooms, games, admin, cards, interactions, refresh, ws)
|
||||
│ │ ├── schemas/ # Pydantic request/response schemas
|
||||
│ │ │ ├── user_data.py # User data endpoints (replays, collections, groups, etc.)
|
||||
│ │ ├── schemas/ # Pydantic request/response schemas (user_data_schemas.py)
|
||||
│ │ ├── services/ # Business logic (MTGJSON manager, card DB, game server, deck parser)
|
||||
│ │ └── main.py # FastAPI app entry point
|
||||
│ │ └── main.py # FastAPI app entry point (user-data mounted at /api/v1/user-data)
|
||||
│ ├── alembic/ # Database migrations
|
||||
│ │ ├── env.py # Async Alembic configuration
|
||||
│ │ └── versions/ # Migration scripts
|
||||
│ │ └── 001_initial_user_schema.py
|
||||
│ ├── scripts/ # Utility scripts (downloads, migrations, checks)
|
||||
│ ├── Dockerfile
|
||||
│ │ └── run_migrations.sh
|
||||
│ ├── Dockerfile # Updated to run migrations on startup
|
||||
│ ├── requirements.txt
|
||||
│ └── .env.example
|
||||
├── docker-compose.dev.yml # Development stack
|
||||
@@ -174,10 +182,16 @@ environment:
|
||||
**Gitea Repository**: `https://git.optimex.systems/admin/mtgonline.git`
|
||||
**Credentials**: Located at `/home/wall-o/projects/gitea_credentials.txt`
|
||||
**Current Branch**: `main`
|
||||
**Last Commit**: `46abfe5` - "Add comprehensive documentation for MTG Online Backend"
|
||||
**Last Commit**: `c42d7ca` - "feat: implement user data schema and API endpoints"
|
||||
|
||||
### Commit History
|
||||
```
|
||||
c42d7ca - feat: implement user data schema and API endpoints
|
||||
- Add Alembic migration setup with async configuration
|
||||
- Create 16 user data models (users, decks, cards, replays, etc.)
|
||||
- Implement comprehensive API endpoints with JWT auth
|
||||
- Add replay, card collection, group, network, preferences, and activity log routers
|
||||
- Include API documentation and migration test plan
|
||||
46abfe5 - Add comprehensive documentation for MTG Online Backend
|
||||
6f01e2d - Initial project setup
|
||||
```
|
||||
@@ -373,39 +387,88 @@ The multiplayer gameplay feature will live in a **separate backend codebase** to
|
||||
|
||||
See **ROADMAP.md Phase 2** for detailed task breakdown.
|
||||
|
||||
## User Data Schema & API
|
||||
|
||||
### Database Models (16 Tables)
|
||||
- **`users`** - User accounts with authentication
|
||||
- **`decks`** - User decks (DRAFT/FINAL status)
|
||||
- **`cards`** - User card collections
|
||||
- **`card_ownership`** - Card ownership tracking
|
||||
- **`win_streaks`** - Win/loss statistics
|
||||
- **`game_replays`** - Saved game replays (JSONB)
|
||||
- **`groups`** - User groups
|
||||
- **`group_members`** - Group membership
|
||||
- **`networks`** - Network accounts (Twitch, X, YouTube)
|
||||
- **`network_credentials`** - Network login info
|
||||
- **`preferences`** - User preferences (JSONB)
|
||||
- **`activity_log`** - User activity tracking (JSONB)
|
||||
- **`suggested_cards`** - Card suggestions
|
||||
- **`folders`** - Deck organization
|
||||
- **`game_logs`** - Game audit trail
|
||||
- **`user_decks`** - User deck storage (DRAFT/FINAL)
|
||||
|
||||
### API Endpoints
|
||||
|
||||
#### Replays (`/api/v1/user-data/replays`)
|
||||
- `POST /api/v1/user-data/replays/` - Save replay
|
||||
- `GET /api/v1/user-data/replays/{replay_id}` - Get replay
|
||||
- `DELETE /api/v1/user-data/replays/{replay_id}` - Delete replay
|
||||
|
||||
#### Card Collection (`/api/v1/user-data/cards`)
|
||||
- `GET /api/v1/user-data/cards/` - List user's cards
|
||||
- `POST /api/v1/user-data/cards/` - Add card to collection
|
||||
- `DELETE /api/v1/user-data/cards/{card_id}` - Remove card
|
||||
|
||||
#### Groups (`/api/v1/user-data/groups`)
|
||||
- `GET /api/v1/user-data/groups/` - List user's groups
|
||||
- `POST /api/v1/user-data/groups/` - Create group
|
||||
- `PATCH /api/v1/user-data/groups/{group_id}` - Update group
|
||||
- `DELETE /api/v1/user-data/groups/{group_id}` - Delete group
|
||||
|
||||
#### Networks (`/api/v1/user-data/networks`)
|
||||
- `GET /api/v1/user-data/networks/` - List network accounts
|
||||
- `POST /api/v1/user-data/networks/` - Add network
|
||||
- `PATCH /api/v1/user-data/networks/{network_id}` - Update network
|
||||
- `DELETE /api/v1/user-data/networks/{network_id}` - Remove network
|
||||
|
||||
#### Preferences (`/api/v1/user-data/preferences`)
|
||||
- `GET /api/v1/user-data/preferences/` - Get preferences
|
||||
- `PATCH /api/v1/user-data/preferences/` - Update preferences
|
||||
|
||||
#### Activity Log (`/api/v1/user-data/activity`)
|
||||
- `GET /api/v1/user-data/activity/` - List activity
|
||||
- `POST /api/v1/user-data/activity/` - Add activity entry
|
||||
|
||||
### Alembic Migrations
|
||||
- **Async configuration** with `run_sync` for database operations
|
||||
- **Initial migration**: `001_initial_user_schema.py` creates all 16 tables
|
||||
- **Migration script**: `scripts/run_migrations.sh` runs on container startup
|
||||
- **JSONB columns** used for flexible data storage (replay_data, activity_data, preferences)
|
||||
|
||||
### Architecture Decisions
|
||||
- **CASCADE deletes** for data integrity in related tables
|
||||
- **Composite unique constraints** for card collection uniqueness
|
||||
- **RESTful API design** with pagination support
|
||||
- **JWT authentication** for all endpoints
|
||||
- **Permission checks** for group/network management
|
||||
|
||||
## State File
|
||||
|
||||
Current state saved at: `/home/wall-o/projects/mtgonline/state.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"task_description": "Complete documentation and cleanup of MTG Online Backend project",
|
||||
"current_step": "All tasks completed: documentation, commit/push to Gitea, Docker cleanup",
|
||||
"files_created": [
|
||||
"/home/wall-o/projects/mtgonline/README.md",
|
||||
"/home/wall-o/projects/mtgonline/backend/README.md"
|
||||
],
|
||||
"files_modified": [
|
||||
"/home/wall-o/projects/mtgonline/README.md",
|
||||
"/home/wall-o/projects/mtgonline/state.json"
|
||||
],
|
||||
"decisions": [
|
||||
"Updated root README with current architecture (dual PostgreSQL, Redis, MTGJSON pipeline)",
|
||||
"Created comprehensive backend README with architecture, database setup, and troubleshooting",
|
||||
"Hardcoded environment variables in docker-compose.dev.yml to prevent connection issues",
|
||||
"Backend successfully connects to mtgdata:5432/mtgdata (not localhost)",
|
||||
"All Docker resources cleaned up: containers, images, volumes, networks"
|
||||
],
|
||||
"next_steps": [],
|
||||
"blockers": [],
|
||||
"commit_hash": "46abfe5",
|
||||
"timestamp": "2026-07-21T03:56:00Z"
|
||||
"task_description": "Create Alembic migration setup for user data schema and complete API endpoints for all user data features",
|
||||
"current_step": "Phase 3 completed - All API endpoints created with comprehensive documentation",
|
||||
"commit_hash": "c42d7ca",
|
||||
"timestamp": "2026-07-22T23:23:00-04:00"
|
||||
}
|
||||
```
|
||||
|
||||
## Access Information
|
||||
|
||||
- **Backend API**: `http://localhost:5555`
|
||||
- **User Data API**: `http://localhost:5555/api/v1/user-data`
|
||||
- **Swagger Docs**: `http://localhost:5555/docs`
|
||||
- **Health Check**: `http://localhost:5555/health`
|
||||
- **Gitea**: `https://git.optimex.systems/admin/mtgonline`
|
||||
@@ -420,22 +483,21 @@ Current state saved at: `/home/wall-o/projects/mtgonline/state.json`
|
||||
#### Architecture & Configuration
|
||||
4. `/home/wall-o/projects/mtgonline/docker-compose.dev.yml` - Docker configuration
|
||||
5. `/home/wall-o/projects/mtgonline/backend/app/core/settings.py` - Application settings
|
||||
6. `/home/wall-o/projects/mtgonline/backend/app/main.py` - FastAPI entry point
|
||||
6. `/home/wall-o/projects/mtgonline/backend/app/main.py` - FastAPI entry point (user-data mounted at /api/v1/user-data)
|
||||
|
||||
#### MTGJSON Integration
|
||||
7. `/home/wall-o/projects/mtgonline/backend/app/services/mtgjson_manager.py` - MTGJSON pipeline
|
||||
#### User Data Models
|
||||
7. `/home/wall-o/projects/mtgonline/backend/app/models/user_data.py` - All user data models (16 tables)
|
||||
8. `/home/wall-o/projects/mtgonline/backend/alembic/versions/001_initial_user_schema.py` - Migration script
|
||||
|
||||
#### Strategic Documents
|
||||
8. `/home/wall-o/projects/mtgonline/ROADMAP.md` - Complete feature roadmap and timeline
|
||||
9. `/home/wall-o/projects/mtgonline/STATEMENT_OF_INTENT.md` - Project vision and objectives
|
||||
#### API Endpoints
|
||||
9. `/home/wall-o/projects/mtgonline/backend/app/routers/user_data.py` - User data API endpoints
|
||||
10. `/home/wall-o/projects/mtgonline/backend/app/schemas/user_data_schemas.py` - Pydantic schemas for user data
|
||||
|
||||
#### Database & Models
|
||||
10. `/home/wall-o/projects/mtgonline/backend/app/models/models.py` - SQLAlchemy ORM models
|
||||
11. `/home/wall-o/projects/mtgonline/backend/app/models/mtg_models.py` - MTG-specific models
|
||||
|
||||
#### APIs
|
||||
12. `/home/wall-o/projects/mtgonline/backend/app/routers/` - All API route modules
|
||||
13. `/home/wall-o/projects/mtgonline/backend/app/schemas/` - Pydantic request/response schemas
|
||||
#### Documentation
|
||||
11. `/home/wall-o/projects/mtgonline/backend/API_DOCUMENTATION.md` - Comprehensive API documentation
|
||||
12. `/home/wall-o/projects/mtgonline/backend/TEST_PLAN.md` - Migration test plan
|
||||
13. `/home/wall-o/projects/mtgonline/ROADMAP.md` - Complete feature roadmap and timeline
|
||||
14. `/home/wall-o/projects/mtgonline/STATEMENT_OF_INTENT.md` - Project vision and objectives
|
||||
|
||||
## Environment
|
||||
|
||||
@@ -446,10 +508,10 @@ Current state saved at: `/home/wall-o/projects/mtgonline/state.json`
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2026-07-21T03:56:00Z
|
||||
**Status**: Phase 1 Complete. Ready for Phase 2: Backend Expansion for Frontend Support.
|
||||
**Last Updated**: 2026-07-22T23:23:00-04:00
|
||||
**Status**: Phase 1-3 Complete. Ready for Phase 4: Testing and Deployment.
|
||||
|
||||
**Next Action**: Begin backend database schema expansion and API development for deckbuilding and gameplay features.
|
||||
**Next Action**: Test migration execution in container, run API tests against all endpoints, add rate limiting, create integration tests, deploy to staging environment.
|
||||
|
||||
**Timeline**:
|
||||
| Phase | Duration | Status |
|
||||
|
||||
Reference in New Issue
Block a user