Files
hoerdle/walkthrough.md
2025-11-22 11:56:22 +01:00

2.4 KiB

Genre/Tag System Implementation Walkthrough

Overview

Implemented a comprehensive Genre/Tag system for Hördle, allowing songs to be categorized and users to play genre-specific daily puzzles.

Changes

Database

  • New Model: Genre (id, name, songs, dailyPuzzles).
  • Updated Model: Song (added M-N relation to Genre).
  • Updated Model: DailyPuzzle (added optional genreId, updated unique constraint to [date, genreId]).

Backend API

  • app/api/genres/route.ts: New endpoints for GET (list) and POST (create) and DELETE genres.
  • app/api/songs/route.ts: Updated to handle genre assignment (POST/PUT) and retrieval (GET).
  • app/api/daily/route.ts: Updated to support ?genre=<name> query parameter.
  • lib/dailyPuzzle.ts: Shared logic for fetching/creating daily puzzles (Global or Genre-specific).

Frontend (Admin)

  • Genre Management: Create and delete genres.
  • Song Assignment: Assign genres during upload and edit.
  • Post-Upload Workflow: Prompt to assign genres immediately after upload.
  • Song List: Display assigned genres in the table.

Frontend (User)

  • Genre Selection: Links on the main page to switch between Global and Genre-specific games.
  • Game Logic: Refactored to support independent game states per genre (localStorage keys: hoerdle_game_state_<genre>).
  • Dynamic Route: app/[genre]/page.tsx for genre-specific URLs.
  • Sharing: Share text now includes the genre name.

Deployment

  • Auto-Migration: Added scripts/docker-entrypoint.sh to run prisma migrate deploy on startup.
  • Dockerfile: Updated to use the entrypoint script.
  • Dependencies: Moved prisma to dependencies in package.json.

Verification Results

Automated Build

  • npm run build passed successfully.
  • npx prisma generate passed.
  1. Admin Dashboard:
    • Go to /admin.
    • Create a new genre (e.g., "Rock").
    • Upload a song and assign "Rock" to it.
    • Edit an existing song and assign "Rock".
  2. User Interface:
    • Go to /. Verify "Global" game works.
    • Click "Rock". Verify URL changes to /Rock.
    • Play the "Rock" game. Verify it picks a song tagged with "Rock".
    • Verify stats are separate for Global and Rock.
  3. Deployment:
    • Deploy to Docker.
    • Verify migrations run automatically on startup.