Skip to content

Conversation

@ldsgroups225
Copy link
Owner

@ldsgroups225 ldsgroups225 commented Jan 13, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Admin authentication and secure access control for the admin dashboard.
    • Complete card management system with create, edit, duplicate, delete, and bulk import capabilities.
    • Parent alerts can now be marked as read individually or in bulk.
    • Achievement notification tracking.
    • Subject-level and lesson-specific study sessions.
    • Spaced repetition algorithm for optimized card review scheduling.
    • Public Terms and Privacy pages with updated navigation.
  • Improvements

    • Subject performance analytics in parent dashboard.
    • Quick review section displays cards due today.

✏️ Tip: You can customize this high-level summary in your review settings.

- Refactored study session API to support subject-level and lesson-level review.
- Updated database schema for elective lessonId and new subjectId in study_sessions.
- Enhanced gamification persistence with server-side XP and streak calculations.
- Improved kurama-admin lesson detail page with card list, CRUD, and bulk JSON import.
- Fixed numerous TypeScript and linting errors across the monorepo.
- Updated CLAUDE.md with new project guidelines and workflows.
- Created SM-2 utility for review interval calculations
- Integrated SM-2 into study sessions (lesson and quick review)
- Added 'Due Today' section to student dashboard
- Enhanced parent dashboard with subject performance grid
- Implemented academic excellence alerts for parents
- Updated database schema with unique constraint and indexes for user progress
- Fixed type errors and improved error handling in server functions
@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR implements core refinements across admin and user applications, introducing admin access enforcement via middleware, comprehensive card management for lesson administration, persistence mechanisms for parent alerts and achievement notifications, subject-based study sessions with SM-2 spaced repetition tracking, and public legal pages with updated navigation.

Changes

Cohort / File(s) Summary
Admin Middleware & Access Control
apps/kurama-admin/src/core/middleware/admin-auth.ts
Enforces admin access by validating user profile from database; returns profile in auth context; extends getAuthContext return type
Admin Lesson Management
apps/kurama-admin/src/routes/_admin/lessons.$lessonId.tsx
Adds comprehensive card CRUD (create, read, update, duplicate, delete) with form, list, preview, and bulk import UI; wires mutations to database operations
Admin Dashboard & User Management
apps/kurama-admin/src/routes/_admin/dashboard.tsx, apps/kurama-admin/src/routes/_admin/users.index.tsx
Updates RecentSession interface to allow null lessonId; expands userType to include 'admin' with label mapping
User Auth & Onboarding
apps/user-application/src/components/auth/auth-screen.tsx, apps/user-application/src/components/onboarding/user-type-selection.tsx, apps/user-application/src/components/profile/profile-edit-form.tsx
Replaces placeholder navigation buttons with Link components for /terms and /privacy routes; refines userType selection logic
Core Learning & Progress Functions
apps/user-application/src/core/functions/learning.ts, apps/user-application/src/core/functions/progress.ts, apps/user-application/src/core/functions/stats.ts, apps/user-application/src/core/functions/review.ts
Adds startStudySession endpoint supporting lesson or subject-based sessions; implements SM-2 progress tracking (markAchievementsAsNotified, updateCardProgress, getDueCards); simplifies review filtering; extends session stats to support subject-based study
Parent Alert & Dashboard Management
apps/user-application/src/core/functions/parent.ts, apps/user-application/src/hooks/use-parent-dashboard.ts
Implements read-tracking for alerts via parentAlertReads schema; adds markAlertAsRead and markAllAlertsAsRead server functions; wires parent dashboard hook to mutations with refetch on success
Study Session Routes & SM-2 Algorithm
apps/user-application/src/routes/api/study/$sessionId.ts, apps/user-application/src/utils/sm2.ts
Extends card retrieval to support subject-level sessions (fetches all lesson cards for subject); implements calculateSM2 algorithm with interval, ease factor, and repetition tracking
Lesson & Review Session Flows
apps/user-application/src/routes/_auth/app/lesson-session.$lessonId.tsx, apps/user-application/src/routes/_auth/app/lesson-summary.$lessonId.tsx, apps/user-application/src/routes/_auth/app/quick-review.tsx
Accumulates per-card SM-2 results (quality, cardId, lessonId) during study; submits via updateCardProgress on session end; adds achievement notification persistence via markAchievementsAsNotified on toast dismiss
User Dashboard & Progress Pages
apps/user-application/src/routes/_auth/app/index.lazy.tsx, apps/user-application/src/routes/_auth/app/parent/index.tsx, apps/user-application/src/routes/_auth/app/progress.tsx
Adds "SM-2 Due Today" card when reviewCount > 0; displays SubjectPerformanceGrid in parent dashboard; replaces localStorage-based achievement tracking with server-side mutation
Navigation & Error Handling
apps/user-application/src/routes/_auth/app/referrals.tsx
Introduces syntax error with consecutive else blocks affecting control flow (⚠️ requires fix)
Public Routes & Pages
apps/user-application/src/routes/_public/privacy.tsx, apps/user-application/src/routes/_public/terms.tsx, apps/user-application/src/routeTree.gen.ts
Adds Terms and Privacy policy pages with static content and back navigation; updates route tree with new PublicTermsRoute and PublicPrivacyRoute entries and type augmentations
User Profile Type Extensions
apps/user-application/src/lib/atoms/user-profile.ts, packages/data-ops/src/zod-schema/profile.ts
Expands userType to include 'admin' across profile atoms and Zod schemas
Database Schema & Migrations
packages/data-ops/src/drizzle/schema.ts, packages/data-ops/src/drizzle/relations.ts, packages/data-ops/src/drizzle/0011_real_pyro.sql, packages/data-ops/src/drizzle/0012_burly_karnak.sql
Adds parentAlertReads table with parent/alert uniqueness constraint; makes studySessions.lessonId optional and adds subjectId; extends userAchievements with notifiedAt timestamp; adds indexes on userProgress; updates relations for alert reads
Database Snapshots & Metadata
packages/data-ops/src/drizzle/meta/0011_snapshot.json, packages/data-ops/src/drizzle/meta/0012_snapshot.json, packages/data-ops/src/drizzle/meta/_journal.json, packages/data-ops/src/queries/achievements.ts
Adds schema snapshots capturing full PostgreSQL state; updates achievement query to track both unlockedAt and notified status; appends migration journal entries
Documentation & Task Tracking
tasks/prd-core-refinement.md, tasks/tasks-core-refinement.md
Documents PRD for persistence, legal pages, and admin security; outlines implementation tasks with checklist and scope definition

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API as Study API
    participant DB as Database
    
    Client->>API: POST /api/study/session (subjectId)
    activate API
    API->>DB: Fetch subject
    DB-->>API: Subject data
    API->>DB: Fetch all lessons for subject
    DB-->>API: Lesson IDs
    API->>DB: Fetch cards where lessonId IN (lesson set)
    DB-->>API: Cards (up to 50)
    API->>DB: Create study session record<br/>(userId, subjectId, mode, startedAt)
    DB-->>API: Session ID
    deactivate API
    API-->>Client: { sessionId, cards[] }
    
    Note over Client: User answers cards
    
    Client->>API: POST /api/study/session/complete<br/>(sessionId, cardResults[])
    activate API
    API->>DB: Bulk upsert userProgress<br/>with SM-2 calculations
    DB-->>API: Updated progress records
    deactivate API
    API-->>Client: { success: true }
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

A rabbit hops through admin halls, 🐰
Watching lessons cards dance and fall,
SM-2 memories bloom in the mind,
While alerts and achievements align,
Terms and privacy paths unwind!

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff5c2cd and fa3e472.

📒 Files selected for processing (37)
  • apps/kurama-admin/src/core/middleware/admin-auth.ts
  • apps/kurama-admin/src/routes/_admin/dashboard.tsx
  • apps/kurama-admin/src/routes/_admin/lessons.$lessonId.tsx
  • apps/kurama-admin/src/routes/_admin/users.index.tsx
  • apps/user-application/src/components/auth/auth-screen.tsx
  • apps/user-application/src/components/onboarding/user-type-selection.tsx
  • apps/user-application/src/components/profile/profile-edit-form.tsx
  • apps/user-application/src/core/functions/learning.ts
  • apps/user-application/src/core/functions/parent.ts
  • apps/user-application/src/core/functions/progress.ts
  • apps/user-application/src/core/functions/review.ts
  • apps/user-application/src/core/functions/stats.ts
  • apps/user-application/src/hooks/use-parent-dashboard.ts
  • apps/user-application/src/lib/atoms/user-profile.ts
  • apps/user-application/src/routeTree.gen.ts
  • apps/user-application/src/routes/_auth/app/index.lazy.tsx
  • apps/user-application/src/routes/_auth/app/lesson-session.$lessonId.tsx
  • apps/user-application/src/routes/_auth/app/lesson-summary.$lessonId.tsx
  • apps/user-application/src/routes/_auth/app/parent/index.tsx
  • apps/user-application/src/routes/_auth/app/progress.tsx
  • apps/user-application/src/routes/_auth/app/quick-review.tsx
  • apps/user-application/src/routes/_auth/app/referrals.tsx
  • apps/user-application/src/routes/_public/privacy.tsx
  • apps/user-application/src/routes/_public/terms.tsx
  • apps/user-application/src/routes/api/study/$sessionId.ts
  • apps/user-application/src/utils/sm2.ts
  • packages/data-ops/src/drizzle/0011_real_pyro.sql
  • packages/data-ops/src/drizzle/0012_burly_karnak.sql
  • packages/data-ops/src/drizzle/meta/0011_snapshot.json
  • packages/data-ops/src/drizzle/meta/0012_snapshot.json
  • packages/data-ops/src/drizzle/meta/_journal.json
  • packages/data-ops/src/drizzle/relations.ts
  • packages/data-ops/src/drizzle/schema.ts
  • packages/data-ops/src/queries/achievements.ts
  • packages/data-ops/src/zod-schema/profile.ts
  • tasks/prd-core-refinement.md
  • tasks/tasks-core-refinement.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ldsgroups225 ldsgroups225 merged commit dc3b75d into main Jan 13, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants