Navigation
๐Ÿš€ Competitive Feature Activation Guide

Close the gap with Duolingo, Babbel & Memrise

Offline Mode

70% Complete

Queue manager exists, needs game integration

Speech Recognition

90% Complete

Hook ready, needs UI integration

Adaptive Learning

60% Complete

Engine exists, needs full personalization

Offline Mode Implementation

Let users play games without internet, sync when reconnected

โœ… What Already Exists

  • offlineQueueManager.js - Queues actions (pearl awards, scores)
  • OfflineIndicator.jsx - Shows connection status
  • Automatic sync on reconnection
  • Exponential backoff for failed syncs
  • localStorage persistence

โŒ What's Missing

  • Games don't use offline queue yet
  • No cached idiom data for offline play
  • No service worker for true PWA offline
  • No offline leaderboard cache

Step 1: Add Offline Support to Games

// In IdiomScrabble.jsx (and other games)
import { queueOfflineAction } from '@/lib/offlineQueueManager';

// Replace direct API calls with offline-aware logic
const handleGameComplete = async () => {
  const gameData = {
    user_email: user.email,
    score: finalScore,
    pearls: pearlsEarned
  };

  // Check if online
  if (navigator.onLine) {
    try {
      await base44.integrations.Core.InvokeLLM(...); // Normal API call
    } catch (error) {
      // If fails, queue it
      queueOfflineAction({
        type: 'submit_score',
        payload: gameData
      });
    }
  } else {
    // Offline - queue immediately
    queueOfflineAction({
      type: 'submit_score',
      payload: gameData
    });
    
    toast.success('Score saved! Will sync when online');
  }
};

Step 2: Cache Idioms for Offline Access

// Create: components/lib/offlineCache.js
export async function cacheIdiomsForOffline() {
  const idioms = await base44.entities.Idiom.list();
  localStorage.setItem('cached_idioms', JSON.stringify({
    data: idioms,
    timestamp: Date.now()
  }));
}

export function getCachedIdioms() {
  const cached = localStorage.getItem('cached_idioms');
  if (!cached) return null;
  
  const { data, timestamp } = JSON.parse(cached);
  const age = Date.now() - timestamp;
  
  // Cache expires after 24 hours
  if (age > 24 * 60 * 60 * 1000) return null;
  
  return data;
}

// In games: Try network first, fallback to cache
const loadIdioms = async () => {
  try {
    const idioms = await base44.entities.Idiom.list();
    // Update cache in background
    cacheIdiomsForOffline();
    return idioms;
  } catch (error) {
    const cached = getCachedIdioms();
    if (cached) {
      toast.info('Playing offline with cached content');
      return cached;
    }
    throw error;
  }
};

Step 3: Service Worker for True Offline

// Create: public/sw.js
self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open('snappy-v1').then((cache) => {
      return cache.addAll([
        '/',
        '/index.html',
        '/static/css/main.css',
        '/static/js/main.js',
        // Add critical assets
      ]);
    })
  );
});

self.addEventListener('fetch', (event) => {
  event.respondWith(
    caches.match(event.request).then((response) => {
      return response || fetch(event.request);
    })
  );
});

// Register in index.html
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js');
}

Implementation Estimate

Time:

6-8 hours

Complexity:

Medium

Priority:
High
Impact:

Enables play on trains, planes, low-signal areas

Recommended Implementation Order

Phase 1 (Week 1)

  • Speech Recognition UI - 4-6 hours
  • Add speech to Practice modes - 2 hours
  • Test on mobile browsers - 1 hour
High impact, low effort

Phase 2 (Week 2)

  • Offline queue integration in games - 4 hours
  • Cache idioms for offline - 2 hours
  • Test offline sync flow - 2 hours
Medium impact, medium effort

Phase 3 (Week 3-4)

  • Create LearningPath entity - 2 hours
  • Build adaptive difficulty system - 6 hours
  • Design skill tree UI - 4 hours
  • Implement XP & milestones - 4 hours
High impact, high effort
After Implementation: Market Position
FeatureDuolingoBabbelSnappy (After)
Offline Modeโœ…โœ…โœ…
Speech Recognitionโœ…โœ…โœ…
Adaptive Learningโœ…โœ…โœ…
Idiom SpecializationโŒโš ๏ธ Limitedโœ… Core Focus
Thinking Style PersonalizationโŒโŒโœ… Unique