WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Module ProgressService

    Comprehensive progress tracking and gamification service for the WayrApp language learning platform.

    This service manages all aspects of user progress including experience points calculation, lesson completion tracking, streak management, and offline synchronization. It serves as the central business logic layer for the progress tracking system, handling complex scenarios like performance-based experience multipliers, conflict resolution during offline sync, and gamification features such as lives and daily streaks.

    The service integrates with the ProgressRepository for data persistence and provides comprehensive progress analytics for both users and administrators. It automatically initializes user progress when needed and maintains data consistency through transactional operations and proper error handling.

    Key features include intelligent experience point calculation based on lesson difficulty and user performance, robust offline progress synchronization with duplicate detection, streak calculation based on daily activity patterns, and comprehensive progress summaries for dashboard displays.

    Exequiel Trujillo

    1.0.0

    // Initialize service with dependencies
    const progressRepository = new ProgressRepository(prisma);
    const progressService = new ProgressService(progressRepository, prisma);

    // Complete a lesson and update progress
    const result = await progressService.completeLesson('user-123', {
    lesson_id: 'lesson-456',
    score: 85,
    time_spent_seconds: 120
    });

    // Sync offline progress data
    const syncResult = await progressService.syncOfflineProgress('user-123', {
    completions: [{ lesson_id: 'lesson-789', completed_at: '2025-01-01T10:00:00Z', score: 92 }],
    last_sync_timestamp: '2025-01-01T09:00:00Z'
    });

    Classes

    ProgressService