RTSDA-Website/CLAUDE.md
Benjamin Slingo 1013ca0870 Remove admin event creation - force submission form workflow
Streamline admin panel to only handle pending event approvals:
- Remove create_admin_event functions from Rust core
- Remove createAdminEventJson from API bindings
- Update events admin page to focus on pending approvals only
- Maintain edit/delete for approved events via main collection

Enforces cleaner workflow: Submit → Approve → Auto-move to events collection
2025-08-28 22:14:17 -04:00

3.7 KiB

CLAUDE INSTRUCTIONS - RTSDA CODEBASE

CRITICAL ARCHITECTURE UNDERSTANDING

ASTRO IS A THIN UI LAYER ONLY

  • Astro handles routing, SSR, and basic UI rendering
  • NO BUSINESS LOGIC IN FRONTEND
  • NO DIRECT API CALLS FROM FRONTEND
  • ALL LOGIC GOES THROUGH church-core RUST CRATE

THE RUST CRATE IS THE CORE FOR A FUCKING REASON

  • church-core/ contains ALL business logic
  • church-core/ handles ALL API communication
  • church-core/ provides unified data models
  • church-core/ has caching, error handling, auth
  • USE THE RUST CRATE, DON'T BYPASS IT

FIXED VIOLATIONS

Admin Panel (COMPLETED )

  • public/admin/scripts/main.js - 1800+ lines of vanilla JS REMOVED
  • NOW: Proper Astro routes using Rust functions via FFI bindings
  • FIXED: Frontend now follows core architecture

REMAINING VIOLATIONS TO FIX

Event Submission Direct API Call

  • src/pages/events/submit.astro:748 - Still uses direct fetch() call
  • SHOULD BE: Use submitEventJson() from bindings.js
  • VIOLATION: Bypassing the unified client architecture

Data Model Mismatches

  • Frontend expects detailed Schedule fields (song_leader, childrens_story)
  • Backend Rust models missing these fields
  • CAUSE: Frontend developed independently of core models

CORRECT ARCHITECTURE FLOW

Frontend (Astro) → bindings.js → Rust FFI → church-core → API

NOT:

Frontend → fetch() → API directly

HOW TO FIX VIOLATIONS

For Event Submission:

  1. Admin functions already exist in church-core/src/client/admin.rs
  2. Already exposed via FFI in church-core/src/api.rs
  3. Already imported in astro-church-website/src/lib/bindings.js
  4. TODO: Replace fetch() call with submitEventJson() function

For Data Models:

  1. Update Schedule models in church-core/src/models/admin.rs
  2. Add missing fields (song_leader, childrens_story, etc.)
  3. Regenerate FFI bindings
  4. Update frontend to use new model structure

COMMANDS TO REMEMBER

Build Commands:

# Build Rust bindings FIRST
npm run build:native

# Then build Astro
npm run build

# Dev server
npm run dev

Testing Commands:

# Test Rust core
cd church-core && cargo test

# Test API connectivity  
cd church-core && cargo run --bin church-core-test

BEFORE MAKING CHANGES

  1. Check if Rust function exists in church-core/
  2. If missing, ADD IT TO RUST FIRST
  3. Then expose via FFI bindings
  4. Finally update frontend to use it

DO NOT:

  • Add business logic to JavaScript
  • Make direct API calls from frontend
  • Create data models in frontend
  • Bypass the Rust crate architecture

THE RUST CRATE EXISTS FOR:

  • Cross-platform consistency (iOS, Android, Web)
  • Type safety and error handling
  • Unified caching and auth
  • Single source of truth for API communication

RESPECT THE ARCHITECTURE. USE THE RUST CRATE.

CLEANUP PROGRESS TRACKING

COMPLETED (Aug 29, 2025)

  • Admin Panel Conversion: Removed 1843-line vanilla JS file
  • Proper Astro Routes: Created TypeScript admin routes using Rust functions
  • Thumbnail Field Removal: Cleaned up event submission form
  • FFI Functions: Added 12 new admin functions in church-core
  • Architecture Compliance: Admin panel now follows correct flow

Commit: f91f696 - Convert admin panel to Astro routes and remove thumbnail field

🚨 HIGH PRIORITY NEXT

  1. Fix event submission direct API call (src/pages/events/submit.astro:748)
  2. Check Schedule model data field mismatches
  3. Add missing admin functions (stats, config, users)

See: /NEXT-STEPS.md for detailed implementation plan