# Phase 4 Implementation Analysis - Django Models & API Structure ## Django Models Analysis ### Parks App Models Structure - **Location**: `backend/apps/parks/models/` (directory structure) - **Key Models**: - `Park`: Main entity with operator (required), property_owner (optional) - `ParkArea`: Areas within parks - `ParkLocation`: Geographic location data - `ParkReview`: User reviews - `ParkPhoto`: Media attachments - `Company` (aliased as `Operator`): Park operators - `CompanyHeadquarters`: Company location data ### Park Model Key Fields - `name`, `slug`, `description`, `status`, `park_type` - `opening_date`, `closing_date`, `operating_season` - `size_acres`, `website` - **Statistics**: `average_rating`, `ride_count`, `coaster_count` - **Images**: `banner_image`, `card_image` (ForeignKey to ParkPhoto) - **Relationships**: `operator` (required), `property_owner` (optional) - **Computed**: `opening_year`, `search_text` ### Rides App Models Structure - **Location**: `backend/apps/rides/models/` (directory structure) - **Key Models**: - `Ride`: Main ride entity - `RideModel`: Ride model/type information - `RollerCoasterStats`: Specific coaster statistics - `Company`: Manufacturers/designers - `RideLocation`: Geographic data - `RideReview`: User reviews - `RidePhoto`: Media attachments - **Rankings**: `RideRanking`, `RidePairComparison`, `RankingSnapshot` ## API Structure Analysis ### Centralized API Architecture - **Base Path**: `backend/apps/api/v1/` - **Structure**: Organized by domain (parks, rides, auth, etc.) - **Key Endpoints**: - `/v1/parks/` - Park data and operations - `/v1/rides/` - Ride data and operations - `/v1/auth/` - Authentication - `/v1/stats/` - Statistics data - `/v1/views/` - View-specific endpoints ### Template Structure - **Base Template**: `templates/base/base.html` (850+ lines) - **Features**: Complete design system, dark/light mode, HTMX/Alpine.js integration - **Current State**: Only base template exists, need to create homepage ## Data Requirements for Homepage ### Statistics Dashboard - Total parks count - Total rides count - Total coaster count - Average park ratings - Recent activity metrics ### Featured Content - Featured parks (highest rated, newest, popular) - Featured rides (top rated, newest additions) - Recent reviews and activity ### Search Functionality - Global search across parks and rides - Filter by type, location, status - HTMX-powered dynamic results ## Implementation Strategy ### 1. Homepage Template Structure ``` templates/ ├── base/ │ └── base.html (existing) ├── pages/ │ └── homepage.html (new) ├── components/ │ ├── hero-section.html │ ├── featured-parks.html │ ├── featured-rides.html │ ├── stats-dashboard.html │ └── recent-activity.html └── partials/ ├── park-card.html ├── ride-card.html └── search-results.html ``` ### 2. API Endpoints Needed - `/api/v1/stats/homepage/` - Homepage statistics - `/api/v1/parks/featured/` - Featured parks - `/api/v1/rides/featured/` - Featured rides - `/api/v1/search/global/` - Global search ### 3. HTMX Integration Points - Dynamic search results - Featured content loading - Statistics updates - Infinite scroll for content ### 4. Alpine.js Enhancements - Search state management - Theme switching - Interactive animations - Client-side filtering ## Next Steps 1. Create homepage template extending base template 2. Implement hero section with search 3. Add featured content sections 4. Create statistics dashboard 5. Add HTMX partial templates 6. Integrate Alpine.js interactions