feat(rooms): Implement Yantra Rooms System backend with atomic progression and data seeding#39
Merged
Merged
Conversation
… and proper status response
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request delivers the full backend infrastructure for the Yantra Rooms System,
addressing the core issue of hardcoded content and enabling dynamic, personalized learning paths.
It covers Phases 1, 2, 3, 4, and 5 of the backend task brief.
Key Features & Implementations:
Database Schema (
rooms_schema.sql,student_challenge_progress.sql):skills,skill_topics(Rooms),yantra_challenges,student_topic_progress, andstudent_challenge_progresstables.CHECKconstraints for data integrity, andUNIQUEconstraints to prevent data duplication.ALTER TABLE ... ADD COLUMN IF NOT EXISTSand unique constraint checks to ensure compatibility with existingyantra_challengestable structures and maintain idempotency for schema updates.student_challenge_progresstable for granular tracking of individual challenge attempts.Atomic Room Progression (Supabase RPC
complete_skill_topic):public.complete_skill_topic(p_topic_id, p_user_id)to atomically handle marking a topic as 'completed' and promoting the next topic to 'current'. This prevents data inconsistencies from partial updates during API calls.API Endpoints (
app/api/skills/[skillSlug]/rooms/route.ts, etc.):GET /api/skills/:skillSlug: Returns skill header information (name, description, room count).GET /api/skills/:skillSlug/rooms: Provides the full list of rooms for a a skill, dynamically joined with the student's progress status.upsertwithonConflict: 'user_id,topic_id', ignoreDuplicates: trueto prevent race conditions when new students access a skill for the first time.GET /api/rooms/:topicId: Fetches detailed information for a specific room, including the current student'sstatusfor that room.GET /api/rooms/:topicId/challenge: Returns the first challenge for a given topic, ordered byorder_index. (Note: Future work will integratestudent_challenge_progressto return the first unpassed challenge).POST /api/rooms/:topicId/complete: Triggers thecomplete_skill_topicRPC for atomic progression.Data Seeding (
seed_rooms_data.sql,seed_challenges.sql):skillsandskill_topicstables with the "Python Foundations" track and its five rooms.skill_key,topic,description, anddifficultyvalues for backward compatibility. All seeding scripts are idempotent usingON CONFLICT.Technical Decisions & Engineering Highlights:
idx_skill_topics_skill_order) for quick lookups, crucial for a growing curriculum.auth.uid() = user_id).SECURITY DEFINERwith explicitsearch_pathfor the RPC ensures controlled access.Verification Status (against brief criteria):
current, others aslocked.lockedroom returns details withstatus: 'locked'.current./api/skills/:skillSlugmatches actual topics.