2.4 KiB
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 toGenre). - Updated Model:
DailyPuzzle(added optionalgenreId, 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.tsxfor genre-specific URLs. - Sharing: Share text now includes the genre name.
Deployment
- Auto-Migration: Added
scripts/docker-entrypoint.shto runprisma migrate deployon startup. - Dockerfile: Updated to use the entrypoint script.
- Dependencies: Moved
prismatodependenciesinpackage.json.
Verification Results
Automated Build
npm run buildpassed successfully.npx prisma generatepassed.
Manual Verification Steps (Recommended)
- 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".
- Go to
- 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.
- Go to
- Deployment:
- Deploy to Docker.
- Verify migrations run automatically on startup.