feat: major project restructure - move Django to backend dir and fix critical imports

- Restructure project: moved Django backend to backend/ directory
- Add frontend/ directory for future Next.js application
- Add shared/ directory for common resources
- Fix critical Django import errors:
  - Add missing sys.path modification for apps directory
  - Fix undefined CATEGORY_CHOICES imports in rides module
  - Fix media migration undefined references
  - Remove unused imports and f-strings without placeholders
- Install missing django-environ dependency
- Django server now runs without ModuleNotFoundError
- Update .gitignore and README for new structure
- Add pnpm workspace configuration for monorepo setup
This commit is contained in:
pacnpal
2025-08-23 18:37:55 -04:00
parent 652ea149bd
commit b0e0678590
996 changed files with 370 additions and 192768 deletions

View File

@@ -1,150 +0,0 @@
# Authentication System Setup
## Overview
This document outlines the setup of the authentication system, including both social and regular authentication.
## Backend Changes
### 1. Package Installation
```bash
pip install django-allauth==0.65.1 dj-rest-auth==6.0.0 djangorestframework==3.15.2 django-cors-headers==4.5.0
```
### 2. Configuration Files Modified
- thrillwiki/settings.py
- Added authentication apps
- Configured REST Framework
- Added CORS settings
- Added social auth providers
- Updated redirect URLs
- thrillwiki/urls.py
- Added dj-rest-auth URLs
- Added social auth URLs
### 3. New Files Created
- accounts/adapters.py
- Custom social account adapter
- Handles missing emails
- Sets profile pictures from social providers
### 4. Modified Files
- accounts/views.py
- Added email collection endpoint
- Updated authentication views
- accounts/urls.py
- Added new authentication endpoints
## Frontend Changes
### 1. Package Installation
```bash
npm install react-router-dom@6 axios@latest @react-oauth/google@latest
```
### 2. New Components Created
- src/contexts/AuthContext.tsx
- src/contexts/AuthProvider.tsx
- src/pages/Login.tsx
- src/pages/DiscordRedirect.tsx
- src/pages/EmailRequired.tsx
### 3. New Assets
- public/google-icon.svg
- public/discord-icon.svg
### 4. Modified Files
- src/App.tsx
- Added Google OAuth provider
- Added new routes
- src/api/client.ts
- Added authentication endpoints
- Added token handling
## Development Environment Setup
### Backend Setup
1. Create ***REMOVED*** file:
```env
DJANGO_SECRET_KEY=your_secret_key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:5173
# OAuth Credentials
GOOGLE_OAUTH2_CLIENT_ID=your_google_client_id
GOOGLE_OAUTH2_CLIENT_SECRET=your_google_client_secret
DISCORD_CLIENT_ID=your_discord_client_id
DISCORD_CLIENT_SECRET=your_discord_client_secret
# Database
DB_NAME=thrillwiki
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432
```
2. Run migrations:
```bash
python manage.py makemigrations
python manage.py migrate
```
### Frontend Setup
1. Create ***REMOVED*** file:
```env
VITE_API_URL=http://localhost:8000
VITE_GOOGLE_CLIENT_ID=your_google_client_id
VITE_DISCORD_CLIENT_ID=your_discord_client_id
```
2. Install dependencies:
```bash
cd frontend
npm install
```
## Testing Instructions
### Backend Testing
1. Start Django development server:
```bash
python manage.py runserver
```
2. Test endpoints:
- Regular auth: http://localhost:8000/api/auth/login/
- Social auth: http://localhost:8000/api/auth/google/login/
- User info: http://localhost:8000/api/auth/user/
### Frontend Testing
1. Start Vite development server:
```bash
cd frontend
npm run dev
```
2. Test flows:
- Regular login: http://localhost:5173/login
- Google login: Click "Continue with Google"
- Discord login: Click "Continue with Discord"
- Protected route: http://localhost:5173/settings
## Testing Checklist
- [ ] Regular login/registration
- [ ] Google OAuth flow
- [ ] Discord OAuth flow
- [ ] Email collection for social auth
- [ ] Profile picture import
- [ ] Protected route access
- [ ] Token persistence
- [ ] Error handling
- [ ] Logout functionality
## Notes
- Ensure all OAuth credentials are properly set up in Google Cloud Console and Discord Developer Portal
- Test all flows in incognito mode to avoid cached credentials
- Verify CSRF protection is working
- Check token expiration handling
- Test error scenarios (network issues, invalid credentials)

View File

@@ -1,59 +0,0 @@
# Changes Made - February 14, 2024
## Reactivated Removal
- Removed all reactivated-related files and configurations
- Cleaned up old client directory and unused configuration files
## Frontend Updates
- Updated to latest versions of all packages including Vite, React, and Material UI
- Configured Vite for optimal development experience
- Set up proper CORS and CSRF settings for Vite development server
- Improved build configuration with proper chunking and optimization
- Removed webpack configuration in favor of Vite
## Development Environment
- Created new development startup script (dev.sh)
- Updated frontend environment variables
- Configured HMR (Hot Module Replacement) for better development experience
- Set up proper proxy configuration for API and media files
## Configuration Updates
- Updated Django settings to work with Vite development server
- Added proper CORS and CSRF configurations for development
- Improved authentication backend configuration
## Park Detail Page Layout Updates
- Moved Quick Facts section from right column into header section for better information visibility
- Relocated map from left column to right column to improve content flow
- Added ride counts (Total Rides and Roller Coasters) to the header status badges
- Made the Location map card dynamically square, matching height to width
- Adjusted grid layout to maintain responsive design
- Added resize handling to ensure map stays square when browser window is resized
### Technical Details
- Modified templates/parks/park_detail.html
- Restructured grid layout classes
- Added JavaScript to maintain square aspect ratio for map
- Added window resize event handler for map container
- Reorganized content sections for better user experience
### Rationale
- Quick Facts are now more immediately visible to users in the header
- Map placement in right column provides better content hierarchy
- Square map provides better visual balance and consistency
- Ride counts in header give immediate overview of park size
- Changes improve overall page readability and information accessibility
## How to Run Development Environment
1. Ensure PostgreSQL is running and database is created
2. Set up your ***REMOVED*** file with necessary environment variables
3. Run migrations: `python manage.py migrate`
4. Install frontend dependencies: `cd frontend && npm install`
5. Start development servers: `./dev.sh`
The development environment will start both Django (port 8000) and Vite (port 5173) servers and open the application in your default browser.
## Next Steps
- Set up Netlify configuration for frontend deployment
- Configure production environment variables
- Set up CI/CD pipeline

View File

@@ -1,143 +0,0 @@
# Frontend Setup - February 14, 2024
## Technology Stack
### Core Technologies
- React 18.2.0
- TypeScript 5.2.2
- Material UI 5.14.17
- React Router 6.18.0
### Build Tools
- Webpack 5.89.0
- Babel 7.23.2
- CSS Loader 6.8.1
- Style Loader 3.3.3
### Development Tools
- Webpack Dev Server 4.15.1
- React Refresh Webpack Plugin 0.5.11
- TypeScript Compiler
- ESLint
## Features Implemented
### Core Features
1. Authentication
- Login/Register pages
- Social authentication support
- Protected routes
- User role management
2. Theme System
- Dark/Light mode toggle
- System preference detection
- Theme persistence
- Custom Material UI theme
3. Navigation
- Responsive navbar
- Mobile hamburger menu
- Search functionality
- User menu
4. Park Management
- Park listing with filters
- Park details page
- Ride listing
- Ride details page
5. User Features
- Profile pages
- Ride credits tracking
- Review system
- Photo uploads
### Technical Features
1. Performance
- Code splitting with React.lazy()
- Route-based chunking
- Image optimization
- Webpack optimization
2. Type Safety
- Full TypeScript integration
- Type-safe API calls
- Interface definitions
- Strict type checking
3. State Management
- React hooks
- Context API
- Local storage integration
- Form state management
4. UI/UX
- Responsive design
- Loading states
- Error boundaries
- Toast notifications
## Project Structure
```
frontend/
├── src/
│ ├── components/ # Reusable UI components
│ ├── pages/ # Route components
│ ├── hooks/ # Custom React hooks
│ ├── api/ # API client and utilities
│ ├── types/ # TypeScript definitions
│ └── utils/ # Helper functions
├── public/ # Static assets
└── webpack.config.js # Build configuration
```
## Development Workflow
1. Start Development Server:
```bash
npm start
```
2. Build for Production:
```bash
npm run build
```
3. Type Checking:
```bash
npm run type-check
```
4. Linting:
```bash
npm run lint
```
## Next Steps
1. Implement Edit System
- Inline editing for parks/rides
- Edit history tracking
- Moderation workflow
2. Review System
- Review submission
- Rating system
- Review moderation
3. Photo Management
- Photo upload
- Gallery system
- Photo moderation
4. Admin Interface
- User management
- Content moderation
- Statistics dashboard
5. Testing
- Unit tests
- Integration tests
- End-to-end tests

View File

@@ -1,78 +0,0 @@
# ThrillWiki Initial Setup
## Project Overview
ThrillWiki is a database website focused on rides and attractions in the amusement and theme park industries. The site features detailed statistics, photos, and user reviews for parks and rides worldwide.
## Technical Stack
- Backend: Django 5.1.2
- Frontend: React + Material UI + Alpine.js + HTMX
- Database: PostgreSQL
- Authentication: django-allauth (with Discord and Google OAuth support)
- Email: ForwardEmail.net SMTP
## Key Features
- Full authentication system with social login support
- Responsive design for desktop and mobile
- Light/dark theme support
- Rich media support for ride and park photos
- User review system with average ratings
- Inline editing for authenticated users
- Page history tracking
- Advanced search and filtering capabilities
## Project Structure
```
thrillwiki/
├── accounts/ # User authentication and profiles
├── api/ # REST API endpoints
├── docs/ # Project documentation
├── frontend/ # React frontend application
├── media/ # User-uploaded content
├── parks/ # Park-related models and views
├── reviews/ # User reviews functionality
├── rides/ # Ride-related models and views
├── static/ # Static assets
├── templates/ # Django templates
└── thrillwiki/ # Project settings and core configuration
```
## Setup Instructions
1. Create and activate a virtual environment:
```bash
python -m venv venv
source venv/bin/activate
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Configure environment variables:
- Copy ***REMOVED***.example to ***REMOVED***
- Update the variables with your specific values
4. Set up the database:
```bash
python manage.py migrate
```
5. Create a superuser:
```bash
python manage.py createsuperuser
```
6. Run the development server:
```bash
python manage.py runserver
```
## Next Steps
- [ ] Implement user models and authentication views
- [ ] Create park and ride models
- [ ] Set up review system
- [ ] Implement frontend components
- [ ] Configure social authentication
- [ ] Set up email verification
- [ ] Implement search and filtering
- [ ] Add media handling

File diff suppressed because it is too large Load Diff

View File

@@ -1,387 +0,0 @@
# ThrillWiki Complete Unraid Automation Guide
This guide provides **complete automation** for ThrillWiki deployment on Unraid, including VM creation, configuration, and CI/CD setup. Everything is automated with a single command.
## 🚀 One-Command Complete Setup
Run this single command to automate everything:
```bash
./scripts/unraid/setup-complete-automation.sh
```
This will:
1. ✅ Create and configure VM on Unraid
2. ✅ Install Ubuntu Server with all dependencies
3. ✅ Configure PostgreSQL database
4. ✅ Deploy ThrillWiki application
5. ✅ Set up systemd services
6. ✅ Configure SSH access
7. ✅ Set up webhook listener
8. ✅ Test the entire system
## System Architecture
```
GitHub Push → Webhook → Local Listener → SSH → Unraid VM → Deploy & Restart
```
## Prerequisites
### Local Machine
- Python 3.8+
- SSH client
- Internet connection
### Unraid Server
- Unraid 6.8+ with VM support enabled
- SSH access to Unraid server
- Sufficient resources (4GB RAM, 50GB disk minimum)
- Ubuntu Server 22.04 ISO in `/mnt/user/isos/`
## Automated Components
### 1. VM Manager (`scripts/unraid/vm-manager.py`)
- Creates VM with proper specifications
- Configures networking and storage
- Manages VM lifecycle (start/stop/status)
- Retrieves VM IP addresses
### 2. Complete Automation (`scripts/unraid/setup-complete-automation.sh`)
- Orchestrates entire setup process
- Handles SSH key generation and distribution
- Configures all services automatically
- Performs end-to-end testing
### 3. VM Configuration
- Ubuntu Server 22.04 LTS
- PostgreSQL database
- UV package manager
- Systemd services for ThrillWiki
- Nginx (optional)
## Step-by-Step Process
### Phase 1: Initial Setup
The automation script will prompt for:
- Unraid server IP address
- Unraid credentials
- VM specifications (memory, CPU, disk)
- GitHub repository URL
- Webhook secret
### Phase 2: SSH Key Setup
- Generates SSH keys for VM access
- Generates SSH keys for Unraid access
- Configures SSH client settings
- Tests connectivity
### Phase 3: VM Creation
- Creates VM XML configuration
- Creates virtual disk (QCOW2 format)
- Defines VM in libvirt
- Starts VM with Ubuntu installation
### Phase 4: VM Configuration
- Installs Ubuntu Server 22.04
- Configures user account with SSH keys
- Installs required packages:
- Python 3.8+
- UV package manager
- PostgreSQL
- Git
- Build tools
### Phase 5: ThrillWiki Deployment
- Clones repository
- Installs Python dependencies with UV
- Creates database and user
- Runs initial migrations
- Configures systemd services
- Starts ThrillWiki service
### Phase 6: CI/CD Setup
- Configures webhook listener
- Tests deployment pipeline
- Verifies all services
## Configuration Files Generated
### `***REMOVED***.unraid`
```bash
UNRAID_HOST=192.168.1.100
UNRAID_USER=root
VM_NAME=thrillwiki-vm
VM_MEMORY=4096
VM_VCPUS=2
VM_DISK_SIZE=50
SSH_PUBLIC_KEY=ssh-rsa AAAAB3...
```
### `***REMOVED***.webhook`
```bash
WEBHOOK_PORT=9000
WEBHOOK_SECRET=your_secret
VM_HOST=192.168.1.101
VM_USER=ubuntu
VM_KEY_PATH=/home/user/.ssh/thrillwiki_vm
VM_PROJECT_PATH=/home/ubuntu/thrillwiki
REPO_URL=https://github.com/user/repo.git
DEPLOY_BRANCH=main
```
### SSH Configuration
```
Host thrillwiki-vm
HostName 192.168.1.101
User ubuntu
IdentityFile ~/.ssh/thrillwiki_vm
StrictHostKeyChecking no
Host unraid
HostName 192.168.1.100
User root
IdentityFile ~/.ssh/unraid_access
StrictHostKeyChecking no
```
## VM Specifications
### Default Configuration
- **OS**: Ubuntu Server 22.04 LTS
- **Memory**: 4GB RAM
- **vCPUs**: 2
- **Storage**: 50GB (expandable)
- **Network**: Bridge mode (br0)
- **Boot**: UEFI with OVMF
### Customizable Options
All specifications can be customized during setup:
- Memory allocation
- CPU cores
- Disk size
- VM name
- Network configuration
## Services Installed
### On VM
- **ThrillWiki Django App**: Port 8000
- **PostgreSQL Database**: Port 5432
- **SSH Server**: Port 22
- **Systemd Services**: Auto-start on boot
### On Local Machine
- **Webhook Listener**: Configurable port (default 9000)
- **SSH Client**: Configured for VM access
## Management Commands
### VM Management
```bash
# Check VM status
python3 scripts/unraid/vm-manager.py status
# Start VM
python3 scripts/unraid/vm-manager.py start
# Stop VM
python3 scripts/unraid/vm-manager.py stop
# Get VM IP
python3 scripts/unraid/vm-manager.py ip
# Complete VM setup
python3 scripts/unraid/vm-manager.py setup
```
### Service Management
```bash
# Connect to VM
ssh thrillwiki-vm
# Check ThrillWiki service
sudo systemctl status thrillwiki
# Restart service
sudo systemctl restart thrillwiki
# View logs
journalctl -u thrillwiki -f
# Manual deployment
cd thrillwiki && ./scripts/vm-deploy.sh
```
### Webhook Management
```bash
# Start webhook listener
./start-webhook.sh
# Or manually
source ***REMOVED***.webhook && python3 scripts/webhook-listener.py
# Test webhook
curl -X GET http://localhost:9000/health
```
## Automated Testing
The setup includes comprehensive testing:
### Connectivity Tests
- SSH access to Unraid server
- SSH access to VM
- Network connectivity
### Service Tests
- ThrillWiki application startup
- Database connectivity
- Web server response
### Deployment Tests
- Git repository access
- Deployment script execution
- Service restart verification
## Security Features
### SSH Security
- Dedicated SSH keys for each connection
- No password authentication
- Key-based access only
### Network Security
- VM isolated in bridge network
- Firewall rules (configurable)
- SSH key rotation support
### Service Security
- Non-root service execution
- Systemd security features
- Log rotation and monitoring
## Troubleshooting
### Common Issues
1. **VM Creation Fails**
```bash
# Check Unraid VM support
ssh unraid "virsh list --all"
# Verify ISO exists
ssh unraid "ls -la /mnt/user/isos/*.iso"
```
2. **VM Won't Start**
```bash
# Check VM configuration
python3 scripts/unraid/vm-manager.py status
# Check Unraid logs
ssh unraid "tail -f /var/log/libvirt/qemu/thrillwiki-vm.log"
```
3. **Can't Connect to VM**
```bash
# Check VM IP
python3 scripts/unraid/vm-manager.py ip
# Test SSH key
ssh -i ~/.ssh/thrillwiki_vm ubuntu@VM_IP
```
4. **Service Won't Start**
```bash
# Check service logs
ssh thrillwiki-vm "journalctl -u thrillwiki --no-pager"
# Manual start
ssh thrillwiki-vm "cd thrillwiki && ./scripts/ci-start.sh"
```
### Log Locations
- **Setup logs**: `logs/unraid-automation.log`
- **VM logs**: SSH to VM, then `journalctl -u thrillwiki`
- **Webhook logs**: `logs/webhook.log`
- **Deployment logs**: On VM at `~/thrillwiki/logs/deploy.log`
## Advanced Configuration
### Custom VM Specifications
Edit variables in the automation script:
```bash
VM_MEMORY=8192 # 8GB RAM
VM_VCPUS=4 # 4 CPU cores
VM_DISK_SIZE=100 # 100GB disk
```
### Network Configuration
For static IP assignment, modify the VM XML template in `vm-manager.py`.
### Storage Configuration
The automation uses QCOW2 format for efficient storage. For better performance, consider:
- Raw disk format
- NVMe storage on Unraid
- Dedicated SSD for VM
## Performance Optimization
### Recommended Settings
- **Memory**: 4GB minimum, 8GB recommended
- **CPU**: 2 cores minimum, 4 cores for production
- **Storage**: SSD recommended for database
- **Network**: 1Gbps for fast deployments
### Production Considerations
- Use dedicated hardware for database
- Configure backup strategies
- Monitor resource usage
- Set up log rotation
## Backup and Recovery
### Automated Backups
The deployment script automatically creates backups before each deployment in `~/thrillwiki/backups/`.
### VM Snapshots
```bash
# Create VM snapshot
ssh unraid "virsh snapshot-create-as thrillwiki-vm snapshot-name"
# List snapshots
ssh unraid "virsh snapshot-list thrillwiki-vm"
# Restore snapshot
ssh unraid "virsh snapshot-revert thrillwiki-vm snapshot-name"
```
### Database Backups
```bash
# Manual database backup
ssh thrillwiki-vm "pg_dump thrillwiki > backup.sql"
# Automated backup (add to cron)
ssh thrillwiki-vm "crontab -e"
# Add: 0 2 * * * pg_dump thrillwiki > /home/ubuntu/db-backup-$(date +\%Y\%m\%d).sql
```
## Monitoring
### Health Checks
The system includes built-in health checks:
- VM status monitoring
- Service health verification
- Network connectivity tests
- Application response checks
### Alerts (Optional)
Configure alerts for:
- Service failures
- Resource exhaustion
- Deployment failures
- Network issues
This complete automation provides a production-ready ThrillWiki deployment with minimal manual intervention. The entire process from VM creation to application deployment is handled automatically.

View File

@@ -1,359 +0,0 @@
# ThrillWiki VM Deployment Setup Guide
This guide explains how to set up a local CI/CD system that automatically deploys ThrillWiki to a Linux VM when commits are pushed to GitHub.
## System Overview
The deployment system consists of three main components:
1. **Local CI Start Script** (`scripts/ci-start.sh`) - Starts the Django server locally
2. **GitHub Webhook Listener** (`scripts/webhook-listener.py`) - Listens for GitHub push events
3. **VM Deployment Script** (`scripts/vm-deploy.sh`) - Deploys code changes to the Linux VM
## Architecture Flow
```
GitHub Push → Webhook → Local Listener → SSH to VM → Deploy Script → Restart Server
```
## Prerequisites
### Local Machine (Webhook Listener Host)
- Python 3.8+
- SSH access to the Linux VM
- Git repository with webhook access
### Linux VM (Deployment Target)
- Ubuntu 20.04+ (recommended)
- Python 3.8+
- UV package manager
- Git
- PostgreSQL (if using database)
- SSH server running
- Sudo access for the deployment user
## Step 1: Linux VM Setup
### 1.1 Create Deployment User
```bash
# On the Linux VM
sudo adduser ubuntu
sudo usermod -aG sudo ubuntu
su - ubuntu
```
### 1.2 Install Required Software
```bash
# Update system
sudo apt update && sudo apt upgrade -y
# Install essential packages
sudo apt install -y git curl build-essential python3-pip python3-venv postgresql postgresql-contrib nginx
# Install UV package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.cargo/env
```
### 1.3 Set up SSH Keys
```bash
# Generate SSH key on local machine
ssh-keygen -t rsa -b 4096 -f ~/.ssh/thrillwiki_vm
# Copy public key to VM
ssh-copy-id -i ~/.ssh/thrillwiki_vm.pub ubuntu@VM_IP_ADDRESS
```
### 1.4 Clone Repository
```bash
# On the VM
cd /home/ubuntu
git clone https://github.com/YOUR_USERNAME/thrillwiki_django_no_react.git thrillwiki
cd thrillwiki
```
### 1.5 Install Dependencies
```bash
# Install Python dependencies
uv sync
# Create required directories
mkdir -p logs backups
```
## Step 2: Configure Services
### 2.1 Install Systemd Services
```bash
# Copy service files to systemd directory
sudo cp scripts/systemd/thrillwiki.service /etc/systemd/system/
sudo cp scripts/systemd/thrillwiki-webhook.service /etc/systemd/system/
# Edit service files to match your paths
sudo nano /etc/systemd/system/thrillwiki.service
sudo nano /etc/systemd/system/thrillwiki-webhook.service
# Reload systemd and enable services
sudo systemctl daemon-reload
sudo systemctl enable thrillwiki.service
sudo systemctl enable thrillwiki-webhook.service
```
### 2.2 Configure Environment Variables
Create `/home/ubuntu/thrillwiki/***REMOVED***`:
```bash
# Database configuration
DATABASE_URL=[DATABASE-URL-REMOVED]
# Django settings
DJANGO_SECRET_KEY=your_secret_key_here
DJANGO_DEBUG=False
DJANGO_ALLOWED_HOSTS=your_domain.com,VM_IP_ADDRESS
# Webhook configuration
WEBHOOK_SECRET=your_github_webhook_secret
WEBHOOK_PORT=9000
VM_HOST=localhost
VM_USER=ubuntu
VM_PROJECT_PATH=/home/ubuntu/thrillwiki
REPO_URL=https://github.com/YOUR_USERNAME/thrillwiki_django_no_react.git
```
## Step 3: Local Machine Setup
### 3.1 Configure Webhook Listener
Create a configuration file for the webhook listener:
```bash
# Create environment file
cat > ***REMOVED***.webhook << EOF
WEBHOOK_PORT=9000
WEBHOOK_SECRET=your_github_webhook_secret
VM_HOST=VM_IP_ADDRESS
VM_PORT=22
VM_USER=ubuntu
VM_KEY_PATH=/home/your_user/.ssh/thrillwiki_vm
VM_PROJECT_PATH=/home/ubuntu/thrillwiki
REPO_URL=https://github.com/YOUR_USERNAME/thrillwiki_django_no_react.git
DEPLOY_BRANCH=main
EOF
```
### 3.2 Set up GitHub Webhook
1. Go to your GitHub repository
2. Navigate to Settings → Webhooks
3. Click "Add webhook"
4. Configure:
- **Payload URL**: `http://YOUR_PUBLIC_IP:9000/webhook`
- **Content type**: `application/json`
- **Secret**: Your webhook secret
- **Events**: Select "Just the push event"
## Step 4: Database Setup
### 4.1 PostgreSQL Configuration
```bash
# On the VM
sudo -u postgres psql
-- Create database and user
CREATE DATABASE thrillwiki;
CREATE USER thrillwiki_user WITH ENCRYPTED PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE thrillwiki TO thrillwiki_user;
\q
# Install PostGIS (if using geographic features)
sudo apt install -y postgresql-postgis postgresql-postgis-scripts
sudo -u postgres psql -d thrillwiki -c "CREATE EXTENSION postgis;"
```
### 4.2 Run Initial Migration
```bash
# On the VM
cd /home/ubuntu/thrillwiki
uv run manage.py migrate
uv run manage.py collectstatic --noinput
uv run manage.py createsuperuser
```
## Step 5: Start Services
### 5.1 Start VM Services
```bash
# On the VM
sudo systemctl start thrillwiki
sudo systemctl start thrillwiki-webhook
sudo systemctl status thrillwiki
sudo systemctl status thrillwiki-webhook
```
### 5.2 Start Local Webhook Listener
```bash
# On local machine
source ***REMOVED***.webhook
python3 scripts/webhook-listener.py
```
## Step 6: Testing
### 6.1 Test Local Server
```bash
# Start local development server
./scripts/ci-start.sh
# Check if server is running
curl http://localhost:8000/health
```
### 6.2 Test VM Deployment
```bash
# On the VM, test deployment script
./scripts/vm-deploy.sh
# Check service status
./scripts/vm-deploy.sh status
# View logs
journalctl -u thrillwiki -f
```
### 6.3 Test Webhook
```bash
# Test webhook endpoint
curl -X GET http://localhost:9000/health
# Make a test commit and push to trigger deployment
git add .
git commit -m "Test deployment"
git push origin main
```
## Monitoring and Logs
### Service Logs
```bash
# View service logs
journalctl -u thrillwiki -f
journalctl -u thrillwiki-webhook -f
# View deployment logs
tail -f /home/ubuntu/thrillwiki/logs/deploy.log
tail -f /home/ubuntu/thrillwiki/logs/webhook.log
```
### Health Checks
```bash
# Check services status
systemctl status thrillwiki
systemctl status thrillwiki-webhook
# Manual health check
curl http://localhost:8000/health
curl http://localhost:9000/health
```
## Troubleshooting
### Common Issues
1. **Permission Denied**
```bash
# Fix file permissions
chmod +x scripts/*.sh
chown ubuntu:ubuntu -R /home/ubuntu/thrillwiki
```
2. **Service Won't Start**
```bash
# Check service logs
journalctl -u thrillwiki --no-pager
# Verify paths in service files
sudo systemctl edit thrillwiki
```
3. **Webhook Not Triggering**
```bash
# Check webhook listener logs
tail -f logs/webhook.log
# Verify GitHub webhook configuration
# Check firewall settings for port 9000
```
4. **Database Connection Issues**
```bash
# Test database connection
uv run manage.py dbshell
# Check PostgreSQL status
sudo systemctl status postgresql
```
### Rollback Procedure
If deployment fails, you can rollback:
```bash
# On the VM
./scripts/vm-deploy.sh
# The script automatically handles rollback on failure
# Manual rollback to specific commit
cd /home/ubuntu/thrillwiki
git reset --hard COMMIT_HASH
./scripts/vm-deploy.sh restart
```
## Security Considerations
1. **SSH Keys**: Use dedicated SSH keys for deployment
2. **Webhook Secret**: Use a strong, unique webhook secret
3. **Firewall**: Only open necessary ports (22, 8000, 9000)
4. **User Permissions**: Use dedicated deployment user with minimal privileges
5. **Environment Variables**: Store sensitive data in environment files, not in code
## Maintenance
### Regular Tasks
1. **Update Dependencies**: Run `uv sync` regularly
2. **Log Rotation**: Set up logrotate for application logs
3. **Backup Database**: Schedule regular database backups
4. **Monitor Disk Space**: Ensure sufficient space for logs and backups
### Cleanup Old Backups
```bash
# The deployment script automatically cleans old backups
# Manual cleanup if needed:
find /home/ubuntu/thrillwiki/backups -name "backup_*.commit" -mtime +30 -delete
```
## Performance Optimization
1. **Use Production WSGI Server**: Consider using Gunicorn instead of development server
2. **Reverse Proxy**: Set up Nginx as reverse proxy
3. **Database Optimization**: Configure PostgreSQL for production
4. **Static Files**: Serve static files through Nginx
This setup provides a robust CI/CD pipeline for automatic deployment of ThrillWiki to your Linux VM whenever code is pushed to GitHub.

View File

@@ -1,73 +0,0 @@
# Consolidation Analysis
## Review System Implementation
### Current Implementation
- Uses Django's GenericForeignKey (confirmed)
- Single Review model handles both parks and rides
- Related models: ReviewImage, ReviewLike, ReviewReport
- Content types: Currently supports any model type
### Migration Plan
1. **Create New Models**:
```python
# parks/models/reviews.py
class ParkReview(TrackedModel):
park = models.ForeignKey(Park, on_delete=models.CASCADE)
# ... other review fields ...
# rides/models/reviews.py
class RideReview(TrackedModel):
ride = models.ForeignKey(Ride, on_delete=models.CASCADE)
# ... other review fields ...
```
2. **Data Migration Steps**:
```python
# Migration operations
def migrate_reviews(apps, schema_editor):
Review = apps.get_model('reviews', 'Review')
ParkReview = apps.get_model('parks', 'ParkReview')
RideReview = apps.get_model('rides', 'RideReview')
for review in Review.objects.all():
if review.content_type.model == 'park':
ParkReview.objects.create(
park_id=review.object_id,
# ... map other fields ...
)
elif review.content_type.model == 'ride':
RideReview.objects.create(
ride_id=review.object_id,
# ... map other fields ...
)
```
3. **Update Related Models**:
```python
# Before (generic)
class ReviewImage(models.Model):
review = models.ForeignKey(Review, ...)
# After (concrete)
class ParkReviewImage(models.Model):
review = models.ForeignKey(ParkReview, ...)
class RideReviewImage(models.Model):
review = models.ForeignKey(RideReview, ...)
```
4. **Backward Compatibility**:
- Maintain old Review API during transition period
- Phase out generic reviews after data migration
### Entity Relationship Compliance
- Park reviews will reference Park model (via Operator)
- Ride reviews will reference Ride model (via Park → Operator)
- Complies with entity relationship rules in .clinerules
### Risk Mitigation
- Use data migration transactions
- Create database backups before migration
- Test with staging data first

View File

@@ -1,290 +0,0 @@
# ThrillWiki Moderation Guide
## Overview
This guide covers the moderation systems in ThrillWiki, including:
- Content edit submissions
- Photo submissions
- User reviews
- Report handling
- Moderation best practices
## Moderation Dashboard
Access the moderation dashboard at `/moderation/` to view:
- Pending edit submissions
- Photo submissions awaiting review
- Reported content
- Moderation statistics
## Content Edit Moderation
### Edit Submission Types
1. **Edit Existing**
- Changes to existing parks, rides, or other content
- Shows diff of proposed changes
- Requires source verification
2. **Create New**
- New park, ride, or content submissions
- Requires complete information
- Needs source verification
### Review Process
1. **Initial Assessment**
- Check submission completeness
- Verify sources
- Review user history
2. **Status Options**
```python
STATUS_CHOICES = [
('NEW', 'New'),
('APPROVED', 'Approved'),
('REJECTED', 'Rejected'),
('ESCALATED', 'Escalated'),
]
```
3. **Actions**
- Approve: Apply changes after verification
- Reject: Provide clear reason
- Escalate: For complex cases needing admin review
### Approval Guidelines
- Verify information accuracy
- Check reliable sources
- Ensure formatting consistency
- Review for completeness
### Rejection Guidelines
- Provide clear explanation
- Reference guidelines
- Suggest improvements
- Be constructive
## Photo Moderation
### Submission Types
- Park photos
- Ride photos
- Attraction photos
- Historical photos
### Review Process
1. **Initial Check**
- Image quality
- Appropriate content
- Copyright concerns
- Metadata accuracy
2. **Status Options**
```python
STATUS_CHOICES = [
('NEW', 'New'),
('APPROVED', 'Approved'),
('REJECTED', 'Rejected'),
('AUTO_APPROVED', 'Auto Approved'),
]
```
3. **Actions**
- Approve: Add to main gallery
- Reject: Explain issues
- Auto-approve: For trusted users
### Photo Guidelines
- Minimum resolution requirements
- No watermarks
- Clear and focused
- Appropriate content
- Proper attribution
## Review Moderation
### Review Components
- Rating (1-10)
- Written content
- Visit date
- Optional photos
### Moderation Criteria
1. **Content Standards**
- Constructive feedback
- No personal attacks
- Family-friendly language
- Factual accuracy
2. **Rating Consistency**
- Check against written content
- Compare with average ratings
- Look for rating abuse
3. **Photo Guidelines**
- Relevant to review
- Appropriate content
- Quality standards
### Report Handling
1. **Review Reports**
- Assess reported content
- Check reporter history
- Verify claims
2. **Actions**
- Remove inappropriate content
- Edit/update if needed
- Notify users
- Document actions
## Best Practices
### General Guidelines
1. **Consistency**
- Follow established guidelines
- Apply rules uniformly
- Document decisions
2. **Communication**
- Clear explanations
- Professional tone
- Constructive feedback
3. **Escalation**
- Know when to escalate
- Document complex cases
- Seek admin input
### Quality Control
1. **Content Standards**
- Accuracy
- Completeness
- Formatting
- Source verification
2. **User Management**
- Track user history
- Identify trusted contributors
- Handle problem users
3. **Documentation**
- Record decisions
- Note special cases
- Track patterns
## Moderation Tools
### Edit Submission Tools
```python
def approve(self, user):
"""Approve and apply changes"""
# Validates and applies changes
# Updates status
# Records moderator action
def reject(self, user):
"""Reject submission"""
# Updates status
# Records moderator action
# Notifies user
def escalate(self, user):
"""Escalate to admin"""
# Marks for admin review
# Records moderator action
```
### Photo Submission Tools
```python
def approve(self, moderator, notes=''):
"""Approve photo"""
# Moves to main gallery
# Updates status
# Records approval
def reject(self, moderator, notes):
"""Reject photo"""
# Updates status
# Records rejection reason
# Notifies user
```
## Special Cases
### Content Disputes
1. **Handling Conflicts**
- Review all perspectives
- Check reliable sources
- Document decisions
- Consider escalation
2. **Resolution Process**
- Gather evidence
- Consult experts if needed
- Make documented decision
- Communicate clearly
### Emergency Situations
1. **Immediate Action Needed**
- Inappropriate content
- Copyright violations
- Personal information
- Harmful content
2. **Response Protocol**
- Remove content immediately
- Document action taken
- Notify administrators
- Follow up as needed
## Moderation Workflow
1. **Daily Tasks**
- Review new submissions
- Check reported content
- Handle escalations
- Update documentation
2. **Weekly Tasks**
- Review moderation patterns
- Check for recurring issues
- Update guidelines if needed
- Team communication
3. **Monthly Tasks**
- Review statistics
- Assess guidelines
- Plan improvements
- Team training
## Resources
### Reference Materials
- Content guidelines
- Photo standards
- Review policies
- Escalation procedures
### Support Channels
- Admin contact information
- Team communication
- Emergency procedures
- Legal resources
## Training and Development
1. **New Moderator Training**
- Platform overview
- Tools introduction
- Guidelines review
- Supervised practice
2. **Ongoing Development**
- Regular updates
- Case studies
- Best practices
- Team feedback
## Conclusion
Effective moderation is crucial for maintaining ThrillWiki's quality and community. Follow these guidelines consistently while using good judgment for special cases. Document decisions and seek help when needed.

View File

@@ -1,244 +0,0 @@
# ThrillWiki Project Documentation
## Overview
ThrillWiki is a comprehensive Django-based web application for managing and sharing information about amusement parks, rides, and attractions. The platform allows users to explore parks, review rides, share photos, and track various statistics about amusement parks and rides worldwide.
## System Architecture
### Core Applications
1. **Parks App**
- Manages amusement park information
- Handles park areas and locations
- Tracks park statistics and operating status
2. **Rides App**
- Manages ride information and categories
- Tracks detailed roller coaster statistics
- Links rides to parks, manufacturers, and designers
3. **Companies App**
- Handles park ownership information
- Manages ride manufacturers
- Tracks company statistics and history
4. **Designers App**
- Manages ride designer/engineering firm information
- Tracks designer contributions and history
5. **Media App**
- Handles photo uploads and management
- Supports generic relationships for photos
- Manages media storage and organization
6. **Reviews App**
- Manages user reviews and ratings
- Handles review moderation
- Supports review images and likes
7. **Analytics App**
- Tracks page views and user interactions
- Identifies trending content
- Provides analytics data for the platform
### Authentication & User Management
- Custom user model through accounts app
- Social authentication support (Google, Discord)
- User profiles and settings management
## Data Models
### Park Models
```python
class Park:
- name, slug, description
- status (Operating, Closed, etc.)
- location (latitude, longitude, address)
- operating details (season, dates)
- statistics (total rides, coasters)
- ownership information
```
### Ride Models
```python
class Ride:
- name, slug, description
- category (Roller Coaster, Dark Ride, etc.)
- status and operating dates
- manufacturer and designer links
- park and area location
- accessibility and capacity info
class RollerCoasterStats:
- height, length, speed metrics
- track type and materials
- launch system details
- train configuration
```
### Company Models
```python
class Company:
- name, slug, description
- headquarters and contact info
- park ownership tracking
- historical records
class Manufacturer:
- name, slug, description
- ride production statistics
- historical records
```
### Media Management
```python
class Photo:
- Generic relationship to content
- Image storage and organization
- Caption and metadata
- Upload tracking
```
### Review System
```python
class Review:
- Generic relationship to content
- Rating and content
- Moderation support
- Image attachments
- Like/report functionality
```
### Analytics
```python
class PageView:
- Content tracking
- Timestamp and user info
- Trending content calculation
```
## Key Features
### Content Management
- Comprehensive park and ride information
- Historical tracking of all content changes
- Rich media support with photo management
- Detailed statistics and specifications
### User Interaction
- User reviews and ratings
- Photo uploads and sharing
- Content moderation system
- Social features (likes, reports)
### Analytics and Trending
- Page view tracking
- Trending content identification
- Usage statistics and metrics
### Location Features
- Geographic coordinates
- Address management
- Park area organization
## Technical Implementation
### Database Design
- PostgreSQL database
- Generic relations for flexible content relationships
- Comprehensive indexing for performance
- Historical record tracking
### Authentication
- Django allauth integration
- Multiple social auth providers
- Custom user model and authentication flow
### Media Handling
- Custom storage backend
- Organized file structure
- Automatic file naming and organization
### Performance Features
- Caching configuration
- Database query optimization
- Efficient media handling
### Security Features
- CSRF protection
- Secure authentication
- Content moderation
- User input validation
## Management Commands
### Analytics
- `update_trending.py`: Updates trending content calculations
### Parks
- `update_park_counts.py`: Updates park statistics and ride counts
## Frontend Integration
### Templates
- Organized template structure
- Partial templates for reusability
- Photo gallery integration
### Static Files
- CSS with Tailwind integration
- JavaScript for interactive features
- Photo gallery functionality
## Development Guidelines
### Code Organization
- Modular app structure
- Clear separation of concerns
- Consistent naming conventions
### Best Practices
- Generic relations for flexibility
- Historical tracking for all major models
- Comprehensive validation
- Efficient query patterns
### Security Considerations
- Secure content storage
- User permission management
- Input validation and sanitization
- Protected user data
## Deployment Considerations
### Environment Configuration
- Environment-specific settings
- Secure key management
- Database configuration
### Media Storage
- Organized upload structure
- Efficient file handling
- Backup considerations
### Performance Optimization
- Caching strategy
- Database indexing
- Query optimization
## Future Considerations
### Scalability
- Database optimization opportunities
- Caching improvements
- Media handling optimization
### Feature Expansion
- Additional social features
- Enhanced analytics
- Mobile app integration possibilities
### Integration Opportunities
- API development
- Third-party service integration
- Mobile app support

View File

@@ -1,153 +0,0 @@
# ThrillWiki Quick Start Guide
## Prerequisites
- Python 3.8+
- PostgreSQL
- Node.js (for Tailwind CSS)
## Setup Instructions
1. **Clone the Repository**
```bash
git clone <repository-url>
cd thrillwiki
```
2. **Create Virtual Environment**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install Dependencies**
```bash
pip install -r requirements.txt
```
4. **Database Setup**
```bash
# Update database settings in thrillwiki/settings.py
python manage.py migrate
```
5. **Create Superuser**
```bash
python manage.py createsuperuser
```
6. **Install Frontend Dependencies**
```bash
# Install Tailwind CSS
npm install
```
7. **Environment Configuration**
- Copy example environment file
- Update necessary settings
- Configure social auth providers
8. **Run Development Server**
```bash
python manage.py runserver
```
## Key URLs
- Admin Interface: `/admin/`
- Home Page: `/`
- Parks List: `/parks/`
- Rides List: `/rides/`
## Development Guidelines
1. **Model Changes**
```bash
python manage.py makemigrations
python manage.py migrate
```
2. **Running Tests**
```bash
python manage.py test
```
3. **Update Trending Content**
```bash
python manage.py update_trending
```
4. **Update Park Statistics**
```bash
python manage.py update_park_counts
```
## Common Tasks
### Adding a New Park
1. Access admin interface
2. Navigate to Parks section
3. Click "Add Park"
4. Fill required information
5. Save
### Adding a New Ride
1. Access admin interface
2. Navigate to Rides section
3. Click "Add Ride"
4. Fill required information
5. Add roller coaster stats if applicable
6. Save
### Managing Photos
1. Photos can be added to parks, rides, or companies
2. Use the photo upload form on respective detail pages
3. Set primary photo as needed
### Moderating Reviews
1. Access admin interface
2. Navigate to Reviews section
3. Review flagged content
4. Take appropriate moderation action
## Troubleshooting
### Common Issues
1. **Database Connection**
- Verify PostgreSQL is running
- Check database credentials
- Ensure database exists
2. **Media Upload Issues**
- Check file permissions
- Verify media storage configuration
- Ensure proper file types
3. **Social Auth**
- Verify provider credentials
- Check callback URLs
- Review auth settings
### Getting Help
- Check existing documentation in `/docs`
- Review error logs
- Contact development team
## Best Practices
1. **Code Style**
- Follow PEP 8
- Use type hints
- Document functions and classes
2. **Git Workflow**
- Create feature branches
- Write descriptive commits
- Keep changes focused
3. **Testing**
- Write unit tests
- Test all new features
- Verify existing functionality

View File

@@ -1,96 +0,0 @@
# Search Integration Plan
## 1. File Structure
```plaintext
core/
├── views/
│ └── search.py # Search views implementation
├── utils/
│ └── search.py # Search utilities
templates/
└── core/
└── search/ # Search templates
├── results.html
├── filters.html
└── ...
```
## 2. View Migration
- Move `search/views.py``core/views/search.py`
- Update view references:
```python
# Old: from search.views import AdaptiveSearchView
# New:
from core.views.search import AdaptiveSearchView, FilterFormView
```
## 3. URL Configuration Updates
Update `thrillwiki/urls.py`:
```python
# Before:
path("search/", include("search.urls", namespace="search"))
# After:
path("search/", include("core.urls.search", namespace="search"))
```
Create `core/urls/search.py`:
```python
from django.urls import path
from core.views.search import AdaptiveSearchView, FilterFormView
from rides.views import RideSearchView
urlpatterns = [
path('parks/', AdaptiveSearchView.as_view(), name='search'),
path('parks/filters/', FilterFormView.as_view(), name='filter_form'),
path('rides/', RideSearchView.as_view(), name='ride_search'),
path('rides/results/', RideSearchView.as_view(), name='ride_search_results'),
]
```
## 4. Import Cleanup Strategy
1. Update all imports:
```python
# Before:
from search.views import ...
from search.utils import ...
# After:
from core.views.search import ...
from core.utils.search import ...
```
2. Remove old search app:
```bash
rm -rf search/
```
3. Update `INSTALLED_APPS` in `thrillwiki/settings.py`:
```python
# Remove 'search' from INSTALLED_APPS
INSTALLED_APPS = [
# ...
# 'search', # REMOVE THIS LINE
# ...
]
```
## 5. Implementation Steps
1. Create new directory structure in core
2. Move view logic to `core/views/search.py`
3. Create URL config in `core/urls/search.py`
4. Move templates to `templates/core/search/`
5. Update all import references
6. Remove old search app
7. Test all search functionality:
- Park search filters
- Ride search
- HTMX filter updates
8. Verify URL routes
## 6. Verification Checklist
- [ ] All search endpoints respond with 200
- [ ] Filter forms render correctly
- [ ] HTMX updates work as expected
- [ ] No references to old search app in codebase
- [ ] Templates render with correct context

View File

@@ -1,77 +0,0 @@
# ThrillWiki Technical Architecture
```
┌─────────────────────────────────────────────────────────────┐
│ ThrillWiki Platform │
├─────────────────┬─────────────────────┬───────────────────┤
│ Frontend Layer │ Application Layer │ Storage Layer │
├─────────────────┤ │ │
│ - Templates │ Django Apps │ - PostgreSQL DB │
│ - Tailwind CSS │ ┌──────────┐ │ - Media Storage │
│ - JavaScript │ │ Parks │ │ - Static Files │
│ │ │ Rides │ │ │
│ Components │ │Companies │ │ │
│ - Photo Gallery │ │Designers │ │ │
│ - Review Forms │ └──────────┘ │ │
│ │ │ │
├─────────────────┼─────────────────────┼───────────────────┤
│ Auth Layer │ Service Layer │ Analytics Layer │
├─────────────────┤ │ │
│ - Django Auth │ Core Services │ - Page Tracking │
│ - Social Auth │ ┌──────────┐ │ - Trending Calc │
│ - Permissions │ │ Reviews │ │ - Usage Stats │
│ │ │ Media │ │ │
│ │ │Analytics │ │ │
│ │ └──────────┘ │ │
└─────────────────┴─────────────────────┴───────────────────┘
Data Flow:
User Request → URL Router → View → Model → Database
Template → Response
Content Relations:
Park ──┬── Areas
└── Rides ─┬── Manufacturer
└── Designer
Media Storage:
Content ─→ Generic Relation ─→ Photos
Analytics Flow:
Page View → Tracking → Trending Calculation
```
## Key Components
1. **Frontend Layer**
- Template-based rendering
- Tailwind CSS styling
- JavaScript enhancements
- Interactive components
2. **Application Layer**
- Core domain apps
- Business logic
- Data validation
- Content management
3. **Storage Layer**
- Database persistence
- Media file storage
- Caching system
4. **Authentication Layer**
- User management
- Social authentication
- Permission control
5. **Service Layer**
- Review system
- Media handling
- Email services
6. **Analytics Layer**
- View tracking
- Trend analysis
- Usage statistics