Skip to main content
Sprout consists of three services that must run simultaneously for full functionality:
  1. Backend API (Express + TypeScript)
  2. Hand Tracking Service (Python + WebSocket)
  3. Frontend (Next.js 16)

Quick Start

Start all three services in separate terminal windows:
1

Start Hand Tracking Service

cd sprout-backend
conda activate sprout-cv
python backend.py
Expected output:
WebSocket Server started on ws://localhost:8765
2

Start Backend API

cd sprout-backend
npm run dev
Expected output:
Default user seeded.
Sprout backend running on http://localhost:8000
3

Start Frontend

cd sprout-frontend
npm run dev
Expected output:
▲ Next.js 16.1.6
- Local:        http://localhost:3000
4

Open in Browser

Navigate to http://localhost:3000 and start using Sprout.
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.
cd sprout-backend
conda activate sprout-cv
python backend.py
Configuration:
  • 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.
cd sprout-backend
npm run dev
# Uses tsx watch for hot reloading
Endpoints:
  • Health Check: http://localhost:8000/api/health
  • API Base: http://localhost:8000/api
  • SSE Streaming: Various agent endpoints
Auto-Seeding: On startup, the backend automatically creates a default user:
DEFAULT_USER_ID = "00000000-0000-0000-0000-000000000000"
email = "[email protected]"
Sprout is a single-user application with no authentication. The default user is auto-created on first startup.

3. Frontend

The Next.js 16 frontend renders the 3D knowledge graph and provides the learning interface.
cd sprout-frontend
npm run dev
# Starts Next.js dev server with hot reloading
Features:
  • 3D graph visualization (Three.js + React Flow)
  • Real-time agent activity streaming
  • Hand tracking integration
  • Interactive tutoring sessions
Proxy Configuration: The frontend proxies /backend-api/* requests to the backend:
next.config.ts
async rewrites() {
  return [
    {
      source: "/backend-api/:path*",
      destination: "http://localhost:8000/:path*",
    },
  ];
}

Development Workflow

Use a terminal multiplexer like tmux or split terminals:
# Create a new tmux session
tmux new -s sprout

# Split into three panes
# Ctrl+b then %  (vertical split)
# Ctrl+b then "  (horizontal split)

# Pane 1: Hand tracking
cd sprout-backend
conda activate sprout-cv
python backend.py

# Pane 2: Backend
cd sprout-backend
npm run dev

# Pane 3: Frontend
cd sprout-frontend
npm run dev

Hot Reloading

Backend uses tsx watch for automatic reloading:
package.json
"dev": "tsx watch src/index.ts"
Changes to src/**/*.ts files will trigger automatic restart.

Using Sprout

Once all services are running:
1

Create a Topic

  1. Open http://localhost:3000
  2. Click “Add a branch” or create a new topic
  3. Enter a topic title (e.g., “Linear Algebra”)
  4. Optionally upload documents for context
2

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
Phase 2: Subconcept Bootstrap
  • 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.
3

Answer Diagnostic Questions

Click on a concept node to answer diagnostic questions. The system will personalize the subconcept graph based on your performance.
4

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
5

Learn Subconcepts

Click on a subconcept to start an interactive tutoring session with chunk-based teaching and exercises.

Monitoring Activity

Backend Logs

The backend logs include:
  • Agent activity (tool calls, reasoning)
  • Database operations
  • API requests
  • Errors and warnings
Default user seeded.
Sprout backend running on http://localhost:8000
# Agent logs appear here during generation

Frontend SSE Streams

Open browser DevTools to see Server-Sent Events:
  1. Open DevTools (F12)
  2. Go to Network tab
  3. Filter by “EventStream”
  4. Click on an active connection to see events:
    • agent_start
    • agent_reasoning
    • tool_call
    • tool_result
    • node_created
    • edge_created
    • agent_done

Hand Tracking Debug

The Python service prints frame-by-frame data:
WebSocket Server started on ws://localhost:8765
Client connected
Sending frame data: {"hands": [{"handedness": "Right", "x": 0.5, ...}]}

Stopping Services

Press Ctrl+C in each terminal window:
  1. Stop hand tracking: Ctrl+C
  2. Stop backend: Ctrl+C
  3. Stop frontend: Ctrl+C

Troubleshooting

Error: EADDRINUSE: address already in useSolution: Kill the process using the port:
lsof -ti:8000 | xargs kill -9  # Backend
lsof -ti:3000 | xargs kill -9  # Frontend
lsof -ti:8765 | xargs kill -9  # Hand tracking
The 3D pointer doesn’t respond to hand movements.Solution:
  1. Ensure python backend.py is running
  2. Check browser console for WebSocket connection errors
  3. Grant camera permission when prompted
  4. Verify camera is not in use by another app
Agent activity stops streaming in the UI.Solution:
  1. Verify NEXT_PUBLIC_BACKEND_ORIGIN matches backend URL
  2. Check backend logs for errors
  3. Frontend bypasses proxy for SSE - ensure direct connection works
  4. Check CORS is enabled (default in src/index.ts)
Error: SQLITE_BUSY: database is lockedSolution:
  1. Ensure only one backend instance is running
  2. Close any DB browser tools accessing sprout.db
  3. Restart the backend
S3 upload returns 403 or 500 error.Solution:
  1. Verify AWS credentials in .env
  2. Check S3 bucket exists and is accessible
  3. Verify IAM permissions allow s3:PutObject
Test with AWS CLI:
aws s3 cp test.txt s3://your-bucket-name/test.txt

Next Steps

Database Migrations

Learn how to manage database schema changes

Hand Tracking Setup

Deep dive into hand tracking configuration

Build docs developers (and LLMs) love