- Backend API (Express + TypeScript)
- Hand Tracking Service (Python + WebSocket)
- Frontend (Next.js 16)
Quick Start
Start all three services in separate terminal windows:All three services must be running for full functionality. Hand tracking can be skipped if you don’t need that feature.
Service Details
1. Hand Tracking Service
The Python WebSocket server captures webcam input and streams hand landmark data to the frontend.- Port:
8765 - Protocol: WebSocket (
ws://localhost:8765) - Frame Rate: 60 fps (capped)
- Camera: Index 0 (default webcam)
Make sure your webcam is not in use by another application before starting.
2. Backend API
The Express + TypeScript backend provides REST endpoints and Server-Sent Events for agent streaming.- Health Check:
http://localhost:8000/api/health - API Base:
http://localhost:8000/api - SSE Streaming: Various agent endpoints
3. Frontend
The Next.js 16 frontend renders the 3D knowledge graph and provides the learning interface.- 3D graph visualization (Three.js + React Flow)
- Real-time agent activity streaming
- Hand tracking integration
- Interactive tutoring sessions
/backend-api/* requests to the backend:
next.config.ts
Development Workflow
Recommended Terminal Setup
Use a terminal multiplexer liketmux or split terminals:
- tmux
- Separate Windows
Hot Reloading
- Backend
- Frontend
- Hand Tracking
Backend uses Changes to
tsx watch for automatic reloading:package.json
src/**/*.ts files will trigger automatic restart.Using Sprout
Once all services are running:Create a Topic
- Open
http://localhost:3000 - Click “Add a branch” or create a new topic
- Enter a topic title (e.g., “Linear Algebra”)
- Optionally upload documents for context
Generate Learning Path
Click “Run agents” to start the two-phase generation:Phase 1: Topic Agent
- Generates 6-10 concept nodes
- Extracts document context
- Creates prerequisite edges
- Runs in parallel for each concept (max 3 concurrent)
- Creates 8-12 subconcepts per concept
- Generates diagnostic questions
Set
NEXT_PUBLIC_SMALL_AGENTS=true to generate 1-2 concepts and 2-3 subconcepts for faster testing.Answer Diagnostic Questions
Click on a concept node to answer diagnostic questions. The system will personalize the subconcept graph based on your performance.
Enable Hand Tracking
Toggle “Hand tracking” in the bottom-right corner to control the camera and graph with hand gestures.Gestures:
- Normal hand: Orbit camera with index finger
- Open palm (3s hold): Enter grab mode
- Grab + palm over node: Drag node in 3D space
Monitoring Activity
Backend Logs
The backend logs include:- Agent activity (tool calls, reasoning)
- Database operations
- API requests
- Errors and warnings
Frontend SSE Streams
Open browser DevTools to see Server-Sent Events:- Open DevTools (F12)
- Go to Network tab
- Filter by “EventStream”
- Click on an active connection to see events:
agent_startagent_reasoningtool_calltool_resultnode_creatededge_createdagent_done
Hand Tracking Debug
The Python service prints frame-by-frame data:Stopping Services
- Graceful Shutdown
- Kill All
Press
Ctrl+C in each terminal window:- Stop hand tracking:
Ctrl+C - Stop backend:
Ctrl+C - Stop frontend:
Ctrl+C
Troubleshooting
Port already in use
Port already in use
Error:
EADDRINUSE: address already in useSolution: Kill the process using the port:Hand tracking not moving
Hand tracking not moving
The 3D pointer doesn’t respond to hand movements.Solution:
- Ensure
python backend.pyis running - Check browser console for WebSocket connection errors
- Grant camera permission when prompted
- Verify camera is not in use by another app
SSE streaming stops
SSE streaming stops
Agent activity stops streaming in the UI.Solution:
- Verify
NEXT_PUBLIC_BACKEND_ORIGINmatches backend URL - Check backend logs for errors
- Frontend bypasses proxy for SSE - ensure direct connection works
- Check CORS is enabled (default in
src/index.ts)
Database locked error
Database locked error
Error:
SQLITE_BUSY: database is lockedSolution:- Ensure only one backend instance is running
- Close any DB browser tools accessing
sprout.db - Restart the backend
Document upload fails
Document upload fails
S3 upload returns 403 or 500 error.Solution:
- Verify AWS credentials in
.env - Check S3 bucket exists and is accessible
- Verify IAM permissions allow
s3:PutObject
Next Steps
Database Migrations
Learn how to manage database schema changes
Hand Tracking Setup
Deep dive into hand tracking configuration