![]() 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
|
||
---|---|---|
migrations | ||
src | ||
tests | ||
.env.example | ||
.gitignore | ||
build.rs | ||
Cargo.toml | ||
cleanup_manual_hymn_titles.sql | ||
CLEANUP_PROGRESS.md | ||
find_manual_hymn_titles.sql | ||
fix_timezone_double_conversion.sql | ||
HYMNARIUM_API_DOCUMENTATION.md | ||
LICENSE | ||
migrate_hymnal_data.py | ||
README.md | ||
simple_hymn_cleanup.sql |
Church API
A comprehensive church management system built with Rust and Axum, providing REST APIs for bulletin management, event scheduling, media processing, and live streaming integration.
Features
- Bulletin Management: Upload, process, and serve church bulletins with automatic format conversion
- Event Scheduling: Create and manage church events with recurring event support
- Media Processing: Handle video uploads with transcoding and thumbnail generation
- Live Streaming: Integration with Owncast for live stream management
- User Authentication: JWT-based authentication with role-based access control
- Email Notifications: SMTP integration for automated notifications
- Database Management: PostgreSQL with automated migrations
Tech Stack
- Backend: Rust with Axum web framework
- Database: PostgreSQL with SQLx
- Media Processing: GStreamer for video transcoding
- Authentication: JWT with bcrypt password hashing
- Email: lettre for SMTP integration
Quick Start
-
Prerequisites
- Rust 1.70+
- PostgreSQL 13+
- GStreamer development libraries
-
Setup
# Clone the repository git clone ssh://rockvilleav@git.rockvilletollandsda.church:10443/RTSDA/church-api.git cd church-api # Copy environment template cp .env.example .env # Edit .env with your configuration # Run database migrations sqlx migrate run # Build and run cargo run
-
Configuration
Edit
.env
with your settings:- Database URL
- JWT secret
- SMTP configuration
- Upload directories
API Endpoints
POST /api/auth/login
- User authenticationGET /api/bulletins
- List bulletinsPOST /api/bulletins
- Upload bulletinGET /api/events
- List eventsPOST /api/events
- Create eventPOST /api/media/upload
- Upload media filesGET /api/stream/status
- Live stream status
Development
# Run tests
cargo test
# Check code
cargo check
# Format code
cargo fmt
License
MIT License - see LICENSE file for details.
Author
Benjamin Slingo