Commit graph

27 commits

Author SHA1 Message Date
Benjamin Slingo cabf8aa83d Remove legacy batch transcoding infrastructure
- Remove TranscodedMedia, TranscodingStatus, and TranscodingRequest models
- Delete 184-line commented stream_media function
- Clean up phantom service imports and dead references
- Remove unused test imports for non-existent services

Total cleanup: 265 lines of dead code removed from legacy Jellyfin compatibility layer.
Smart streaming pipeline remains unchanged and functional.
2025-09-08 12:31:17 -04:00
Benjamin Slingo c607aa135c Fix datetime parsing bug in event submission
- Fix timezone detection logic to only consider dashes after 'T' as timezone indicators
- Reorder multipart datetime parsing to try flexible formats before strict RFC3339
- Resolves 400 "Invalid RFC3339 datetime" error for format like "2025-10-07T00:13"
- Event submissions now work correctly with local church time format
2025-09-08 00:18:47 -04:00
Benjamin Slingo 4899c3829c Complete major performance optimizations: eliminate N+1 patterns and memory pagination
- Add event categories config endpoint (/api/config/event-categories)
- Fix bulletin processing N+1: batch hymn lookups for single bulletins
- Optimize V2 events list endpoint: replace memory pagination with database LIMIT/OFFSET
- Add missing SQL functions: list_events_paginated() and count_events()
- Preserve HTTP response compatibility for iOS app
2025-09-07 22:33:23 -04:00
Benjamin Slingo 8728e14125 Optimize N+1 queries and fix missing event update endpoint
Performance optimizations:
- Fix media items N+1: batch scripture reading lookups (1+N → 2 queries)
- Fix hymnal thematic lists N+1: batch ambits queries (1+N → 2 queries)
- Add batch query functions for bulletins and hymnal ambits

Bug fix:
- Add missing PUT /api/admin/events/:id endpoint for event updates
- Connect existing EventsV1Service::update method to web layer

Database performance significantly improved for high-traffic endpoints
used by website, iOS app, and LuminaLP integrations.
2025-09-07 21:55:49 -04:00
Benjamin Slingo 73c1b416ee Fix N+1 query performance issue in schedule list endpoint
Replace inefficient loop with N database queries (1 + N schedules) with
optimized single query approach. Reduces database load and improves
response times for /api/schedule endpoint when fetching all schedules.

- Add ScheduleService::list_all_schedule_data_v1() method for single query
- Update handler to use optimized method instead of per-schedule queries
- Maintains identical API response format
- Scales better as schedule data grows
2025-09-07 21:26:45 -04:00
Benjamin Slingo e206ce3332 Add quarterlies management system with complete CRUD operations
- New quarterly_orders table with validation and constraints
- Full CRUD API endpoints for quarterly orders management
- Import functionality for bulk quarterly data from JSON
- Python scripts for data migration and database import
- Consistent validation for quarterly types and amounts
- Follows established DRY/KISS architectural patterns
2025-09-06 16:53:14 -04:00
Benjamin Slingo adacf443e5 Add config update endpoint for admin panel
- Add update_config handler in config.rs (6 lines)
- Add PUT /config route in main.rs (1 line)
- Enables admin panel to update church configuration
- Follows existing DRY/KISS architecture patterns
2025-08-30 11:50:21 -04:00
Benjamin Slingo 72a776b431 Complete DRY/KISS architecture refactoring: eliminate SQL duplication and standardize patterns
- SQL Layer Separation: Remove all SQL queries from service layers, achieving perfect Handler→Service→SQL architecture
- Response Standardization: Replace manual ApiResponse construction with helper functions (success_response, success_with_message, success_message_only)
- Sanitization Centralization: Create SanitizeDescription trait to eliminate HTML sanitization duplication across services
- Code Reduction: Delete 1,340 lines of duplicated code while adding 405 lines of clean infrastructure
- Zero Breaking Changes: All API contracts preserved, only internal architecture improved
- Enhanced Security: Automatic response sanitization via SanitizeOutput trait

Created SQL modules:
- src/sql/config.rs: Church configuration operations
- src/sql/media.rs: Media scanning and metadata operations

Refactored services:
- EventsV1Service: Use sql::events module, centralized sanitization
- PendingEventsService: Use sql::events module, centralized sanitization
- ConfigService: Use sql::config module
- MediaScannerService: Use sql::media module
- HymnalService: Simplified complex search query from 200+ to 20 lines

Standardized handlers:
- All handlers now use response helper functions
- Consistent error handling patterns
- Preserved exact JSON response format for frontend compatibility

Result: Perfect DRY/KISS compliance with zero API surface changes
2025-08-30 11:25:01 -04:00
Benjamin Slingo ed72011f16 Phase 3 complete: EventService restructuring achieves maximum DRY/KISS compliance
RESTRUCTURING ACCOMPLISHED:
• Split monolithic EventService into focused services (EventsV1Service, EventsV2Service, PendingEventsService)
• Migrated ALL remaining direct SQL to shared sql::events functions
• Updated all handlers to use appropriate focused services
• Removed obsolete EventService completely

CONSISTENCY FIXES:
• ScheduleService: migrated to sql::schedule pattern (eliminated all direct SQL)
• HymnalService: fixed DRY/KISS violations using sql::hymnal for CRUD operations
• AuthService: ensured consistent sql::users usage

RESULT: All major services now follow Handler→Service→sql:: pattern consistently.
No more direct SQL violations. No more debugging nightmare inconsistencies.
Zero downtime maintained - HTTP responses unchanged.
2025-08-29 22:37:26 -04:00
Benjamin Slingo fafbde3eb2 Document Phase 3 roadmap: EventService restructuring for maximum DRY/KISS compliance
PHASE 3 ANALYSIS COMPLETE:
• Identified EventService complexity: 16 SQL queries across V1/V2/Pending domains
• Discovered major simplification opportunity through service splitting
• Planned shared sql:: functions approach to eliminate V1/V2 SQL duplication

NEXT SESSION STRATEGY:
1. Split EventService → EventsV1Service + EventsV2Service + PendingEventsService
2. Extract shared sql::events utilities (16 queries → 6-8 shared functions)
3. Complete ScheduleService migration using same principle

ARCHITECTURAL BENEFITS:
 Zero risk: V1/V2 isolation prevents cross-version bugs
 Massive simplification: Shared SQL utilities eliminate duplication
 Better testing: SQL logic separate from business logic
 Safer maintenance: Fix once, benefit all API versions

Foundation: sql:: module ecosystem established and ready for clean refactoring
2025-08-29 10:25:32 -04:00
Benjamin Slingo e48015d946 Phase 3 foundation: establish sql:: module ecosystem for consistency
SQL MODULE INFRASTRUCTURE:
• Created 3 new sql:: modules: users, schedule, events
• Expanded existing sql:: module system to 8 total modules
• Updated sql/mod.rs with complete module organization
• Established consistent sql:: → direct SQL pattern

NEW SQL MODULES:
• src/sql/users.rs: User auth operations + UserWithPassword struct
• src/sql/schedule.rs: Schedule, offering, sunset SQL utilities
• src/sql/events.rs: Event lifecycle operations (enhanced from basic version)

PARTIAL SERVICE MIGRATIONS:
• AuthService: Successfully migrated to use sql::users (COMPLETE)
• EventService: Partial migration - 3/16 SQL queries moved to sql::events
• ScheduleService: Prepared sql::schedule module, migration pending

ARCHITECTURE FOUNDATION:
Before: Mixed patterns (some sql::, some direct SQL - inconsistent)
After:  Foundation for Handler → Service → sql:: → Direct SQL (consistent)

DISCOVERY: EventService complexity issue identified
- 16 SQL queries across V1/V2 APIs, pending events, pagination
- Violates single responsibility principle
- Needs refactoring: split into EventsV1Service, EventsV2Service, PendingEventsService

NEXT SESSION PLAN:
1. Restructure EventService into focused services (V1/V2/Pending separation)
2. Complete sql:: migrations with cleaner, smaller services
3. Achieve full Handler→Service→sql:: consistency across codebase

Benefits: Solid sql:: foundation established, AuthService fully migrated,
architectural pattern proven, cleaner refactoring path identified
2025-08-29 10:22:07 -04:00
Benjamin Slingo 7f90bae5cd Phase 2 complete: eliminate db:: anti-pattern, achieve Handler→Service→SQL consistency
MAJOR ARCHITECTURAL CLEANUP:
• Removed entire src/db/ module (6 files, 300+ lines of pointless wrapper code)
• Migrated all handlers to proper Handler → Service → SQL pattern
• Created shared sql:: utilities replacing db:: wrappers
• Eliminated intermediate abstraction layer violating DRY/KISS principles

SERVICE LAYER STANDARDIZATION:
• ContactService: Added proper business logic layer for contact form submissions
• Updated contact handler to use ContactService instead of direct db::contact calls
• Fixed refactored handlers to use proper BulletinService methods
• All services now follow consistent architecture pattern

SQL UTILITIES CREATED:
• src/sql/events.rs: Shared SQL functions for event operations
• src/sql/contact.rs: Shared SQL functions for contact submissions
• Updated sql/mod.rs to include new modules

HANDLER MIGRATIONS:
• handlers/contact.rs: db::contact → ContactService calls
• handlers/v2/events.rs: db::events → sql::events calls
• handlers/refactored_events.rs: db::events → sql::events calls
• handlers/bulletins_refactored.rs: db::bulletins → BulletinService calls

ARCHITECTURE ACHIEVEMENT:
Before: Handler → Service → db::* wrappers → SQL (anti-pattern)
After:  Handler → Service → sql::* utilities → Direct SQL (clean)

BENEFITS: 70% reduction in abstraction layers, consistent DRY/KISS compliance,
improved maintainability, centralized business logic, eliminated code duplication

Compilation:  All tests pass, only unused import warnings remain
Next: Phase 3 - SQL Layer Consolidation for remaining modules
2025-08-29 09:53:58 -04:00
Benjamin Slingo 2a5a34a9ed Phase 1 complete: standardize handler layer DRY/KISS patterns
- Eliminate manual ApiResponse construction in 5 handlers
- Add MemberService + sql::members following established pattern
- Create success_message_only() utility for empty responses
- Fix members handler: db::members direct calls → service layer
- Add SanitizeOutput for LoginResponse trait consistency
- All examined handlers now follow Handler → Service → SQL pattern
2025-08-29 09:38:06 -04:00
Benjamin Slingo 24d389cdf0 Initial cleanup: remove backup files, fix major hymnal KISS violation
- Remove 13 backup/unused files cluttering src/
- Fix hymnal search: 200+ line complex SQL → shared sql::hymnal functions
- Fix DRY violation: duplicate bulletin lookup in media handler
- Add systematic 5-phase cleanup plan for remaining violations
- Note: This is just initial cleanup - significant DRY/KISS work remains
2025-08-29 09:23:07 -04:00
Benjamin Slingo 6bee94c311 Apply DRY/KISS: Replace db wrapper layer with shared SQL functions
- Create sql:: module with raw SQL queries (no business logic)
- Services now call sql:: functions + handle conversion logic only
- Eliminate SQL duplication across V1/V2 service methods
- Remove redundant db:: wrapper functions for bulletins, bible_verses, schedule
- Clean Handler → Service → Shared SQL → DB architecture
- Maintain API compatibility, zero downtime
2025-08-29 09:02:05 -04:00
Benjamin Slingo ef7e077ae2 Refactor EventService: eliminate duplication, apply DRY/KISS principles
BREAKING: Removed CreateEventRequest - unused for direct creation
ADDED: UpdateEventRequest - clean editing with image support
IMPROVED: EventService now contains business logic, not wrapper calls

Architecture Changes:
- Before: Handler → Service → db::events → SQL (wasteful)
- After:  Handler → Service → Direct SQL + Business Logic (clean)

Key Improvements:
 All EventService methods use direct SQL with real business logic
 Eliminated pointless db::events wrapper functions
 Added missing V2 service methods for consistency
 Fixed handler pattern violations (no more direct db calls)
 Preserved email notifications and HTTP response formats
 Applied sanitization, validation, error handling in services

Changes:
- Remove CreateEventRequest/V2 (unused create paths)
- Add UpdateEventRequest with image field (no redundant thumbnail)
- Migrate all EventService methods to direct SQL + business logic
- Fix v2/events.rs to use proper service methods consistently
- Remove create/update routes and handlers (unused)
- Maintain backward compatibility for all APIs

Next: Apply same DRY/KISS cleanup to BulletinService and others
2025-08-28 22:42:45 -04:00
Benjamin Slingo b55b9f0abe Step 3-4: Rewrite db/bulletins.rs with pure SQL + fix BulletinService
- Complete rewrite of db/bulletins.rs using direct SQL queries only
- Remove all dependencies on dead *Operations patterns
- Enhanced error handling with specific error types (bulletin_not_found, duplicate_entry)
- Fix BulletinService to call db::bulletins:: directly instead of dead BulletinOperations
- Clean SQL with proper logging and error context
- Part of nuclear consolidation to Handler → Service → DB pattern
2025-08-28 21:41:01 -04:00
Benjamin Slingo da06dae89d NUCLEAR: Delete db_operations.rs entirely
- Remove entire utils/db_operations.rs file and all *Operations patterns
- Comment out imports to dead operations
- This breaks compilation temporarily but eliminates the maintenance nightmare
- Next: rewrite db:: modules to use direct SQL instead of operations
- Goal: Clean Handler → Service → Database pattern only
2025-08-28 21:36:14 -04:00
Benjamin Slingo e2ab29505a Phase 1.5: Migrate main events handler to service layer only
- Remove all direct db:: calls from events.rs handler
- Add missing get_pending_by_id method to EventService
- Use specific error types (ApiError::event_not_found)
- Clean handler → service → database pattern
- First step in eliminating maintenance nightmare of multiple DB patterns
2025-08-28 21:34:03 -04:00
Benjamin Slingo e0fffbc4b9 Phase 1.4: Enhanced input validation system
- Add comprehensive validation methods for dates, UUIDs, ranges, files
- Domain-specific validation functions for bulletins, events, hymnal search
- Enhanced recurring pattern validation with specific error types
- Better date range validation with improved error messages
- Foundation for consistent input validation across all endpoints
- All using new specific error types for better debugging
2025-08-28 21:25:36 -04:00
Benjamin Slingo ad43a19f7c Phase 1: Enhance error handling and database operations
- Add specific error variants for better internal handling
- Enhance error messages with context and logging
- Improve database operations with better error handling
- Use specific errors for media processing, config issues, duplicates
- All HTTP responses remain identical - zero breaking changes
- Foundation for better maintainability and debugging
2025-08-28 21:20:29 -04:00
Benjamin Slingo 5793e12df9 Add comprehensive hymnal support and enhance bulletin processing
- Add complete hymnal API with search, themes, and responsive readings
- Implement hymn title lookup for bulletins (#319#319 - Hymn Title)
- Add Bible book abbreviation support (Matt → Matthew, etc.)
- Enhance scripture processing to handle verse ranges (Matt 1:21-23)
- Add hymnal database schema with SDA 1985 and 1941 hymnals support
- Implement advanced hymnal search with fuzzy matching and themes
- Update bulletin processing to auto-populate hymn titles from database
2025-08-28 20:34:04 -04:00
Benjamin Slingo 916a54caa2 Add missing event thumbnail upload endpoint
- Fixed 502 error when uploading thumbnails via admin panel
- Added /api/upload/events/:id/thumbnail route and handler
- Thumbnails saved with thumb_ prefix for organization
- Includes proper file cleanup when replacing existing thumbnails
- Resolves CORS issues by ensuring endpoint exists for proper middleware handling
2025-08-23 11:29:44 -04:00
Benjamin Slingo 17aeb7d55e Add proper README and remove development documentation files
- Created comprehensive README.md with setup instructions and API overview
- Removed 10 internal development .md files
- Updated .gitignore to prevent future development docs from being tracked
- Repository now has clean, professional documentation structure
2025-08-19 21:01:55 -04:00
Benjamin Slingo 7ab47d6017 Clean up repository: remove shell scripts, test files, and temporary utilities
- Removed all .fish and .sh utility scripts
- Removed test SQL files and debug scripts
- Removed temp files and symlinks
- Removed HTML test files and Python migration helpers
- Updated .gitignore to prevent these files from being tracked again

Repository now contains only essential project code and migrations.
2025-08-19 21:00:09 -04:00
Benjamin Slingo b150e08163 Remove .serena folder from tracking and add to .gitignore 2025-08-19 20:57:56 -04:00
Benjamin Slingo 0c06e159bb Initial commit: Church API Rust implementation
Complete church management system with bulletin management, media processing, live streaming integration, and web interface. Includes authentication, email notifications, database migrations, and comprehensive test suite.
2025-08-19 20:56:41 -04:00