---
phase: 03-komplettes-spielerlebnis
plan: 01
subsystem: game-data
tags: [word-lists, typing, progress-tracking, rate-limiting]

requires:
  - phase: 01-technische-basis
    provides: "Level definitions with allKeys, Progress interface, IndexedDB storage"
  - phase: 02-gemini-integration
    provides: "Gemini API with rate limiting"
provides:
  - "Static word lists per level (1-6) with getWordsForLevel()"
  - "Extended Progress interface with accuracy tracking fields"
  - "LessonPhase type (discover | practice | words)"
  - "Updated rate limits: 10 text / 5 image per day"
affects: [03-02-lesson-flow, 03-03-reward-system, 03-04-parent-area]

tech-stack:
  added: []
  patterns: ["TDD for game data validation", "letter-only validation against level allKeys"]

key-files:
  created:
    - src/game/words.ts
    - src/game/words.test.ts
  modified:
    - src/types.ts
    - src/api/gemini.ts
    - src/ui/screens.ts
    - src/api/gemini.test.ts
    - src/storage/db.test.ts

key-decisions:
  - "Levels 1-2 use letter combos (no real German words possible with F/J/D/K)"
  - "Rate limits raised to 10 text / 5 image per day for real usage"

patterns-established:
  - "Word list validation: every word checked against getKeysUpToLevel() at test time"

requirements-completed: [LEVL-04, TYPE-06]

duration: 3min
completed: 2026-03-29
---

# Phase 03 Plan 01: Data Layer Foundation Summary

**Word lists for levels 1-6 with TDD validation, extended Progress with accuracy stats, rate limits 10/5 per day**

## Performance

- **Duration:** 3 min
- **Started:** 2026-03-29T11:39:57Z
- **Completed:** 2026-03-29T11:42:37Z
- **Tasks:** 2
- **Files modified:** 7

## Accomplishments
- Word lists for levels 1-6 (8-10 words each), validated to only use learned letters per level
- getWordsForLevel() with without-replacement and with-replacement sampling
- Progress interface extended with totalCorrect, totalErrors, errorKeyCounts, lastPlayedLevels
- LessonPhase type exported for lesson flow phases
- Rate limits updated from 1/1 to 10 text / 5 image per day

## Task Commits

Each task was committed atomically:

1. **Task 1: Word lists per level with validation tests** - `420c0e1` (test: RED), `5a6ba70` (feat: GREEN)
2. **Task 2: Extend Progress type and update rate limits** - `d4207bf` (feat)

## Files Created/Modified
- `src/game/words.ts` - Static word lists per level, getWordsForLevel() function
- `src/game/words.test.ts` - 8 tests validating word lists against level keys
- `src/types.ts` - Extended Progress interface, new LessonPhase type
- `src/api/gemini.ts` - Rate limit constants TEXT_RATE_LIMIT=10, IMAGE_RATE_LIMIT=5
- `src/ui/screens.ts` - New Progress field defaults in welcome screen
- `src/api/gemini.test.ts` - Updated rate limit tests for new limits
- `src/storage/db.test.ts` - Updated Progress test fixture with new fields

## Decisions Made
- Levels 1-2 use letter combination patterns since no real German words can be formed with only F/J/D/K
- Rate limits raised to 10 text / 5 image per day (was 1 each) for practical usage

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 1 - Bug] Fixed invalid letters in word lists**
- **Found during:** Task 1 (TDD GREEN phase)
- **Issue:** Plan's suggested words contained letters not in level allKeys (e.g., "halb" has "b" not in level 5, "salad" has letters not in level 4)
- **Fix:** Replaced invalid words with valid alternatives using only level-appropriate letters
- **Files modified:** src/game/words.ts
- **Verification:** All 8 word validation tests pass
- **Committed in:** 5a6ba70 (Task 1 GREEN commit)

**2. [Rule 1 - Bug] Updated existing tests for new rate limits and Progress shape**
- **Found during:** Task 2 (verification step)
- **Issue:** Existing tests expected old rate limit of 1 and old Progress shape without new fields
- **Fix:** Updated gemini.test.ts to call incrementApiCall 10/5 times, added new fields to db.test.ts fixture
- **Files modified:** src/api/gemini.test.ts, src/storage/db.test.ts
- **Verification:** All 76 tests pass, tsc --noEmit clean
- **Committed in:** d4207bf (Task 2 commit)

---

**Total deviations:** 2 auto-fixed (2 bugs)
**Impact on plan:** Both fixes necessary for correctness. No scope creep.

## Issues Encountered
None beyond the auto-fixed deviations above.

## User Setup Required
None - no external service configuration required.

## Next Phase Readiness
- Word lists ready for lesson flow (03-02)
- Progress stats fields ready for parent area (03-04)
- LessonPhase type ready for lesson screen phases (03-02)
- Rate limits configured for reward system API calls (03-03)

---
*Phase: 03-komplettes-spielerlebnis*
*Completed: 2026-03-29*
