An AI-powered interactive calculus visualization tool that transforms mathematical concepts into dynamic, animated learning experiences.
Mathora gives AI models a new superpower: the ability to create rich, animated visualizations to teach students mathematical concepts. Instead of static graphs or simple explanations, AI can now generate complex animation timelines that show functions morphing, integrals being calculated, and concepts coming to life through smooth, professional animations.
The goal is to enhance student learning by making abstract mathematical concepts tangible and intuitive through visual storytelling, powered by AI's understanding of both mathematics and pedagogy.
- Real-time graphing of mathematical functions using Three.js
- Smooth curve rendering with high-resolution point sampling
- Animated transitions - functions can morph to new equations with customizable duration
- Dynamic domain changes - animate
xminandxmaxin real-time - Flicker-free updates through intelligent interpolation
- Accurate region shading between functions
f(x)andg(x)or above/below the x-axis - Dynamic triangulated mesh that updates as functions change
- Smooth morphing of shaded areas during function transitions
- Stable geometry with incremental interpolation for seamless animations
- Animated tangent lines that slide along function curves
- Dynamic range updates - tangent can move between custom start and end points
- Real-time updates as functions morph or change
- Smooth transitions with customizable animation duration
- Smooth camera movements to different positions during animations
- Integrated with timeline actions - any action can trigger camera movement
- Automatic look-at behavior - camera maintains focus on origin during movement
- OrbitControls integration - students can manually explore after animations complete
- Step-by-step progression - manual control with Next button
- Add, update, and remove actions within each step
- Subtitle system for synchronized explanations per step
- Restart functionality - reset to beginning anytime
- Camera control - optional camera movement with each step
- Natural language input - describe what you want to visualize in plain English
- LLM-backed backend generates complete animation timelines from prompts
- Structured JSON output following strict TypeScript schemas
- Example: "Show me how the integral of sin(x) changes as we shift it vertically"
- Custom axes and grid with labeled tick marks
- High-visibility design optimized for educational use
- Infinite grid plane with fade distance for depth perception
- Clean, modern interface built with Next.js and Tailwind CSS
- Next.js 16 - React framework with App Router
- TypeScript - Type-safe development
- React Three Fiber - 3D graphics in React
- @react-three/drei - Useful helpers (Grid, Line, Text components)
- Three.js - Core 3D rendering engine
- Tailwind CSS - Utility-first styling
- Node.js + Express - RESTful API server
- TypeScript - Type-safe backend code
- Zod - Runtime schema validation
- DeepSeek API - OpenAI-compatible LLM for timeline generation
- dotenv - Environment variable management
MathGPT/
βββ frontend/ # Next.js frontend application
β βββ app/ # Next.js App Router pages
β β βββ page.tsx # Main landing page
β β βββ layout.tsx # Root layout
β βββ components/ # React components
β β βββ math/ # Math visualization components
β β β βββ Axes.tsx # Coordinate axes rendering
β β β βββ Grid.tsx # Grid plane
β β β βββ MathScene.tsx # Main 3D scene
β β β βββ graphFunctions/ # Core visualization components
β β β β βββ FunctionPlot.tsx # Function rendering
β β β β βββ ShadeArea.tsx # Area shading
β β β β βββ Point2D.tsx # Point rendering
β β β β βββ Label2D.tsx # Text labels
β β β β βββ slidingTangent.tsx # Sliding tangent lines
β β β βββ cameraFunctions/
β β β β βββ CameraAnimator.tsx # Camera animation system
β β β βββ timeline/
β β β βββ TimelineController.tsx # Animation controller
β β β βββ coreFunctionTests/ # Component test timelines
β β β βββ functionPlotTimeline.ts
β β β βββ shadeAreaTimeline.ts
β β β βββ pointAndLabelTimeline.ts
β β β βββ slidingTangentTimeline.ts
β β β βββ cameraTimeline.ts
β β βββ TeachingView.tsx # Main teaching interface
β β βββ LandingScreen.tsx # Landing page component
β β βββ MainView.tsx # Graph view container
β βββ package.json
β
βββ backend/ # Express API server
βββ src/
βββ index.ts # Server entry point
βββ routes/
βββ timeline.ts # Timeline generation endpoint
βββ services/
βββ llm.ts # LLM integration (Gemini)
βββ prompt.ts # Prompt engineering
βββ schema.ts # Zod validation schemas
- Node.js 18+ and npm
- Google Gemini API Key (get one at Google AI Studio)
-
Clone the repository
git clone <repository-url> cd MathGPT
-
Set up the backend
cd backend npm install -
Configure environment variables Create a
.envfile in thebackend/directory:DEEPSEEK_API_KEY=your_api_key_here
-
Set up the frontend
cd ../frontend npm install
-
Start the backend server (from
backend/directory)npm start
The backend will run on
http://localhost:3001 -
Start the frontend (from
frontend/directory)npm run dev
The frontend will run on
http://localhost:3000 -
Open your browser Navigate to
http://localhost:3000and start visualizing!
-
Enter a mathematical prompt on the landing screen
- Example: "Show me the area between sin(x) and 0.3cos(x) from -Ο to Ο"
- Example: "Graph y = xΒ² and animate it shifting up by 2 units"
-
Watch the AI generate a complete animation timeline
-
Observe the visualization as functions animate, regions shade, and concepts come to life
-
Use the controls to toggle graph, whiteboard, and explanation panels
You can test individual visualization components by entering specific prompts on the landing screen:
- "area test" - Test the area shading functionality
- "point test" - Test point and label rendering
- "function test" - Test function plotting and animation
- "tangent test" - Test sliding tangent line animations
- "camera test" - Test camera movement and positioning
Each test runs a predefined timeline showcasing the specific component's capabilities. This makes it easy to verify functionality and see examples of each visualization type.
- Support for 3D function visualization
- Multi-step problem solving with intermediate visualizations
- Interactive question-answering with contextual animations
- Support for parametric equations and polar coordinates
- Riemann sum visualizations with animated rectangles
- Custom camera controller for more precise camera movements
- Additional animation types for specialized math concepts
- Step-by-step problem breakdowns
- Interactive exercises with feedback
- Export animations as videos or GIFs
- Collaborative viewing and sharing
- Integration with learning management systems
- Performance optimization for complex animations
- Mobile device support
- Offline mode with local LLM support
- Plugin system for custom visualization types
- Multi-language support
- Customizable themes and color schemes
- Accessibility improvements (screen reader support)
- Keyboard shortcuts for power users
- Undo/redo functionality
- Timeline editor for manual fine-tuning
The project includes a comprehensive test suite for individual visualization components located in frontend/components/math/timeline/coreFunctionTests/. Each test provides a complete timeline demonstrating the component's functionality:
functionPlotTimeline.ts- Tests function rendering and morphingshadeAreaTimeline.ts- Tests area shading between functionspointAndLabelTimeline.ts- Tests point and label placementslidingTangentTimeline.ts- Tests animated tangent line slidingcameraTimeline.ts- Tests camera movement and positioning
You can run these tests by entering specific prompts (see Usage section above) or by importing them directly in your code.
Currently me, Shourya Sheth and Saf Nasim are working on this