Enhance documentation and management commands for ThrillWiki

- Updated backend README.md to include detailed management commands for configuration, database operations, cache management, data management, user authentication, content/media handling, trending/discovery, testing/development, and security/auditing.
- Added a new MANAGEMENT_COMMANDS.md file for comprehensive command reference.
- Included logging standardization details in architecture documentation (ADR-007).
- Improved production checklist with configuration validation and cache verification steps.
- Expanded API documentation to include error logging details.
- Created a documentation review checklist to ensure completeness and accuracy.
This commit is contained in:
pacnpal
2025-12-23 21:28:14 -05:00
parent edcd8f2076
commit ca770d76ff
10 changed files with 1649 additions and 13 deletions

View File

@@ -288,27 +288,222 @@ uv run manage.py test backend.tests.accessibility
## Management Commands
ThrillWiki provides numerous management commands for development, deployment, and maintenance.
### Configuration & Validation
```bash
# Database operations
# Validate all settings and environment variables
uv run manage.py validate_settings
uv run manage.py validate_settings --strict # Treat warnings as errors
uv run manage.py validate_settings --json # JSON output
uv run manage.py validate_settings --secrets-only # Only validate secrets
# Validate state machine configurations
uv run manage.py validate_state_machines
# List all FSM transition callbacks
uv run manage.py list_transition_callbacks
```
### Database Operations
```bash
# Standard Django commands
uv run manage.py migrate
uv run manage.py makemigrations
uv run manage.py createsuperuser
uv run manage.py showmigrations
uv run manage.py createsuperuser
# Static files
uv run manage.py collectstatic
# Fix migration history issues
uv run manage.py fix_migrations
uv run manage.py fix_migration_history
# Configuration validation
uv run manage.py validate_settings
# Cache management
uv run manage.py warm_cache
# Data management
uv run manage.py import_parks data/parks.json
uv run manage.py generate_test_data
# Reset database (DESTRUCTIVE - development only)
uv run manage.py reset_db
```
### Cache Management
```bash
# Warm cache with frequently accessed data
uv run manage.py warm_cache
uv run manage.py warm_cache --parks-only
uv run manage.py warm_cache --rides-only
uv run manage.py warm_cache --metadata-only
uv run manage.py warm_cache --dry-run # Preview without caching
# Clear all caches
uv run manage.py clear_cache
```
### Data Management
```bash
# Seed initial data (operators, manufacturers, etc.)
uv run manage.py seed_initial_data
# Create sample data for development
uv run manage.py create_sample_data
uv run manage.py create_sample_data --minimal # Quick setup
uv run manage.py create_sample_data --clear # Clear existing first
# Seed sample parks and rides
uv run manage.py seed_sample_data
# Seed test submissions for moderation
uv run manage.py seed_submissions
# Seed API test data
uv run manage.py seed_data
# Update park statistics (ride counts, ratings)
uv run manage.py update_park_counts
# Update ride rankings
uv run manage.py update_ride_rankings
```
### User & Authentication
```bash
# Create test users
uv run manage.py create_test_users
# Delete user and all related data
uv run manage.py delete_user <username>
# Setup user groups and permissions
uv run manage.py setup_groups
# Setup Django sites framework
uv run manage.py setup_site
# Social authentication setup
uv run manage.py setup_social_auth
uv run manage.py setup_social_providers
uv run manage.py create_social_apps
uv run manage.py check_social_apps
uv run manage.py fix_social_apps
uv run manage.py reset_social_apps
uv run manage.py reset_social_auth
uv run manage.py cleanup_social_auth
uv run manage.py update_social_apps_sites
uv run manage.py verify_discord_settings
uv run manage.py test_discord_auth
uv run manage.py check_all_social_tables
uv run manage.py setup_social_auth_admin
# Avatar management
uv run manage.py generate_letter_avatars
uv run manage.py regenerate_avatars
```
### Content & Media
```bash
# Static file management
uv run manage.py collectstatic
uv run manage.py optimize_static # Minify and compress
# Media file management (in shared/media/)
uv run manage.py download_photos
uv run manage.py move_photos
uv run manage.py fix_photo_paths
```
### Trending & Discovery
```bash
# Calculate trending content
uv run manage.py calculate_trending
uv run manage.py update_trending
uv run manage.py test_trending
# Calculate new content for discovery
uv run manage.py calculate_new_content
```
### Testing & Development
```bash
# Run development server with auto-reload
uv run manage.py rundev
# Setup development environment
uv run manage.py setup_dev
# Test location services
uv run manage.py test_location
# Test FSM transition callbacks
uv run manage.py test_transition_callbacks
# Analyze FSM transitions
uv run manage.py analyze_transitions
# Cleanup test data
uv run manage.py cleanup_test_data
```
### Security & Auditing
```bash
# Run security audit
uv run manage.py security_audit
```
### Command Categories
| Category | Commands |
|----------|----------|
| **Configuration** | validate_settings, validate_state_machines, list_transition_callbacks |
| **Database** | migrate, makemigrations, reset_db, fix_migrations |
| **Cache** | warm_cache, clear_cache |
| **Data** | seed_initial_data, create_sample_data, update_park_counts, update_ride_rankings |
| **Users** | create_test_users, delete_user, setup_groups, setup_social_auth |
| **Media** | collectstatic, optimize_static, download_photos, move_photos |
| **Trending** | calculate_trending, update_trending, calculate_new_content |
| **Development** | rundev, setup_dev, test_location, cleanup_test_data |
| **Security** | security_audit |
### Common Workflows
#### Initial Setup
```bash
uv run manage.py migrate
uv run manage.py createsuperuser
uv run manage.py setup_groups
uv run manage.py seed_initial_data
uv run manage.py create_sample_data --minimal
uv run manage.py warm_cache
```
#### Development Reset
```bash
uv run manage.py reset_db
uv run manage.py migrate
uv run manage.py create_sample_data
uv run manage.py warm_cache
```
#### Production Deployment
```bash
uv run manage.py migrate
uv run manage.py collectstatic --noinput
uv run manage.py validate_settings --strict
uv run manage.py warm_cache
```
#### Cache Refresh
```bash
uv run manage.py clear_cache
uv run manage.py warm_cache
uv run manage.py calculate_trending
```
See [Management Commands Reference](../docs/MANAGEMENT_COMMANDS.md) for complete documentation.
## Database
### Entity Relationships