Business logic service for managing hierarchical educational content in WayrApp.
This service orchestrates the complete lifecycle of educational content through this hierarchy:
Courses → Levels → Sections → Modules → Lessons → Exercises. It serves as the primary business logic layer between REST API
controllers and data access repositories, implementing comprehensive validation, intelligent caching,
and complex operations like packaged course generation for offline mobile support.
The ContentService ensures data integrity through hierarchical validation, maintains referential
consistency across all content operations, and provides optimized caching strategies for performance.
It handles the complete CRUD lifecycle for all content entities while maintaining cache coherence
and providing specialized features like conditional content packaging with versioning support.
Key architectural responsibilities include hierarchical content validation (ensuring parent entities
exist before creating children), unique constraint enforcement (IDs, codes, ordering within parents),
intelligent cache invalidation (automatically clearing related caches on content changes), packaged
content generation for offline mobile apps with HTTP conditional request support, and comprehensive
error handling with detailed AppError responses.
The service integrates seamlessly with Prisma ORM for database operations, Redis caching for
performance optimization, and provides TypeScript-first APIs with full type safety across the
entire content management workflow.
Author
Exequiel Trujillo
Since
1.0.0
Example
// Basic service initialization and course creation import { ContentService } from'@/modules/content/services'; import { PrismaClient } from'@prisma/client';
// Create a complete course hierarchy constcourse = awaitcontentService.createCourse({ id:'spanish-101', source_language:'en', target_language:'es', name:'Spanish for Beginners', description:'Learn Spanish from scratch', is_public:true });
Example
// Advanced usage with packaged content for offline support // Get packaged course with all hierarchical content constpackagedCourse = awaitcontentService.getPackagedCourse('spanish-101');
// Conditional request to check for updates (HTTP 304 support) constupdated = awaitcontentService.getPackagedCourse('spanish-101', '2024-01-01T00:00:00Z'); if (updated === null) { console.log('Course not modified since specified date'); }
Business logic service for managing hierarchical educational content in WayrApp.
This service orchestrates the complete lifecycle of educational content through this hierarchy: Courses → Levels → Sections → Modules → Lessons → Exercises. It serves as the primary business logic layer between REST API controllers and data access repositories, implementing comprehensive validation, intelligent caching, and complex operations like packaged course generation for offline mobile support.
The ContentService ensures data integrity through hierarchical validation, maintains referential consistency across all content operations, and provides optimized caching strategies for performance. It handles the complete CRUD lifecycle for all content entities while maintaining cache coherence and providing specialized features like conditional content packaging with versioning support.
Key architectural responsibilities include hierarchical content validation (ensuring parent entities exist before creating children), unique constraint enforcement (IDs, codes, ordering within parents), intelligent cache invalidation (automatically clearing related caches on content changes), packaged content generation for offline mobile apps with HTTP conditional request support, and comprehensive error handling with detailed AppError responses.
The service integrates seamlessly with Prisma ORM for database operations, Redis caching for performance optimization, and provides TypeScript-first APIs with full type safety across the entire content management workflow.
Author
Exequiel Trujillo
Since
1.0.0
Example
Example
Example