# ThrillWiki Implementation Plan

## User Review Required
> [!IMPORTANT]
> **Measurement Unit System**: The backend will store all values in **Metric**. The Frontend (`useUnits` composable) will handle conversion to Imperial based on user preference.
> **Sacred Pipeline Enforcement**: All user edits create `Submission` records (stored as JSON). No direct database edits are allowed for non-admin users.

## Proposed Changes

### Backend (Django + DRF)

#### 1. Core & Auth Infrastructure
- [x] **`apps.core`**: Implement `TrackedModel` using `pghistory` for all core entities to support Edit History and Versioning (Section 15).
- [x] **`apps.accounts`**:
    - `User` & `UserProfile` models (Bio, Location, Home Park).
    - **Settings Support**: Endpoints for changing Email, Password, MFA, and Sessions (Section 9.1-9.2).
    - **Privacy**: Fields for `public_profile`, `show_location`, etc. (Section 9.3).
    - **Data Export**: Endpoint to generate JSON dump of all user data (Section 9.6).
    - **Account Deletion**: `UserDeletionRequest` model with 7-day grace period (Section 9.6).

#### 2. Entity Models & Logic ("Live" Data)
- [x] **`apps.parks`**: `Park` (with Operator/Owner FKs, Geolocation).
- [x] **`apps.rides`**: `Ride` (Status FSM), `RideModel`, `Manufacturer`, `Designer`.
- [x] **`apps.rides` (Credits)**: `RideCredit` Through-Model with `count`, `rating`, `date`, `notes`. Constraint: Unique(user, ride).
- [x] **`apps.companies`**: `Company` model with types (`Manufacturer`, `Designer`, `Operator`, `Owner`).
- [x] **`apps.lists`**: `UserList` (Ranking System) and `UserListItem`.
- [x] **`apps.reviews`**: `Review` model (GenericFK) with Aggregation Logic.

#### 3. The Sacred Pipeline (`apps.moderation`)
- [x] **Submission Model**: Stores `changes` (JSON), `status` (State Machine), `moderator_note`.
- [x] **Submission Serializers**: Handle validation of "Proposed Data" vs "Live Data".
- [x] **Queue Endpoints**: `list_pending`, `claim`, `approve`, `reject`, `activity_log`, `stats`.
- [x] **Reports**: `Report` model and endpoints.

### Frontend (Nuxt 4)

#### 1. Initial Setup & Core
- [x] **Composables**: `useUnits` (Metric/Imperial), `useAuth` (MFA, Session), `useApi`.
- [x] **Layouts**: Standard Layout (Hero, Tabs), Auth Layout.

#### 2. Discovery & Search (Section 1 & 6)
- [x] **Global Search**: Hero Search with Autocomplete (Parks, Rides, Companies).
- [x] **Discovery Tabs** (11 Sections):
    - [x] Trending Parks / Rides
    - [x] New Parks / Rides
    - [x] Top Parks / Rides
    - [x] Opening Soon / Recently Opened
    - [x] Closing Soon / Recently Closed
    - [x] Recent Changes Feed

#### 3. Content Pages (Read-Only Views)
- [ ] **Park Detail**: Tabs (Overview, Rides, Reviews, Photos, History).
- [ ] **Ride Detail**: Tabs (Overview, Specifications, Reviews, Photos, History).
- [ ] **Company Pages**: Manufacturer, Designer, Operator, Property Owner details.
- [ ] **Maps**: Interactive "Parks Nearby" map.

#### 4. The Sacred Submission Pipeline (Write Views)
- [ ] **Submission Forms** (Multi-step Wizards):
    - [ ] **Park Form**: Location, Dates, Media, Relations.
    - [ ] **Ride Form**: Specs (with Unit Toggle), Relations, Park selection.
    - [ ] **Company Form**: Type selection, HQ, details.
    - [ ] **Photo Upload**: Bulk upload, captioning, crop.
- [ ] **Editing**: Load existing data into form -> Submit as JSON Diff.

#### 5. Moderation Interface (Section 16)
- [ ] **Dashboard**: Queue stats, Assignments.
- [ ] **Queues**:
    - [ ] **Pending Queue**: Filter by Type, Submitter, Date.
    - [ ] **Reports Queue**.
    - [ ] **Audit Log**.
- [ ] **Review Workspace**:
    - [ ] **Diff Viewer**: Visual Old vs New comparison.
    - [ ] **Actions**: Claim, Approve, Reject (with reason), Edit.

#### 6. User Experience & Settings
- [ ] **User Profile**: Activity Feed, Credits Tab, Lists Tab, Reviews Tab.
- [ ] **Ride Credits Management**: Add/Edit Credit (Date, Count, Notes).
- [ ] **Settings Area** (6 Tabs):
    - [ ] Account & Profile (Edit generic info).
    - [ ] Security (MFA setup, Active Sessions).
    - [ ] Privacy (Visibility settings).
    - [ ] Notifications.
    - [ ] Location & Info (Timezone, Home Park).
    - [ ] Data & Export (JSON Download, Delete Account).

#### 7. Lists System
- [ ] **List Management**: Create/Edit Lists (Public/Private).
- [ ] **List Editor**: Search items, Add to list, Drag-and-drop reorder, Add notes.

## Verification Plan

### Automated Tests
- **Backend**: `pytest` for all Model constraints and API permissions.
    - Test Submission State Machine: `Pending -> Claimed -> Approved`.
    - Test Versioning: Ensure `pghistory` tracks changes on approval.
- **Frontend**: `vitest` for Unit Tests (Composables).

### Manual Verification Flows
1. **Sacred Pipeline Flow**:
   - **User**: Submit a change to "Top Thrill 2" (add stats).
   - **Moderator**: Go to Queue -> Claim -> Verify Diff -> Approve.
   - **Public**: Verify "Top Thrill 2" page shows new stats and "Last Updated" is now.
   - **History**: Verify "History" tab shows the update event.

2. **Ride Credits**:
   - Go to "Iron Gwazi" page.
   - Click "Add to Credits" -> Enter `Count: 5`, `Rating: 4.5`.
   - Go to Profile -> Ride Credits. Verify Iron Gwazi is listed with correct data.

3. **Data Privacy & Export**:
   - Go to Settings -> Privacy -> Toggle "Private Profile".
   - Open Profile URL in Incognito -> Verify 404 or "Private" message.
   - Go to Settings -> Data -> "Download Data" -> Verify JSON structure.

---

## Gap Reconciliation Batches (Added 2025-12-26)

> [!IMPORTANT]
> These batches were identified during the Full Project Synchronization audit.
> Refer to `GAP_ANALYSIS_MATRIX.md` for detailed per-feature status.

### BATCH 1: Critical Missing Pages (HIGH PRIORITY)
- [ ] `/my-credits` - Ride Credits Dashboard with stats, filters, quick increment
- [ ] `/settings` - Full Settings Page (6 sections: Account, Security, Privacy, Notifications, Location, Data)
- [ ] `/parks/nearby` - Location-based Discovery with Leaflet map, geolocation, radius slider
- [ ] `/my-submissions` - Submission History for user's past edits
- [ ] Static Pages: `/terms`, `/privacy`, `/guidelines`

### BATCH 2: Missing Tabs on Existing Pages (HIGH PRIORITY)
- [ ] Park Detail - Add Reviews, Photos, History tabs
- [ ] Ride Detail - Add Specifications, Reviews, Photos, History tabs
- [ ] Homepage - Expand to 11 Discovery Tabs (All, Parks, Coasters, Flat, Water, Dark, Shows, Transport, Manufacturers, Designers, Recent)
- [ ] Profile Page - Add Reviews, Ride Credits tabs

### BATCH 3: Missing Components (MEDIUM PRIORITY)
- [ ] `ReviewCard.vue` - User review display with voting
- [ ] `CreditCard.vue` - Ride credit display with quick actions
- [ ] `StarRating.vue` - Star rating visualization
- [ ] `DiffViewer.vue` - Side-by-side comparison for moderation
- [ ] `ImageGallery.vue` - Photo gallery with lightbox
- [ ] `AppFooter.vue` - Site-wide footer
- [ ] `Breadcrumbs.vue` - Hierarchical navigation
- [ ] DatePicker and Range Slider components

### BATCH 4: Submission Forms (MEDIUM PRIORITY)
- [ ] `/submit/park` - Multi-step park submission wizard
- [ ] `/submit/ride` - Multi-step ride submission wizard
- [ ] `/submit/company` - Company submission wizard
- [ ] Edit forms for existing entities with JSON diff

### BATCH 5: Company Pages (MEDIUM PRIORITY)
- [ ] `/designers` - Designers listing and detail pages
- [ ] `/operators` - Operators listing and detail pages
- [ ] `/owners` - Property Owners listing and detail pages
- [ ] `/ride-models/[slug]` - Ride Model detail with installations

### BATCH 6: Enhanced Features (LOW PRIORITY)
- [ ] OAuth Authentication (Google, Discord)
- [ ] Magic Link Login
- [ ] CAPTCHA integration on forms
- [ ] MFA Setup UI
- [ ] Review voting (thumbs up/down) and replies
- [ ] Recent searches history
- [ ] Drag-and-drop list reordering
- [ ] Glass card effects (dark mode)
- [ ] Reduced motion support

---

## Execution Order Recommendation

1. **Start with BATCH 1** - Critical pages users expect
2. **Then BATCH 2** - Complete existing pages
3. **Then BATCH 3** - Components needed by batches 1 & 2
4. **Then BATCH 4** - Enable user contributions
5. **Then BATCH 5** - Additional entity types
6. **Finally BATCH 6** - Polish and enhancements

