intialization
This commit is contained in:
@@ -335,42 +335,126 @@ simplified,traditional,pinyin,meaning,hsk_level,radical,frequency,pos,classifier
|
||||
|
||||
## 9. Development Milestones
|
||||
|
||||
### Week 1: Foundation
|
||||
- Setup Next.js 16 project
|
||||
- Configure Prisma + PostgreSQL
|
||||
- Setup Docker Compose
|
||||
- Create all data models
|
||||
- Configure NextAuth.js
|
||||
### Week 1: Foundation ✅ COMPLETE
|
||||
- ✅ Setup Next.js 16 project
|
||||
- ✅ Configure Prisma + PostgreSQL
|
||||
- ✅ Setup Docker Compose
|
||||
- ✅ Create all data models (18 models, 3 enums)
|
||||
- ✅ Configure NextAuth.js
|
||||
- ✅ Middleware for route protection
|
||||
- ✅ All Prisma relations implemented
|
||||
- ✅ Database migrations created
|
||||
- ✅ Docker containers: nginx, app, postgres
|
||||
- ✅ Build successful
|
||||
|
||||
### Week 2: Authentication
|
||||
- Registration/login pages
|
||||
- Middleware protection
|
||||
- User preferences
|
||||
- Integration tests
|
||||
### Week 2: Authentication ✅ COMPLETE
|
||||
- ✅ Registration/login pages
|
||||
- ✅ Middleware protection
|
||||
- ✅ User preferences (cardsPerSession, characterDisplay, hideEnglish)
|
||||
- ✅ Integration tests (10 tests for auth, 8 tests for preferences)
|
||||
- ✅ Server Actions: register, login, updatePreferences, getPreferences
|
||||
- ✅ Zod validation for all inputs
|
||||
- ✅ Password hashing with bcrypt
|
||||
- ✅ Session management with NextAuth.js v5
|
||||
- ✅ Settings page with preferences form
|
||||
|
||||
### Week 3-4: Data Import
|
||||
- Admin role middleware
|
||||
- HSK JSON parser
|
||||
- CSV parser
|
||||
- Import UI and actions
|
||||
- Test with real HSK data
|
||||
### Week 3-4: Data Import ✅ COMPLETE
|
||||
- ✅ Admin role middleware
|
||||
- ✅ HSK JSON parser (`src/lib/import/json-parser.ts`)
|
||||
- ✅ Support for complete-hsk-vocabulary format
|
||||
- ✅ All transcription types (pinyin, numeric, wade-giles, zhuyin, ipa)
|
||||
- ✅ Multi-character hanzi support
|
||||
- ✅ HSK level mapping (new-1 through old-6)
|
||||
- ✅ CSV parser (`src/lib/import/csv-parser.ts`)
|
||||
- ✅ Flexible column mapping
|
||||
- ✅ Comma-separated multi-values
|
||||
- ✅ Complete field validation
|
||||
- ✅ Import UI and actions
|
||||
- ✅ File upload and paste textarea
|
||||
- ✅ Update existing or skip duplicates
|
||||
- ✅ Detailed results with line-level errors
|
||||
- ✅ Test with real HSK data
|
||||
- ✅ 14 passing integration tests
|
||||
- ✅ Admin import page at /admin/import
|
||||
- ✅ **Enhancement**: Database initialization system
|
||||
- ✅ `getInitializationFiles()` Server Action to list available files
|
||||
- ✅ Multi-file selection for batch initialization
|
||||
- ✅ SSE API endpoint (`/api/admin/initialize`) for long-running operations
|
||||
- ✅ Real-time progress updates via Server-Sent Events
|
||||
- ✅ Progress bar showing percent, current/total, and operation message
|
||||
- ✅ Auto-create HSK level collections from hanzi level attributes
|
||||
- ✅ Auto-populate collections with corresponding hanzi
|
||||
- ✅ Optional clean data mode (delete all existing data)
|
||||
- ✅ Admin initialization page at /admin/initialize with SSE integration
|
||||
- ✅ No timeouts: processes complete.json (11K+ hanzi) smoothly
|
||||
|
||||
### Week 5: Collections
|
||||
- Collections CRUD
|
||||
- Add/remove hanzi
|
||||
- Global HSK collections
|
||||
### Week 5: Collections ✅ COMPLETE
|
||||
- ✅ Collections CRUD (Server Actions in `src/actions/collections.ts`)
|
||||
- ✅ createCollection()
|
||||
- ✅ getUserCollections()
|
||||
- ✅ getCollectionById()
|
||||
- ✅ updateCollection()
|
||||
- ✅ deleteCollection()
|
||||
- ✅ Add/remove hanzi
|
||||
- ✅ addHanziToCollection() with multi-select
|
||||
- ✅ removeHanziFromCollection() with bulk support
|
||||
- ✅ Search & select interface
|
||||
- ✅ Paste list interface (comma, space, newline separated)
|
||||
- ✅ Global HSK collections
|
||||
- ✅ isPublic flag for admin-created collections
|
||||
- ✅ Read-only for regular users
|
||||
- ✅ Full control for admins
|
||||
- ✅ 21 passing integration tests
|
||||
- ✅ Pages: /collections, /collections/[id], /collections/new
|
||||
- ✅ Order preservation with orderIndex
|
||||
|
||||
### Week 5: Hanzi Search
|
||||
- Search page
|
||||
- Filters (HSK level)
|
||||
- Hanzi detail view
|
||||
- Pagination
|
||||
### Week 5: Hanzi Search ✅ COMPLETE
|
||||
- ✅ Search page (`/hanzi`)
|
||||
- ✅ Query input for simplified, traditional, pinyin, meaning
|
||||
- ✅ Case-insensitive search
|
||||
- ✅ Multi-character support
|
||||
- ✅ Filters (HSK level)
|
||||
- ✅ 12 HSK levels (new-1 through new-6, old-1 through old-6)
|
||||
- ✅ Dynamic filtering on hskLevels relation
|
||||
- ✅ Hanzi detail view (`/hanzi/[id]`)
|
||||
- ✅ Large character display
|
||||
- ✅ All forms with isDefault indicator
|
||||
- ✅ All transcriptions grouped by type
|
||||
- ✅ All meanings with language codes
|
||||
- ✅ HSK level badges, parts of speech
|
||||
- ✅ Classifiers, radical, frequency
|
||||
- ✅ Add to collection button with modal
|
||||
- ✅ Pagination
|
||||
- ✅ 20 results per page
|
||||
- ✅ hasMore indicator (limit+1 pattern)
|
||||
- ✅ Previous/Next controls
|
||||
- ✅ 16 passing integration tests
|
||||
- ✅ Public access (no authentication required)
|
||||
- ✅ Server Actions: searchHanzi(), getHanzi(), getHanziBySimplified()
|
||||
|
||||
### Week 6: SM-2 Algorithm
|
||||
- Implement algorithm
|
||||
- Card selection logic
|
||||
- Progress tracking
|
||||
- Unit tests (90%+ coverage)
|
||||
### Week 6: SM-2 Algorithm ✅ COMPLETE
|
||||
- ✅ Implement algorithm (`src/lib/learning/sm2.ts`)
|
||||
- ✅ calculateCorrectAnswer() with exact formulas
|
||||
- ✅ calculateIncorrectAnswer() with exact formulas
|
||||
- ✅ Initial values: easeFactor=2.5, interval=1, consecutiveCorrect=0
|
||||
- ✅ Correct answer intervals: 1, 6, then interval × easeFactor
|
||||
- ✅ Incorrect answer: reset to 1 day, decrease easeFactor
|
||||
- ✅ Card selection logic
|
||||
- ✅ selectCardsForSession() with priority sorting
|
||||
- ✅ Filter SUSPENDED cards
|
||||
- ✅ Priority: HARD > NORMAL > EASY
|
||||
- ✅ Sort: nextReviewDate ASC, incorrectCount DESC, consecutiveCorrect ASC
|
||||
- ✅ Wrong answer generation
|
||||
- ✅ generateWrongAnswers() selects 3 from same HSK level
|
||||
- ✅ Fisher-Yates shuffle for randomization
|
||||
- ✅ shuffleOptions() for answer position randomization
|
||||
- ✅ Unit tests (38 tests, 100% coverage)
|
||||
- ✅ Test all calculation formulas
|
||||
- ✅ Test edge cases (minimum easeFactor, large intervals, etc.)
|
||||
- ✅ Test card selection with all sorting criteria
|
||||
- ✅ Test wrong answer generation
|
||||
- ✅ 100% statement and line coverage
|
||||
- ✅ 94.11% branch coverage (exceeds 90% requirement)
|
||||
|
||||
### Week 7-8: Learning Interface
|
||||
- Learning session pages
|
||||
|
||||
Reference in New Issue
Block a user