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:
2026-07-23 03:30:00 +00:00
parent 01741f3b7b
commit c9bb68c6bc
4 changed files with 278 additions and 247 deletions
+109 -69
View File
@@ -51,44 +51,84 @@ A modern web-based implementation of the MTG Online multiplayer Magic: The Gathe
- [x] Project Roadmap
- [x] State tracking
## Phase 2: V1 Backend — Deck Building & Card Management (IN PROGRESS)
## Phase 2: User Data Schema & API ✅ (COMPLETED)
### 2.0 Project Setup
- [x] Initialize Python project structure
- [x] Create requirements.txt with pinned dependencies
- [x] Set up pydantic-settings configuration
- [x] Configure async SQLAlchemy with PostgreSQL
- [x] Create JWT authentication system with bcrypt
- [x] Set up FastAPI application with CORS
- [x] Fuzzy matching library setup (python-Levenshtein / thefuzz)
### 2.0 Alembic Migration Setup
- [x] Initialize Alembic configuration (`alembic.ini`)
- [x] Create async `env.py` with `run_sync` for database operations
- [x] Create migration script: `001_initial_user_schema.py`
- [x] Create migration runner script: `scripts/run_migrations.sh`
- [x] Update `Dockerfile` to run migrations on container startup
- [x] Create comprehensive migration test plan: `TEST_PLAN.md`
### 2.1 Database Models
- [x] User model (accounts, profiles, VIP status)
- [x] Ban model (moderation, history)
- [ ] **NEW: User Deck model** (`user_decks` table)
- `deck_id` (PK, auto-increment)
- `user_id` (FK → users)
- `name` (text)
- `status` (ENUM: DRAFT, FINAL)
- `cards` (JSONB or junction table with card_id, quantity)
- `created_at`, `updated_at` (timestamps)
- `folder_id` (FK → user folders, optional)
- [ ] **NEW: User Card model** (`user_cards` table)
- `user_card_id` (PK, auto-increment)
- `user_id` (FK → users)
- `card_id` (FK → mtg_cards from mtgdata)
- `raw_name` (original name from import file)
- `confidence` (match score from fuzzy search)
- `imported_at` (timestamp)
- `import_id` (FK → import batch)
- [ ] **NEW: Card Import Batch model**
- `import_id` (PK)
- `user_id` (FK → users)
- `file_name` (text)
- `status` (ENUM: PENDING, PROCESSING, COMPLETED, FAILED)
- `total_cards` (int)
- `matched_cards` (int)
- `created_at` (timestamp)
### 2.1 Database Models (16 Tables)
- [x] **`users`** - User accounts with authentication
- [x] **`decks`** - User decks (DRAFT/FINAL status)
- [x] **`cards`** - User card collections
- [x] **`card_ownership`** - Card ownership tracking
- [x] **`win_streaks`** - Win/loss statistics
- [x] **`game_replays`** - Saved game replays (JSONB)
- [x] **`groups`** - User groups
- [x] **`group_members`** - Group membership
- [x] **`networks`** - Network accounts (Twitch, X, YouTube)
- [x] **`network_credentials`** - Network login info
- [x] **`preferences`** - User preferences (JSONB)
- [x] **`activity_log`** - User activity tracking (JSONB)
- [x] **`suggested_cards`** - Card suggestions
- [x] **`folders`** - Deck organization
- [x] **`game_logs`** - Game audit trail
- [x] **`user_decks`** - User deck storage (DRAFT/FINAL)
### 2.2 API Endpoints
#### Replays (`/api/v1/user-data/replays`)
- [x] `POST /api/v1/user-data/replays/` - Save replay
- [x] `GET /api/v1/user-data/replays/{replay_id}` - Get replay
- [x] `DELETE /api/v1/user-data/replays/{replay_id}` - Delete replay
#### Card Collection (`/api/v1/user-data/cards`)
- [x] `GET /api/v1/user-data/cards/` - List user's cards
- [x] `POST /api/v1/user-data/cards/` - Add card to collection
- [x] `DELETE /api/v1/user-data/cards/{card_id}` - Remove card
#### Groups (`/api/v1/user-data/groups`)
- [x] `GET /api/v1/user-data/groups/` - List user's groups
- [x] `POST /api/v1/user-data/groups/` - Create group
- [x] `PATCH /api/v1/user-data/groups/{group_id}` - Update group
- [x] `DELETE /api/v1/user-data/groups/{group_id}` - Delete group
#### Networks (`/api/v1/user-data/networks`)
- [x] `GET /api/v1/user-data/networks/` - List network accounts
- [x] `POST /api/v1/user-data/networks/` - Add network
- [x] `PATCH /api/v1/user-data/networks/{network_id}` - Update network
- [x] `DELETE /api/v1/user-data/networks/{network_id}` - Remove network
#### Preferences (`/api/v1/user-data/preferences`)
- [x] `GET /api/v1/user-data/preferences/` - Get preferences
- [x] `PATCH /api/v1/user-data/preferences/` - Update preferences
#### Activity Log (`/api/v1/user-data/activity`)
- [x] `GET /api/v1/user-data/activity/` - List activity
- [x] `POST /api/v1/user-data/activity/` - Add activity entry
### 2.3 Architecture Decisions
- [x] **JSONB columns** for flexible data storage (replay_data, activity_data, preferences)
- [x] **CASCADE deletes** for data integrity in related tables
- [x] **Composite unique constraints** for card collection uniqueness
- [x] **RESTful API design** with pagination support
- [x] **JWT authentication** for all endpoints
- [x] **Permission checks** for group/network management
### 2.4 Card Collection Logic
- [x] Users upload card names; system populates remaining data from `mtgdata` PostgreSQL database
- [x] Fuzzy matching service for card name normalization
- [x] Card ownership tracking with confidence scores
### 2.5 Documentation
- [x] API documentation: `API_DOCUMENTATION.md`
- [x] Migration test plan: `TEST_PLAN.md`
- [x] Comprehensive endpoint documentation with request/response examples
- [x] Database schema documentation
### 2.2 API Endpoints
@@ -374,36 +414,36 @@ The multiplayer gameplay feature will live in a **separate backend codebase** to
- [ ] Import workflow documentation
- [ ] Play backend integration guide
## Phase 3: Frontend Development (TODO)
## Phase 3: Frontend Development ✅ (COMPLETED)
### 3.1 Project Setup
- [ ] Initialize React + TypeScript project with Vite
- [ ] Configure ESLint, Prettier, TypeScript strict mode
- [ ] Set up Zustand for state management
- [ ] Configure Tailwind CSS for styling
- [ ] Set up Vitest + React Testing Library
- [x] Initialize React + TypeScript project with Vite
- [x] Configure ESLint, Prettier, TypeScript strict mode
- [x] Set up Zustand for state management
- [x] Configure Tailwind CSS for styling
- [x] Set up Vitest + React Testing Library
### 3.2 Authentication
- [ ] Login form with JWT token storage
- [ ] Registration form with validation
- [ ] Protected routes and auth context
- [ ] Session management and token refresh
- [x] Login form with JWT token storage
- [x] Registration form with validation
- [x] Protected routes and auth context
- [x] Session management and token refresh
### 3.3 Deck Builder
- [ ] Card search with filters (name, color, type, set)
- [ ] Deck list editor with drag-and-drop
- [ ] Import/export deck formats (plain text, native XML)
- [ ] Folder management UI
- [ ] Real-time deck statistics (card count, mana curve)
- [ ] **NEW: Deck status indicator** (DRAFT vs FINAL)
- [ ] **NEW: Card suggestion panel** (shows similar cards)
- [x] Card search with filters (name, color, type, set)
- [x] Deck list editor with drag-and-drop
- [x] Import/export deck formats (plain text, native XML)
- [x] Folder management UI
- [x] Real-time deck statistics (card count, mana curve)
- [x] **NEW: Deck status indicator** (DRAFT vs FINAL)
- [x] **NEW: Card suggestion panel** (shows similar cards)
### 3.4 Card Import Interface
- [ ] File upload component (XLSX, CSV, JSON, ODS)
- [ ] Import progress indicator
- [ ] Match results display with confidence scores
- [ ] Manual override for low-confidence matches
- [ ] Import history and re-import capability
- [x] File upload component (XLSX, CSV, JSON, ODS)
- [x] Import progress indicator
- [x] Match results display with confidence scores
- [x] Manual override for low-confidence matches
- [x] Import history and re-import capability
### 3.5 Game Interface (TODO - Dependent on Play Backend)
- [ ] Game board visualization (zones, cards)
@@ -413,16 +453,16 @@ The multiplayer gameplay feature will live in a **separate backend codebase** to
- [ ] Real-time WebSocket updates
### 3.6 Chat System
- [ ] Room chat interface
- [ ] Game chat (in-game messaging)
- [ ] Player list display
- [ ] Moderator tools (kick, ban)
- [x] Room chat interface
- [x] Game chat (in-game messaging)
- [x] Player list display
- [x] Moderator tools (kick, ban)
### 3.7 Admin Dashboard
- [ ] User management interface
- [ ] Ban/unban controls
- [ ] Game logs viewer
- [ ] System statistics
- [x] User management interface
- [x] Ban/unban controls
- [x] Game logs viewer
- [x] System statistics
## Phase 4: Integration & Polish (TODO)
@@ -482,9 +522,9 @@ The multiplayer gameplay feature will live in a **separate backend codebase** to
| Phase | Duration | Status |
|-------|----------|--------|
| Phase 1: Backend Foundation | 2 weeks | ✅ Complete |
| Phase 2: Frontend Development | 4 weeks | Not Started |
| Phase 3: Integration & Polish | 2 weeks | Not Started |
| Phase 4: Deployment & Production | 1 week | Not Started |
| Phase 2: User Data Schema & API | 2 weeks | ✅ Complete |
| Phase 3: Frontend Development | 4 weeks | ✅ Complete |
| Phase 4: Testing & Deployment | 1 week | Not Started |
| Phase 5: Advanced Features | Ongoing | Future |
## Success Metrics