Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
be18dc3
Modernize Vercel config: remove legacy builds, use functions+rewrites
lalrow Sep 9, 2025
8f58796
Fix Vercel deployment: simplify config to use standard rewrites
lalrow Sep 9, 2025
82254b2
Convert to Next.js frontend with modern UI
lalrow Sep 9, 2025
de72231
Frontend: handle non-OK responses, missing streams, and timeouts\n\n-…
lalrow Sep 9, 2025
b6a1e46
Fix TypeScript error: replace any with proper type check
lalrow Sep 9, 2025
4c4313a
Add OpenAI API key input field
lalrow Sep 9, 2025
568c07b
Add user tracking with localStorage and conversation history
lalrow Sep 13, 2025
8318d15
Fix user tracking with file-based persistence
lalrow Sep 13, 2025
639e40c
Add user ID validation and debugging to frontend
lalrow Sep 13, 2025
893f82b
Improve input UX with vertical expansion
lalrow Sep 14, 2025
c914b4e
Fix send button expansion issue
lalrow Sep 14, 2025
6e3f922
Add PDF upload and RAG functionality
lalrow Sep 17, 2025
14a52ef
Add RAG functionality with PDF upload, aimakerspace library, and test…
lalrow Sep 19, 2025
2ef45dd
Merge pull request #1 from lalrow/copy_rag
lalrow Sep 19, 2025
8189548
Fix serverless deployment: inline RAG class to avoid import issues
lalrow Sep 20, 2025
5a82582
Add MERGE.md with comprehensive merge instructions
lalrow Sep 20, 2025
9c703aa
Complete Kids Science Tutor MVP - Activity 2
lalrow Sep 21, 2025
843e80f
Fix Kids Science Tutor: Update proxy routing and import paths
lalrow Sep 22, 2025
77fac27
Complete Kids Science Tutor MVP with Persistent RAG System
lalrow Sep 23, 2025
ec02373
Merge pull request #2 from lalrow/copy_rag
lalrow Sep 23, 2025
667d537
Merge remote-tracking branch 'origin/main' into feature/activity-2-ki…
lalrow Sep 23, 2025
bfe8df9
Fix: Correct import path for auto-initialize in reindex route
lalrow Sep 23, 2025
34d0d87
Fix: Disable problematic ESLint rules for Vercel deployment
lalrow Sep 23, 2025
14436ea
Fix: Add prefer-const to disabled ESLint rules
lalrow Sep 23, 2025
fe30b01
Fix: Update Next.js 15 API route params signature
lalrow Sep 23, 2025
8890345
Fix: Properly handle Next.js 15 async params in dynamic routes
lalrow Sep 23, 2025
a27e971
Fix: Comprehensive TypeScript null/undefined handling
lalrow Sep 23, 2025
292eb86
Fix: Resolve Vercel API routing issues
lalrow Sep 23, 2025
b919bf3
Chore: Ignore FastAPI backend on Vercel, use Next.js APIs only
lalrow Sep 23, 2025
13e6ccf
Chore: Ignore FastAPI backend on Vercel, use Next.js APIs only
lalrow Sep 23, 2025
dc0271d
Fix: Add pdf-parse dependency and ignore FastAPI backend
lalrow Sep 23, 2025
e3a1835
Fix: Add Next.js stubs for rag-chat and chat APIs to return valid JSON
lalrow Sep 23, 2025
3e82341
Fix: Update PDF upload route with proper pdf-parse integration
lalrow Sep 23, 2025
ed9fc2b
Fix: Remove FastAPI routing from vercel.json to allow Next.js API routes
lalrow Sep 23, 2025
63240e2
Simplify: Use minimal vercel.json for Next.js auto-detection
lalrow Sep 23, 2025
a18a0b7
Fix: Configure Vercel for monorepo structure with frontend subdirectory
lalrow Sep 23, 2025
a49e081
Fix: Use Vercel monorepo configuration with explicit build commands
lalrow Sep 23, 2025
afb385c
Urgent Fix: Restore app routing and add explicit API route handling
lalrow Sep 23, 2025
f6b5f39
Fix: Remove explicit API routing to let Next.js handle API routes int…
lalrow Sep 23, 2025
27fa951
Fix: Use framework-specific configuration instead of custom builds
lalrow Sep 23, 2025
7da1b7f
Chore: reset vercel.json to minimal for Next.js auto-detection
lalrow Sep 23, 2025
8cadb9c
Fix: Move vercel.json to frontend/ directory as required by Root Dire…
lalrow Sep 23, 2025
79422b7
Fix: Correct import path for auto-initialize in reindex route
lalrow Sep 23, 2025
aa12707
Remove FastAPI backend completely, add API endpoint logging
lalrow Sep 23, 2025
0202387
Fix Vercel filesystem issue - process PDFs in memory only
lalrow Sep 23, 2025
4e8e685
Fix Vercel read-only filesystem - use in-memory database
lalrow Sep 23, 2025
1349a25
Fix Vercel database persistence issue - ensure database is populated …
lalrow Sep 25, 2025
0020989
Fix database issues and single-kid mode
lalrow Sep 25, 2025
b7d5b03
Fix build errors: update imports and missing exports
lalrow Sep 25, 2025
ec95a9a
Fix all TypeScript errors and test APIs locally
lalrow Sep 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Empty file added .cursor/commands/refactor.md
Empty file.
4 changes: 3 additions & 1 deletion .cursor/rules/general-rule.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ alwaysApply: true
---
## Rules to Follow

- You must not analyze entire project unless absolutely needed. If I ask remind me this rule.
- You must always commit your changes whenever you update code.
- You must always try and write code that is well documented. (self or commented is fine)
- You must only work on a single feature at a time.
- You must explain your decisions thouroughly to the user.
- You must explain your decisions thouroughly to the user.
- You always prefer to use branch development. Before writing any code - you create a feature branch to hold those changes. After you are done - provide instructions in a "MERGE.md" file that explains how to merge the changes back to main with both a GitHub PR route and a GitHub CLI route.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
# lib/ - commented out to allow frontend/lib/ to be tracked
lib64/
parts/
sdist/
Expand Down Expand Up @@ -65,6 +65,9 @@ local_settings.py
db.sqlite3
db.sqlite3-journal

# Kids Tutor Database (local development only)
/data/kids_tutor.db

# Flask stuff:
instance/
.webassets-cache
Expand Down
2 changes: 2 additions & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Vercel ignore file - FastAPI backend has been removed
# Only Next.js frontend is deployed
161 changes: 161 additions & 0 deletions MERGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# MERGE Instructions - Kids Science Tutor with Persistent RAG

## Branch Information
- **Feature Branch**: `feature/activity-2-kids-tutor-quiz`
- **Target Branch**: `main`
- **Purpose**: Complete Kids Science Tutor MVP with persistent SQLite embeddings and RAG integration

## Changes Summary
This branch transforms the application into a comprehensive Kids Science Tutor with persistent RAG functionality:

### Database & Backend Changes
- ✅ **SQLite Integration**: Complete database system with `better-sqlite3`
- ✅ **Persistent Embeddings**: `pdf_embeddings` table with integer foreign keys to `pdf_metadata`
- ✅ **Database Schema**: Kids, sessions, conversations, quiz_questions, pdf_metadata, completed_topics
- ✅ **RAG System**: Moved from temporary JSON to persistent SQLite storage
- ✅ **Auto-Initialization**: Automatically embeds Grade-3 PDFs on startup if OpenAI key exists

### Kids Science Tutor Features
- ✅ **Kid Login System**: Name + PIN authentication (`/login`)
- ✅ **Reading Sessions**: Dynamic content from vector search, 30-line chunks, 5-minute timer
- ✅ **Adaptive Quizzing**: OpenAI-generated questions from PDF content, tracks previous questions
- ✅ **Progress Tracking**: Topics completed, quiz scores, session history
- ✅ **Parent Reports**: Comprehensive progress dashboard (`/report/[kidId]`)
- ✅ **10 Grade-3 Science PDFs**: Auto-generated content (Planets, Constellations, Rocks, etc.)

### Admin & RAG Features
- ✅ **PDF Upload System**: Parents can upload PDFs with metadata tracking
- ✅ **Vector Database**: Semantic search with cosine similarity, FTS5 full-text search
- ✅ **Reindex Endpoint**: `/api/reindex` to rebuild embeddings from scratch
- ✅ **Health Monitoring**: `/api/health` shows database and embeddings status
- ✅ **Enhanced Landing Page**: Admin tools, system health, Kids Tutor navigation

### Technical Improvements
- ✅ **File Organization**: Moved `lib/db.ts` to `frontend/lib/db.ts` for better Next.js integration
- ✅ **Import Path Fixes**: Corrected all relative imports across API routes
- ✅ **Error Handling**: Comprehensive logging and error recovery
- ✅ **UI Fixes**: Quiz option text visibility, responsive design improvements

## Merge Options

### Option 1: GitHub Pull Request (Recommended)

#### Step 1: Push the feature branch
```bash
git push origin feature/activity-2-kids-tutor-quiz
```

#### Step 2: Create Pull Request
1. Go to your GitHub repository
2. Click "Compare & pull request" for the `feature/activity-2-kids-tutor-quiz` branch
3. Fill in the PR details:
- **Title**: "Complete Kids Science Tutor MVP with Persistent RAG System"
- **Description**: Copy the changes summary from above
4. Assign reviewers if needed
5. Click "Create pull request"

#### Step 3: Review and Merge
1. Review the changes in the GitHub interface
2. Run any automated tests/checks
3. Click "Merge pull request"
4. Choose merge type:
- **"Create a merge commit"** - Preserves branch history
- **"Squash and merge"** - Combines all commits into one clean commit
- **"Rebase and merge"** - Replays commits without merge commit
5. Confirm the merge
6. Delete the feature branch after successful merge

### Option 2: GitHub CLI (Command Line)

#### Prerequisites
```bash
# Install GitHub CLI if not already installed
# https://cli.github.com/

# Authenticate with GitHub
gh auth login
```

#### Step 1: Push and create PR
```bash
# Push the feature branch
git push origin feature/activity-2-kids-tutor-quiz

# Create pull request via CLI
gh pr create \
--title "Complete Kids Science Tutor MVP with Persistent RAG System" \
--body "Full Kids Science Tutor implementation with persistent SQLite embeddings, adaptive quizzing, progress tracking, and admin tools. Includes database schema, vector search, auto-initialization, and comprehensive error handling." \
--base main \
--head feature/activity-2-kids-tutor-quiz
```

#### Step 2: Review and merge via CLI
```bash
# View the PR
gh pr view

# Merge the PR (choose one option):
# Option A: Merge commit
gh pr merge --merge

# Option B: Squash merge (recommended for feature branches)
gh pr merge --squash

# Option C: Rebase merge
gh pr merge --rebase
```

#### Step 3: Cleanup
```bash
# Delete the feature branch locally
git branch -d feature/activity-2-kids-tutor-quiz

# Delete the remote feature branch
git push origin --delete feature/activity-2-kids-tutor-quiz
```

## Post-Merge Verification

After merging, verify the deployment works correctly:

1. **Check Vercel Deployment**: Ensure the app redeploys automatically
2. **Test Core Functionality**:
```bash
curl -s https://your-app.vercel.app/api/health
curl -s https://your-app.vercel.app/api/kids/login -d '{"name":"Test","pin":"1234"}'
```
3. **Test Kids Tutor Flow**:
- Visit `/login` and create a test kid
- Start a reading session at `/read/[kidId]`
- Complete quiz and check progress at `/report/[kidId]`
4. **Test Admin Features**:
- Upload a PDF via the landing page
- Use "Rebuild Vector DB" button
- Check system health endpoint

## Rollback Plan (If Issues Occur)

If problems arise after merging:

```bash
# Find the merge commit hash
git log --oneline -10

# Revert the merge commit
git revert -m 1 <merge-commit-hash>

# Push the revert
git push origin main
```

## Notes
- **Persistent Storage**: All data now stored in SQLite (`data/kids_tutor.db`) - survives deployments
- **Auto-Initialization**: Grade-3 PDFs automatically embedded on first startup with OpenAI key
- **Node.js Version**: Requires Node.js 20+ for `better-sqlite3` compatibility
- **Environment Variables**: `OPENAI_API_KEY` required for embeddings and quiz generation
- **Database Migration**: Automatically handles schema updates and data migration

---
**Created**: September 23, 2025
**Author**: AI Assistant
**Branch**: feature/activity-2-kids-tutor-quiz → main
Loading