📋 Complete Context Taxonomy v2

Anasayfa, Sidebar, Large Playlists - Tüm Senaryolar

📅 5 Aralık 2025 🎯 v2 - Homepage + 500 Şarkılık Playlist 💾 Zero Migration

⚠️ SORUN: Anasayfa section'ları, sidebar linkleri, 500+ şarkılı playlist'ler için context YOK!

🏠 Anasayfa Context Mapping

Anasayfa Yapısı

Anasayfada birçok section var: Yeni Albümler, Popüler Şarkılar, Önerilen Playlistler, Son Eklenenler vb. Her section'dan şarkı çalınırsa farklı context uygulanmalı!

1

💿 Yeni Albümler (New Releases)

Senaryo:

Anasayfadaki "Yeni Albümler" section'ından kullanıcı bir albüme tıklar → Şarkı çalar

Context Stratejisi:

Seçenek A: Album Context (Önerilen ✅)
{type: "album", id: 45, genreId: 9}
→ Albüm biter, sonra genre'ye geç

Seçenek B: Discovery Context
{type: "discovery", section: "new-releases"}
→ Yeni albümlerden karışık şarkılar getir

Önerilen: Seçenek A (Album context) - Kullanıcı bir albüm seçti, albümü dinlesin

2

🔥 Popüler Şarkılar (Popular Songs)

Senaryo:

Anasayfadaki "Popüler Şarkılar" section'ından tek bir şarkı seçilir

Context Stratejisi:

Seçenek A: Popular Context (Önerilen ✅)
{type: "popular", period: "weekly"}
→ Popüler şarkılardan devam et (play_count sıralaması)

Seçenek B: Album Context
{type: "album", id: şarkının albumId}
→ Şarkının albümünden devam et

Önerilen: Seçenek A (Popular context) - Kullanıcı popüler müzik istiyorsa popüler devam etsin

3

🎵 Önerilen Playlistler (Featured Playlists)

Senaryo:

Anasayfadaki "Önerilen Playlistler" section'ından bir playlist seçilir

Context Stratejisi:

Playlist Context (Tek seçenek ✅)
{type: "playlist", id: 23, name: "Chill Vibes"}
→ Playlist'teki şarkılar biter, tekrar baştan döner (loop)

✅ Playlist seçildi, playlist'ten devam et

4

🆕 Son Eklenenler (Recently Added)

Context Stratejisi:

Recent Context (Önerilen ✅)
{type: "recent", order: "created_at DESC"}
→ Yeni eklenen şarkılardan devam et
5

❤️ Favorilerim (My Favorites)

Context Stratejisi:

Favorites Context (Önerilen ✅)
{type: "favorites", userId: 123}
→ Kullanıcının favori şarkılarından devam et

📱 Sidebar Navigation Context

Sidebar Links

Sol taraftaki navigation menu'deki linkler. Her link farklı bir context type'a işaret eder.

🏠 Home / Anasayfa

Anasayfa'ya tıklanırsa context temizlenmez, son context devam eder

Context: Değişmez (mevcut context korunur)

🎭 Genres / Türler

Genres sayfasına git → Context belirlenmez (kullanıcı genre seçene kadar)

Context: null (genre seçilene kadar)

💿 Albums / Albümler

Albums sayfasına git → Context belirlenmez

Context: null (albüm seçilene kadar)

🎵 Playlists

Playlists sayfasına git → Context belirlenmez

Context: null (playlist seçilene kadar)

🏢 Sectors / Sektörler

Sectors sayfasına git → Context belirlenmez

Context: null (sector seçilene kadar)

📻 Radios

Radios sayfasına git → Context belirlenmez

Context: null (radio seçilene kadar)

💡 Sidebar Kuralı:

Sidebar'daki linkler sadece sayfalar arası geçiş yapar. Context, kullanıcı şarkı/albüm/playlist ÇALANA KADAR belirlenmez.

🚨 500+ Şarkılı Playlist Stratejisi

Problem: Performance

Bazı playlist'ler 500 hatta 1000 şarkı içerebilir. Tüm şarkıları queue'ya yüklemek:

  • ❌ Memory problemi (500 şarkı x metadata = çok veri)
  • ❌ API response çok büyük (JSON 5MB+)
  • ❌ Frontend render yavaşlar
  • ❌ Kullanıcı zaten 500 şarkıyı görmeyecek

✅ Çözüm: Chunk Strategy

Strateji:

  1. 1. İlk yükleme: Playlist'ten sadece ilk 15 şarkı çek
  2. 2. Queue azalınca: Playlist'ten sıradaki 10 şarkıyı çek (offset mekanizması)
  3. 3. Playlist bitti mi? Eğer 500 şarkı bittiyse başa dön (loop) veya benzer playlist'lerden devam et

Context Yapısı (Playlist için):

playContext = {
  type: "playlist",
  id: 23,
  name: "Epic Playlist (500 songs)",
  totalSongs: 500,
  currentOffset: 15, // Şu ana kadar 15 şarkı yüklendi
  loop: true // Playlist bitince başa dön
}

Backend API Logic:

case 'playlist':
    $playlist = Playlist::find($context['id']);
    $totalSongs = $playlist->songs()->count();
    $currentOffset = $context['currentOffset'] ?? 0;
    
    // Sıradaki 10 şarkıyı çek
    $songs = $playlist->songs()
        ->skip($currentOffset)
        ->take(10)
        ->get();
    
    // Eğer playlist bitti ve loop aktifse başa dön
    if ($songs->isEmpty() && $context['loop']) {
        $songs = $playlist->songs()->take(10)->get();
        $newOffset = 10;
    } else {
        $newOffset = $currentOffset + $songs->count();
    }
    
    return [
        'songs' => $songs,
        'newOffset' => $newOffset,
        'totalSongs' => $totalSongs,
        'hasMore' => $newOffset < $totalSongs
    ];

Sonuç: 500 şarkılı playlist olsa bile, her seferinde sadece 10-15 şarkı yüklenir. Memory ve performance problem yok!

🔀 Alternatif: Shuffle Mode

Kullanıcı "Shuffle" modunu aktif ederse:

case 'playlist':
    $playlist = Playlist::find($context['id']);
    
    // Rastgele 10 şarkı çek (offset yok!)
    $songs = $playlist->songs()
        ->inRandomOrder()
        ->take(10)
        ->get();
    
    return ['songs' => $songs];

💡 Shuffle mode'da offset yok, her seferinde rastgele 10 şarkı

📊 Tam Context Taksonomisi

10 Context Type

Sistem genelinde kullanılacak TÜM context tipleri:

1. genre

{type: "genre", id: 9}

2. album

{type: "album", id: 45, genreId: 9}

3. playlist

{type: "playlist", id: 23, currentOffset: 0}

4. sector

{type: "sector", id: 3}

5. radio

{type: "radio", id: 5, playlists: [12,15]}

6. popular

{type: "popular", period: "weekly"}

7. recent

{type: "recent", order: "created_at DESC"}

8. favorites

{type: "favorites", userId: 123}

9. artist

{type: "artist", id: 67}

10. search

{type: "search", query: "jazz"}

🔧 Implementation Güncellemesi

Phase 1: Context Helpers (1 saat) ⬆️

✅ setPlayContext() - 10 context type desteği

✅ getPlayContext()

✅ updatePlayContext() - offset güncelleme için

Phase 2: Blade Updates (2 saat) ⬆️

✅ home.blade.php - 5 section için context

✅ genres, albums, playlists, sectors, radios

✅ favorites, search results

Phase 3: Backend API (3 saat) ⬆️

✅ 10 context type için switch-case

✅ Playlist offset mekanizması

✅ Shuffle mode desteği

Phase 4: Frontend Queue (2 saat) ⬆️

✅ refillQueue() - offset update logic

✅ Large playlist handling

Phase 5: Test (2 saat) ⬆️

✅ 10 context type testi

✅ 500 şarkılı playlist testi

✅ Anasayfa section testleri

⏱️ Toplam Süre: ~10 saat (v1: 6 saat → v2: 10 saat)

Anasayfa section'ları + 500+ şarkılı playlist desteği eklendi

🎯 v2 Özeti

1. Anasayfa 5 section için context mapping (Yeni Albümler, Popüler, Önerilen, vb.)

2. Sidebar navigation context kuralları (sayfa değiştir, context korun)

3. 500+ şarkılı playlist için chunk strategy (offset mekanizması)

4. 10 context type taksonomisi (genre, album, playlist, sector, radio, popular, recent, favorites, artist, search)

5. Hala sıfır migration! Sadece frontend + 1 API endpoint

✅ Tüm senaryolar kapsandı!