ExperimentAI is a local-first AI-powered virtual science laboratory that enables students to perform physics, electrical, and astronomy experiments with real-time AI assistance, offline capability, and collaborative features.
- Offline Experiments: Run simulations without internet connectivity
- Local SQLite Database: All experiment data stored locally first
- Automatic Sync: PowerSync synchronizes with Supabase when online
- Resilient State: Continue working during network interruptions
- Real-time Help: Ask questions during experiments
- Concept Explanations: AI explains physics, circuits, and astronomy concepts
- Knowledge Retrieval: Tavily integration provides authoritative scientific sources
- Context-Aware: Assistant references your current experiment
- Automatic Analysis: Mastra workflow analyzes completed experiments
- Structured Insights: Generates observations, conclusions, and recommendations
- Learning Progress: AI tracks experiment history for personalized guidance
- Error Detection: Identifies incorrect configurations and suggests fixes
- Automatic Entries: Every experiment creates a structured notebook record
- AI Explanations: Each entry includes AI-generated analysis
- Cross-Device Access: Notebooks sync via PowerSync
- Persistent History: Track learning progress over time
- Real-time Sync: Multiple users can observe/modify same experiment
- Shared State: PowerSync keeps all participants synchronized
- Teacher Dashboard: Educators can monitor student experiments
- Team Learning: Students collaborate on complex simulations
- Frontend: React 18, React Three Fiber, Three.js
- Styling: Tailwind CSS, Framer Motion
- Build Tool: Vite
- Sync Engine: PowerSync (SQLite ↔ Supabase PostgreSQL)
- Backend: Supabase (Authentication, PostgreSQL, RLS)
- AI Framework: Mastra (agents + workflows)
- Knowledge Retrieval: Tavily Search API
- AI Model: OpenAI GPT-4 (via Mastra)
- Node.js 18+
- Supabase account
- PowerSync account
- OpenAI API key
- Tavily API key
npm install
cp .env.example .env
### Database Setup
1. Create a Supabase project
2. Run the schema migration:
```bash
# In Supabase SQL Editor, run:
supabase/schema.sql
- Configure PowerSync:
- Create PowerSync instance
- Connect to your Supabase database
- Configure sync rules (see
docs/powersync-setup.md)
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
VITE_POWERSYNC_URL=your_powersync_instance_url
VITE_OPENAI_API_KEY=your_openai_api_key
VITE_TAVILY_API_KEY=your_tavily_api_keynpm run devThe application will be available at http://localhost:3000
User Action → Local SQLite (PowerSync) → Supabase PostgreSQL
↓
Instant UI Update
↓
Background Sync (when online)
Experiment Completed → Mastra Workflow Triggered
↓
AI Analyzes Data
↓
Generates Structured Insights
↓
Stores in Local DB + Syncs
↓
Creates Notebook Entry
User Question → Tavily Search (scientific sources)
↓
Mastra Agent (GPT-4)
↓
Contextual Answer + Citations
- Pendulum simulations
- Spring dynamics
- Projectile motion
- Optics experiments
- Real-time measurements with AI analysis
- Drag-and-drop circuit builder
- Component library (batteries, resistors, LEDs, switches)
- Live circuit simulation
- AI error detection for incorrect wiring
- Planetary motion simulation
- Orbital mechanics
- Gravitational interactions
- AI explanations of celestial dynamics